diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index 874b5cbea894..9e481e0ba29b 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -692,6 +692,15 @@ Services.obs.addObserver(function onSystemMessageOpenApp(subject, topic, data) { shell.openAppForSystemMessage(msg); }, 'system-messages-open-app', false); +Services.obs.addObserver(function onInterAppCommConnect(subject, topic, data) { + data = JSON.parse(data); + shell.sendChromeEvent({ type: "inter-app-comm-permission", + chromeEventID: data.callerID, + manifestURL: data.manifestURL, + keyword: data.keyword, + peers: data.appsToSelect }); +}, 'inter-app-comm-select-app', false); + Services.obs.addObserver(function onFullscreenOriginChange(subject, topic, data) { shell.sendChromeEvent({ type: "fullscreenoriginchange", fullscreenorigin: data }); @@ -759,6 +768,13 @@ var CustomEventManager = { case 'captive-portal-login-cancel': CaptivePortalLoginHelper.handleEvent(detail); break; + case 'inter-app-comm-permission': + Services.obs.notifyObservers(null, 'inter-app-comm-select-app-result', + JSON.stringify({ callerID: detail.chromeEventID, + keyword: detail.keyword, + manifestURL: detail.manifestURL, + selectedApps: detail.peers })); + break; case 'inputmethod-update-layouts': KeyboardHelper.handleEvent(detail); break; diff --git a/b2g/components/B2GComponents.manifest b/b2g/components/B2GComponents.manifest index 6c72e1dd7e8b..6bffaa7a081b 100644 --- a/b2g/components/B2GComponents.manifest +++ b/b2g/components/B2GComponents.manifest @@ -24,10 +24,6 @@ category xpcom-directory-providers b2g-directory-provider @mozilla.org/b2g/direc component {3a54788b-48cc-4ab4-93d6-0d6a8ef74f8e} ActivitiesGlue.js contract @mozilla.org/dom/activities/ui-glue;1 {3a54788b-48cc-4ab4-93d6-0d6a8ef74f8e} -# InterAppCommUIGlue.js -component {879ee66c-e246-11e3-9910-74d02b97e723} InterAppCommUIGlue.js -contract @mozilla.org/dom/apps/inter-app-comm-ui-glue;1 {879ee66c-e246-11e3-9910-74d02b97e723} - # ProcessGlobal.js component {1a94c87a-5ece-4d11-91e1-d29c29f21b28} ProcessGlobal.js contract @mozilla.org/b2g-process-global;1 {1a94c87a-5ece-4d11-91e1-d29c29f21b28} diff --git a/b2g/components/InterAppCommUIGlue.js b/b2g/components/InterAppCommUIGlue.js deleted file mode 100644 index 4cdeadc9ec80..000000000000 --- a/b2g/components/InterAppCommUIGlue.js +++ /dev/null @@ -1,91 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict" - -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/Promise.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy", - "resource://gre/modules/SystemAppProxy.jsm"); - -const DEBUG = false; -function debug(aMsg) { - dump("-- InterAppCommUIGlue: " + Date.now() + ": " + aMsg + "\n"); -} - -function InterAppCommUIGlue() { - // This matrix is to store the callerID (a random UUID) / deferral binding. - // An example of the object literal is shown below: - // - // { - // "callerID1" : deferred1, - // "callerID2" : deferred2 - // } - this._deferreds = {}; - - // Listen to the result of selected apps from front-end. - SystemAppProxy.addEventListener ("mozIACContentEvent", function (aEvent) { - let detail = aEvent.detail; - if (detail.type != "inter-app-comm-permission") { - return; - } - - if (DEBUG) { - debug("mozIACContentEvent: " + JSON.stringify(detail)); - } - - let callerID = detail.chromeEventID; - let deferred = this._deferreds[callerID]; - if (!deferred) { - if (DEBUG) { - debug("Error! Cannot find the deferred for callerID: " + callerID); - } - return; - } - - delete this._deferreds[callerID]; - deferred.resolve({ callerID: callerID, - keyword: detail.keyword, - manifestURL: detail.manifestURL, - selectedApps: detail.peers }); - }.bind(this)); -} - -InterAppCommUIGlue.prototype = { - selectApps: function(aCallerID, aPubAppManifestURL, aKeyword, aAppsToSelect) { - let deferred = Promise.defer(); - this._deferreds[aCallerID] = deferred; - - SystemAppProxy._sendCustomEvent("mozIACChromeEvent", - { type: "inter-app-comm-permission", - chromeEventID: aCallerID, - manifestURL: aPubAppManifestURL, - keyword: aKeyword, - peers: aAppsToSelect }); - - // TODO Bug 897169 Simulate the return of the app-selected result by - // the prompt, which always allows the connection. This dummy codes - // will be removed when the UX/UI for the prompt is ready. - SystemAppProxy._sendCustomEvent("mozIACContentEvent", - { type: "inter-app-comm-permission", - chromeEventID: aCallerID, - manifestURL: aPubAppManifestURL, - keyword: aKeyword, - peers: aAppsToSelect }); - - return deferred.promise; - }, - - classID: Components.ID("{879ee66c-e246-11e3-9910-74d02b97e723}"), - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIInterAppCommUIGlue]) -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([InterAppCommUIGlue]); diff --git a/b2g/components/moz.build b/b2g/components/moz.build index fbaaed2e21bc..66296e4998b5 100644 --- a/b2g/components/moz.build +++ b/b2g/components/moz.build @@ -13,7 +13,6 @@ EXTRA_COMPONENTS += [ 'ContentPermissionPrompt.js', 'FilePicker.js', 'HelperAppDialog.js', - 'InterAppCommUIGlue.js', 'MailtoProtocolHandler.js', 'PaymentGlue.js', 'ProcessGlobal.js', diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 5ce40ff95fc9..ad981c1d851a 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -792,7 +792,6 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@ @BINPATH@/components/FilePicker.js @BINPATH@/components/HelperAppDialog.js @BINPATH@/components/DownloadsUI.js -@BINPATH@/components/InterAppCommUIGlue.js #ifndef MOZ_WIDGET_GONK @BINPATH@/components/SimulatorScreen.js diff --git a/dom/apps/src/InterAppCommService.jsm b/dom/apps/src/InterAppCommService.jsm index c460f7e80c25..c9feb2511a39 100644 --- a/dom/apps/src/InterAppCommService.jsm +++ b/dom/apps/src/InterAppCommService.jsm @@ -52,6 +52,7 @@ const kMessages =["Webapps:Connect", this.InterAppCommService = { init: function() { Services.obs.addObserver(this, "xpcom-shutdown", false); + Services.obs.addObserver(this, "inter-app-comm-select-app-result", false); kMessages.forEach(function(aMsg) { ppmm.addMessageListener(aMsg, this); @@ -543,36 +544,30 @@ this.InterAppCommService = { target: aTarget }; - let glue = Cc["@mozilla.org/dom/apps/inter-app-comm-ui-glue;1"] - .createInstance(Ci.nsIInterAppCommUIGlue); - if (glue) { - glue.selectApps(callerID, pubAppManifestURL, keyword, appsToSelect).then( - function(aData) { - this._handleSelectedApps(aData); - }.bind(this), - function(aError) { - if (DEBUG) { - debug("Error occurred in the UI glue component. " + aError) - } + // TODO Bug 897169 Temporarily disable the notification for popping up + // the prompt until the UX/UI for the prompt is confirmed. + // + // TODO Bug 908191 We need to change the way of interaction between API and + // run-time prompt from observer notification to xpcom-interface caller. + // + /* + if (DEBUG) debug("appsToSelect: " + appsToSelect); + Services.obs.notifyObservers(null, "inter-app-comm-select-app", + JSON.stringify({ callerID: callerID, + manifestURL: pubAppManifestURL, + keyword: keyword, + appsToSelect: appsToSelect })); + */ - // Resolve the caller as if there were no selected apps. - this._handleSelectedApps({ callerID: callerID, - keyword: keyword, - manifestURL: pubAppManifestURL, - selectedApps: [] }); - }.bind(this) - ); - } else { - if (DEBUG) { - debug("Error! The UI glue component is not implemented.") - } - - // Resolve the caller as if there were no selected apps. - this._handleSelectedApps({ callerID: callerID, - keyword: keyword, - manifestURL: pubAppManifestURL, - selectedApps: [] }); - } + // TODO Bug 897169 Simulate the return of the app-selected result by + // the prompt, which always allows the connection. This dummy codes + // will be removed when the UX/UI for the prompt is ready. + if (DEBUG) debug("appsToSelect: " + appsToSelect); + Services.obs.notifyObservers(null, 'inter-app-comm-select-app-result', + JSON.stringify({ callerID: callerID, + manifestURL: pubAppManifestURL, + keyword: keyword, + selectedApps: appsToSelect })); }, _getConnections: function(aMessage, aTarget) { @@ -785,7 +780,7 @@ this.InterAppCommService = { message: message }); }, - _handleSelectedApps: function(aData) { + _handleSelectcedApps: function(aData) { let callerID = aData.callerID; let caller = this._promptUICallers[callerID]; if (!caller) { @@ -882,11 +877,16 @@ this.InterAppCommService = { switch (aTopic) { case "xpcom-shutdown": Services.obs.removeObserver(this, "xpcom-shutdown"); + Services.obs.removeObserver(this, "inter-app-comm-select-app-result"); kMessages.forEach(function(aMsg) { ppmm.removeMessageListener(aMsg, this); }, this); ppmm = null; break; + case "inter-app-comm-select-app-result": + if (DEBUG) debug("inter-app-comm-select-app-result: " + aData); + this._handleSelectcedApps(JSON.parse(aData)); + break; } } }; diff --git a/dom/interfaces/apps/moz.build b/dom/interfaces/apps/moz.build index f525074165a4..7967d4f13c6b 100644 --- a/dom/interfaces/apps/moz.build +++ b/dom/interfaces/apps/moz.build @@ -12,7 +12,6 @@ XPIDL_SOURCES += [ 'nsIDOMApplicationRegistry2.idl', 'nsIDOMMozApplicationEvent.idl', 'nsIInterAppCommService.idl', - 'nsIInterAppCommUIGlue.idl' ] XPIDL_MODULE = 'dom_apps' diff --git a/dom/interfaces/apps/nsIInterAppCommUIGlue.idl b/dom/interfaces/apps/nsIInterAppCommUIGlue.idl deleted file mode 100644 index 6e98265183c2..000000000000 --- a/dom/interfaces/apps/nsIInterAppCommUIGlue.idl +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -/** - * To be implemented by @mozilla.org/dom/apps/inter-app-comm-ui-glue;1 - */ -[scriptable, uuid(634555c6-e246-11e3-b427-74d02b97e723)] -interface nsIInterAppCommUIGlue : nsISupports -{ - /** - * This method is to notify the prompt to let the user select some of the - * IAC-eligible apps. - * - * @param callerID The generated UUID to identify the caller and - * should be unique for each call. - * @param pubAppManifestURL The manifest URL of the publisher. - * @param keyword The IAC keyword. - * @param appsToSelect The IAC-eligible apps for selection. - * - * Returns a promise. - */ - jsval selectApps(in AString callerID, - in AString pubAppManifestURL, - in AString keyword, - in jsval appsToSelect); -};