From 12c6f5d749c0b5ef68832e6638ddf1e39917c860 Mon Sep 17 00:00:00 2001 From: cctuan Date: Thu, 10 Jul 2014 19:12:11 +0800 Subject: [PATCH] Bug 1036788 - Stop using origins to identify apps --- apps/system/js/app_window_factory.js | 2 +- apps/system/js/app_window_manager.js | 15 +++++++++------ apps/system/js/icc_worker.js | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/system/js/app_window_factory.js b/apps/system/js/app_window_factory.js index 83dfbac69f92..6d80f6742df3 100644 --- a/apps/system/js/app_window_factory.js +++ b/apps/system/js/app_window_factory.js @@ -176,7 +176,7 @@ if (config.manifest.role === 'search') { return; } - var app = AppWindowManager.getApp(config.origin); + var app = AppWindowManager.getApp(config.origin, config.manifestURL); if (app) { app.reviveBrowser(); } else if (config.origin !== homescreenLauncher.origin) { diff --git a/apps/system/js/app_window_manager.js b/apps/system/js/app_window_manager.js index ed959176d1f0..bb0c722686a7 100644 --- a/apps/system/js/app_window_manager.js +++ b/apps/system/js/app_window_manager.js @@ -42,11 +42,13 @@ /** * Match app origin and get the first matching one. * @param {String} origin The origin to be matched. + * @param {String} [manifestURL] The manifestURL to be matched. * @return {AppWindow} The app window object matched. */ - getApp: function awm_getApp(origin) { + getApp: function awm_getApp(origin, manifestURL) { for (var id in this._apps) { - if (this._apps[id].origin == origin) { + if (this._apps[id].origin === origin && + (!manifestURL || this._apps[id].manifestURL === manifestURL)) { return this._apps[id]; } } @@ -54,11 +56,11 @@ }, /** - * Match app origin and get the first matching one. + * Get all apps. * @return {Object} The running app window references stored * by its instanceID. */ - getApps: function awm_getApps(origin) { + getApps: function awm_getApps() { return this._apps; }, @@ -679,9 +681,10 @@ * @param {String} origin The origin of the running app window to be killed. * @memberOf module:AppWindowManager */ - kill: function awm_kill(origin) { + kill: function awm_kill(origin, manifestURL) { for (var id in this._apps) { - if (this._apps[id].origin === origin) { + if (this._apps[id].origin === origin && + (!manifestURL || this._apps[id].manifestURL === manifestURL)) { this._apps[id].kill(); } } diff --git a/apps/system/js/icc_worker.js b/apps/system/js/icc_worker.js index 58e602cd64f6..0e81804c6e65 100644 --- a/apps/system/js/icc_worker.js +++ b/apps/system/js/icc_worker.js @@ -326,7 +326,7 @@ var icc_worker = { 'icc.data': JSON.stringify(message) }); reqIccData.onsuccess = function icc_getIccData() { - if (AppWindowManager.getApps(application)) { + if (AppWindowManager.getApp(application)) { return DUMP('Settings is running. Ignoring'); } navigator.mozApps.mgmt.getAll().onsuccess = function gotApps(evt) {