зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset eab1c325d9fb (bug 908191) since it already landed on m-i
This commit is contained in:
Родитель
964a88cec3
Коммит
c66ee7b583
|
@ -692,6 +692,15 @@ Services.obs.addObserver(function onSystemMessageOpenApp(subject, topic, data) {
|
||||||
shell.openAppForSystemMessage(msg);
|
shell.openAppForSystemMessage(msg);
|
||||||
}, 'system-messages-open-app', false);
|
}, '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) {
|
Services.obs.addObserver(function onFullscreenOriginChange(subject, topic, data) {
|
||||||
shell.sendChromeEvent({ type: "fullscreenoriginchange",
|
shell.sendChromeEvent({ type: "fullscreenoriginchange",
|
||||||
fullscreenorigin: data });
|
fullscreenorigin: data });
|
||||||
|
@ -759,6 +768,13 @@ var CustomEventManager = {
|
||||||
case 'captive-portal-login-cancel':
|
case 'captive-portal-login-cancel':
|
||||||
CaptivePortalLoginHelper.handleEvent(detail);
|
CaptivePortalLoginHelper.handleEvent(detail);
|
||||||
break;
|
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':
|
case 'inputmethod-update-layouts':
|
||||||
KeyboardHelper.handleEvent(detail);
|
KeyboardHelper.handleEvent(detail);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,10 +24,6 @@ category xpcom-directory-providers b2g-directory-provider @mozilla.org/b2g/direc
|
||||||
component {3a54788b-48cc-4ab4-93d6-0d6a8ef74f8e} ActivitiesGlue.js
|
component {3a54788b-48cc-4ab4-93d6-0d6a8ef74f8e} ActivitiesGlue.js
|
||||||
contract @mozilla.org/dom/activities/ui-glue;1 {3a54788b-48cc-4ab4-93d6-0d6a8ef74f8e}
|
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
|
# ProcessGlobal.js
|
||||||
component {1a94c87a-5ece-4d11-91e1-d29c29f21b28} ProcessGlobal.js
|
component {1a94c87a-5ece-4d11-91e1-d29c29f21b28} ProcessGlobal.js
|
||||||
contract @mozilla.org/b2g-process-global;1 {1a94c87a-5ece-4d11-91e1-d29c29f21b28}
|
contract @mozilla.org/b2g-process-global;1 {1a94c87a-5ece-4d11-91e1-d29c29f21b28}
|
||||||
|
|
|
@ -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]);
|
|
|
@ -13,7 +13,6 @@ EXTRA_COMPONENTS += [
|
||||||
'ContentPermissionPrompt.js',
|
'ContentPermissionPrompt.js',
|
||||||
'FilePicker.js',
|
'FilePicker.js',
|
||||||
'HelperAppDialog.js',
|
'HelperAppDialog.js',
|
||||||
'InterAppCommUIGlue.js',
|
|
||||||
'MailtoProtocolHandler.js',
|
'MailtoProtocolHandler.js',
|
||||||
'PaymentGlue.js',
|
'PaymentGlue.js',
|
||||||
'ProcessGlobal.js',
|
'ProcessGlobal.js',
|
||||||
|
|
|
@ -792,7 +792,6 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
|
||||||
@BINPATH@/components/FilePicker.js
|
@BINPATH@/components/FilePicker.js
|
||||||
@BINPATH@/components/HelperAppDialog.js
|
@BINPATH@/components/HelperAppDialog.js
|
||||||
@BINPATH@/components/DownloadsUI.js
|
@BINPATH@/components/DownloadsUI.js
|
||||||
@BINPATH@/components/InterAppCommUIGlue.js
|
|
||||||
|
|
||||||
#ifndef MOZ_WIDGET_GONK
|
#ifndef MOZ_WIDGET_GONK
|
||||||
@BINPATH@/components/SimulatorScreen.js
|
@BINPATH@/components/SimulatorScreen.js
|
||||||
|
|
|
@ -52,6 +52,7 @@ const kMessages =["Webapps:Connect",
|
||||||
this.InterAppCommService = {
|
this.InterAppCommService = {
|
||||||
init: function() {
|
init: function() {
|
||||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||||
|
Services.obs.addObserver(this, "inter-app-comm-select-app-result", false);
|
||||||
|
|
||||||
kMessages.forEach(function(aMsg) {
|
kMessages.forEach(function(aMsg) {
|
||||||
ppmm.addMessageListener(aMsg, this);
|
ppmm.addMessageListener(aMsg, this);
|
||||||
|
@ -543,36 +544,30 @@ this.InterAppCommService = {
|
||||||
target: aTarget
|
target: aTarget
|
||||||
};
|
};
|
||||||
|
|
||||||
let glue = Cc["@mozilla.org/dom/apps/inter-app-comm-ui-glue;1"]
|
// TODO Bug 897169 Temporarily disable the notification for popping up
|
||||||
.createInstance(Ci.nsIInterAppCommUIGlue);
|
// the prompt until the UX/UI for the prompt is confirmed.
|
||||||
if (glue) {
|
//
|
||||||
glue.selectApps(callerID, pubAppManifestURL, keyword, appsToSelect).then(
|
// TODO Bug 908191 We need to change the way of interaction between API and
|
||||||
function(aData) {
|
// run-time prompt from observer notification to xpcom-interface caller.
|
||||||
this._handleSelectedApps(aData);
|
//
|
||||||
}.bind(this),
|
/*
|
||||||
function(aError) {
|
if (DEBUG) debug("appsToSelect: " + appsToSelect);
|
||||||
if (DEBUG) {
|
Services.obs.notifyObservers(null, "inter-app-comm-select-app",
|
||||||
debug("Error occurred in the UI glue component. " + aError)
|
JSON.stringify({ callerID: callerID,
|
||||||
}
|
manifestURL: pubAppManifestURL,
|
||||||
|
keyword: keyword,
|
||||||
|
appsToSelect: appsToSelect }));
|
||||||
|
*/
|
||||||
|
|
||||||
// Resolve the caller as if there were no selected apps.
|
// TODO Bug 897169 Simulate the return of the app-selected result by
|
||||||
this._handleSelectedApps({ callerID: callerID,
|
// the prompt, which always allows the connection. This dummy codes
|
||||||
keyword: keyword,
|
// will be removed when the UX/UI for the prompt is ready.
|
||||||
manifestURL: pubAppManifestURL,
|
if (DEBUG) debug("appsToSelect: " + appsToSelect);
|
||||||
selectedApps: [] });
|
Services.obs.notifyObservers(null, 'inter-app-comm-select-app-result',
|
||||||
}.bind(this)
|
JSON.stringify({ callerID: callerID,
|
||||||
);
|
manifestURL: pubAppManifestURL,
|
||||||
} else {
|
keyword: keyword,
|
||||||
if (DEBUG) {
|
selectedApps: appsToSelect }));
|
||||||
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: [] });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_getConnections: function(aMessage, aTarget) {
|
_getConnections: function(aMessage, aTarget) {
|
||||||
|
@ -785,7 +780,7 @@ this.InterAppCommService = {
|
||||||
message: message });
|
message: message });
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleSelectedApps: function(aData) {
|
_handleSelectcedApps: function(aData) {
|
||||||
let callerID = aData.callerID;
|
let callerID = aData.callerID;
|
||||||
let caller = this._promptUICallers[callerID];
|
let caller = this._promptUICallers[callerID];
|
||||||
if (!caller) {
|
if (!caller) {
|
||||||
|
@ -882,11 +877,16 @@ this.InterAppCommService = {
|
||||||
switch (aTopic) {
|
switch (aTopic) {
|
||||||
case "xpcom-shutdown":
|
case "xpcom-shutdown":
|
||||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||||
|
Services.obs.removeObserver(this, "inter-app-comm-select-app-result");
|
||||||
kMessages.forEach(function(aMsg) {
|
kMessages.forEach(function(aMsg) {
|
||||||
ppmm.removeMessageListener(aMsg, this);
|
ppmm.removeMessageListener(aMsg, this);
|
||||||
}, this);
|
}, this);
|
||||||
ppmm = null;
|
ppmm = null;
|
||||||
break;
|
break;
|
||||||
|
case "inter-app-comm-select-app-result":
|
||||||
|
if (DEBUG) debug("inter-app-comm-select-app-result: " + aData);
|
||||||
|
this._handleSelectcedApps(JSON.parse(aData));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,6 @@ XPIDL_SOURCES += [
|
||||||
'nsIDOMApplicationRegistry2.idl',
|
'nsIDOMApplicationRegistry2.idl',
|
||||||
'nsIDOMMozApplicationEvent.idl',
|
'nsIDOMMozApplicationEvent.idl',
|
||||||
'nsIInterAppCommService.idl',
|
'nsIInterAppCommService.idl',
|
||||||
'nsIInterAppCommUIGlue.idl'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
XPIDL_MODULE = 'dom_apps'
|
XPIDL_MODULE = 'dom_apps'
|
||||||
|
|
|
@ -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);
|
|
||||||
};
|
|
Загрузка…
Ссылка в новой задаче