зеркало из https://github.com/mozilla/gecko-dev.git
Bug 876397 - Inter-App Communication API (part 1, Web IDLs). r=nsm,ted sr=smaug
This commit is contained in:
Родитель
8c9f7570bc
Коммит
1f00287b51
|
@ -750,6 +750,12 @@ pref("disk_space_watcher.enabled", true);
|
||||||
// Enable promise
|
// Enable promise
|
||||||
pref("dom.promise.enabled", false);
|
pref("dom.promise.enabled", false);
|
||||||
|
|
||||||
|
// DOM Inter-App Communication API.
|
||||||
|
#ifdef MOZ_WIDGET_GONK
|
||||||
|
// Enable this only for gonk-specific build but not for desktop build.
|
||||||
|
pref("dom.inter-app-communication-api.enabled", true);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Allow ADB to run for this many hours before disabling
|
// Allow ADB to run for this many hours before disabling
|
||||||
// (only applies when marionette is disabled)
|
// (only applies when marionette is disabled)
|
||||||
// 0 disables the timer.
|
// 0 disables the timer.
|
||||||
|
|
|
@ -505,6 +505,10 @@
|
||||||
@BINPATH@/components/Push.manifest
|
@BINPATH@/components/Push.manifest
|
||||||
@BINPATH@/components/PushServiceLauncher.js
|
@BINPATH@/components/PushServiceLauncher.js
|
||||||
|
|
||||||
|
@BINPATH@/components/InterAppComm.manifest
|
||||||
|
@BINPATH@/components/InterAppConnection.js
|
||||||
|
@BINPATH@/components/InterAppMessagePort.js
|
||||||
|
|
||||||
@BINPATH@/components/nsDOMIdentity.js
|
@BINPATH@/components/nsDOMIdentity.js
|
||||||
@BINPATH@/components/nsIDService.js
|
@BINPATH@/components/nsIDService.js
|
||||||
@BINPATH@/components/Identity.manifest
|
@BINPATH@/components/Identity.manifest
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* 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 "InterAppComm.h"
|
||||||
|
#include "nsContentUtils.h"
|
||||||
|
#include "nsPIDOMWindow.h"
|
||||||
|
#include "nsJSPrincipals.h"
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
|
#include "AccessCheck.h"
|
||||||
|
|
||||||
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
|
/* static */ bool
|
||||||
|
InterAppComm::EnabledForScope(JSContext* /* unused */, JSObject* aObj)
|
||||||
|
{
|
||||||
|
// Disable the constructors if they're disabled by the preference for sure.
|
||||||
|
if (!Preferences::GetBool("dom.inter-app-communication-api.enabled", false)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only expose the constructors to the chrome codes for Gecko internal uses.
|
||||||
|
// The content pages shouldn't be aware of the constructors.
|
||||||
|
return xpc::AccessCheck::isChrome(aObj);
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
#ifndef mozilla_dom_apps_InterAppComm_h
|
||||||
|
#define mozilla_dom_apps_InterAppComm_h
|
||||||
|
|
||||||
|
// Forward declarations.
|
||||||
|
struct JSContext;
|
||||||
|
class JSObject;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
class InterAppComm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool EnabledForScope(JSContext* /* unused */, JSObject* aObj);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // mozilla_dom_apps_InterAppComm_h
|
|
@ -0,0 +1,8 @@
|
||||||
|
component {9dbfa904-0718-11e3-8e77-0721a45514b8} InterAppConnection.js
|
||||||
|
contract @mozilla.org/dom/inter-app-connection;1 {9dbfa904-0718-11e3-8e77-0721a45514b8}
|
||||||
|
|
||||||
|
component {6a77e9e0-0645-11e3-b90b-73bb7c78e06a} InterAppConnection.js
|
||||||
|
contract @mozilla.org/dom/inter-app-connection-request;1 {6a77e9e0-0645-11e3-b90b-73bb7c78e06a}
|
||||||
|
|
||||||
|
component {c66e0f8c-e3cb-11e2-9e85-43ef6244b884} InterAppMessagePort.js
|
||||||
|
contract @mozilla.org/dom/inter-app-message-port;1 {c66e0f8c-e3cb-11e2-9e85-43ef6244b884}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/* 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 { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
|
function debug(aMsg) {
|
||||||
|
// dump("-- InterAppConnection: " + Date.now() + ": " + aMsg + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MozInterAppConnection implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function InterAppConnection() {
|
||||||
|
debug("InterAppConnection()");
|
||||||
|
this.keyword = null;
|
||||||
|
this.publisher = null;
|
||||||
|
this.subscriber = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
InterAppConnection.prototype = {
|
||||||
|
classDescription: "MozInterAppConnection",
|
||||||
|
|
||||||
|
classID: Components.ID("{9dbfa904-0718-11e3-8e77-0721a45514b8}"),
|
||||||
|
|
||||||
|
contractID: "@mozilla.org/dom/inter-app-connection;1",
|
||||||
|
|
||||||
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
|
||||||
|
|
||||||
|
__init: function(aKeyword, aPublisher, aSubscriber) {
|
||||||
|
debug("__init: aKeyword: " + aKeyword +
|
||||||
|
" aPublisher: " + aPublisher + " aSubscriber: " + aSubscriber);
|
||||||
|
this.keyword = aKeyword;
|
||||||
|
this.publisher = aPublisher;
|
||||||
|
this.subscriber = aSubscriber;
|
||||||
|
},
|
||||||
|
|
||||||
|
cancel: function() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MozInterAppConnectionRequest implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function InterAppConnectionRequest() {
|
||||||
|
debug("InterAppConnectionRequest()");
|
||||||
|
this.keyword = null;
|
||||||
|
this.port = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
InterAppConnectionRequest.prototype = {
|
||||||
|
classDescription: "MozInterAppConnectionRequest",
|
||||||
|
|
||||||
|
classID: Components.ID("{6a77e9e0-0645-11e3-b90b-73bb7c78e06a}"),
|
||||||
|
|
||||||
|
contractID: "@mozilla.org/dom/inter-app-connection-request;1",
|
||||||
|
|
||||||
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
|
||||||
|
|
||||||
|
__init: function(aKeyword, aPort) {
|
||||||
|
debug("__init: aKeyword: " + aKeyword + " aPort: " + aPort);
|
||||||
|
this.keyword = aKeyword;
|
||||||
|
this.port = aPort;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([InterAppConnection,
|
||||||
|
InterAppConnectionRequest]);
|
|
@ -0,0 +1,51 @@
|
||||||
|
/* 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 { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
|
function debug(aMsg) {
|
||||||
|
// dump("-- InterAppMessagePort: " + Date.now() + ": " + aMsg + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
function InterAppMessagePort() {
|
||||||
|
debug("InterAppMessagePort()");
|
||||||
|
};
|
||||||
|
|
||||||
|
InterAppMessagePort.prototype = {
|
||||||
|
classDescription: "MozInterAppMessagePort",
|
||||||
|
|
||||||
|
classID: Components.ID("{c66e0f8c-e3cb-11e2-9e85-43ef6244b884}"),
|
||||||
|
|
||||||
|
contractID: "@mozilla.org/dom/inter-app-message-port;1",
|
||||||
|
|
||||||
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
|
||||||
|
|
||||||
|
postMessage: function(aMessage) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
|
||||||
|
start: function() {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
|
||||||
|
close: function() {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
|
||||||
|
get onmessage() {
|
||||||
|
return this.__DOM_IMPL__.getEventHandler("onmessage");
|
||||||
|
},
|
||||||
|
|
||||||
|
set onmessage(aHandler) {
|
||||||
|
this.__DOM_IMPL__.setEventHandler("onmessage", aHandler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([InterAppMessagePort]);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# 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/.
|
||||||
|
|
||||||
|
LOCAL_INCLUDES += \
|
||||||
|
-I$(topsrcdir)/js/xpconnect/wrappers \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
include $(topsrcdir)/dom/dom-config.mk
|
||||||
|
include $(topsrcdir)/config/rules.mk
|
|
@ -460,6 +460,14 @@ WebappsApplication.prototype = {
|
||||||
return request;
|
return request;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
connect: function(aKeyword, aRules) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
|
||||||
|
getConnections: function() {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
|
||||||
uninit: function() {
|
uninit: function() {
|
||||||
this._onprogress = null;
|
this._onprogress = null;
|
||||||
cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
|
cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
|
||||||
|
|
|
@ -4,9 +4,20 @@
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# 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/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
EXPORTS.mozilla.dom += [
|
||||||
|
'InterAppComm.h',
|
||||||
|
]
|
||||||
|
|
||||||
|
CPP_SOURCES += [
|
||||||
|
'InterAppComm.cpp',
|
||||||
|
]
|
||||||
|
|
||||||
EXTRA_COMPONENTS += [
|
EXTRA_COMPONENTS += [
|
||||||
'AppsService.js',
|
'AppsService.js',
|
||||||
'AppsService.manifest',
|
'AppsService.manifest',
|
||||||
|
'InterAppComm.manifest',
|
||||||
|
'InterAppConnection.js',
|
||||||
|
'InterAppMessagePort.js',
|
||||||
'Webapps.js',
|
'Webapps.js',
|
||||||
'Webapps.manifest',
|
'Webapps.manifest',
|
||||||
]
|
]
|
||||||
|
@ -25,3 +36,8 @@ EXTRA_PP_JS_MODULES += [
|
||||||
'Webapps.jsm',
|
'Webapps.jsm',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
FAIL_ON_WARNINGS = True
|
||||||
|
|
||||||
|
LIBXUL_LIBRARY = True
|
||||||
|
|
||||||
|
LIBRARY_NAME = 'dom_apps_s'
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
interface nsIDOMDOMRequest;
|
interface nsIDOMDOMRequest;
|
||||||
|
|
||||||
[scriptable, uuid(8bdeef38-e9cd-46f8-b8de-ed9e6b4d01ea)]
|
[scriptable, uuid(4081390c-08cf-11e3-9200-b3c0a8744b20)]
|
||||||
interface mozIDOMApplication : nsISupports
|
interface mozIDOMApplication : nsISupports
|
||||||
{
|
{
|
||||||
readonly attribute jsval manifest;
|
readonly attribute jsval manifest;
|
||||||
|
@ -90,6 +90,16 @@ interface mozIDOMApplication : nsISupports
|
||||||
* onsuccess will be called once data is actually cleared.
|
* onsuccess will be called once data is actually cleared.
|
||||||
*/
|
*/
|
||||||
nsIDOMDOMRequest clearBrowserData();
|
nsIDOMDOMRequest clearBrowserData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inter-App Communication APIs.
|
||||||
|
*
|
||||||
|
* https://wiki.mozilla.org/WebAPI/Inter_App_Communication_Alt_proposal
|
||||||
|
*/
|
||||||
|
nsISupports connect(in DOMString keyword,
|
||||||
|
[optional] in jsval rules); // nsISupports is a Promise.
|
||||||
|
|
||||||
|
nsISupports getConnections(); // nsISupports is a Promise.
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(cf742022-5ba3-11e2-868f-03310341b006)]
|
[scriptable, uuid(cf742022-5ba3-11e2-868f-03310341b006)]
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
[HeaderFile="mozilla/dom/InterAppComm.h",
|
||||||
|
Func="mozilla::dom::InterAppComm::EnabledForScope",
|
||||||
|
Constructor(DOMString keyword, DOMString publisher, DOMString subsriber),
|
||||||
|
JSImplementation="@mozilla.org/dom/inter-app-connection;1"]
|
||||||
|
interface MozInterAppConnection {
|
||||||
|
readonly attribute DOMString keyword;
|
||||||
|
readonly attribute DOMString publisher;
|
||||||
|
readonly attribute DOMString subscriber;
|
||||||
|
|
||||||
|
void cancel();
|
||||||
|
};
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
[HeaderFile="mozilla/dom/InterAppComm.h",
|
||||||
|
Func="mozilla::dom::InterAppComm::EnabledForScope",
|
||||||
|
Constructor(DOMString keyword, MozInterAppMessagePort port),
|
||||||
|
JSImplementation="@mozilla.org/dom/inter-app-connection-request;1"]
|
||||||
|
interface MozInterAppConnectionRequest {
|
||||||
|
readonly attribute DOMString keyword;
|
||||||
|
|
||||||
|
readonly attribute MozInterAppMessagePort port;
|
||||||
|
};
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
// TODO Bug 907060 Per off-line discussion, after the MessagePort is done
|
||||||
|
// at Bug 643325, we will start to refactorize the common logic of both
|
||||||
|
// Inter-App Communication and Shared Worker. For now, we hope to design an
|
||||||
|
// MozInterAppMessagePort to meet the timeline, which still follows exactly
|
||||||
|
// the same interface and semantic as the MessagePort is. In the future,
|
||||||
|
// we can then align it back to MessagePort with backward compatibility.
|
||||||
|
|
||||||
|
[HeaderFile="mozilla/dom/InterAppComm.h",
|
||||||
|
Func="mozilla::dom::InterAppComm::EnabledForScope",
|
||||||
|
JSImplementation="@mozilla.org/dom/inter-app-message-port;1"]
|
||||||
|
interface MozInterAppMessagePort : EventTarget {
|
||||||
|
void postMessage(any message);
|
||||||
|
|
||||||
|
void start();
|
||||||
|
|
||||||
|
void close();
|
||||||
|
|
||||||
|
attribute EventHandler onmessage;
|
||||||
|
};
|
|
@ -186,6 +186,9 @@ WEBIDL_FILES = [
|
||||||
'ImageData.webidl',
|
'ImageData.webidl',
|
||||||
'ImageDocument.webidl',
|
'ImageDocument.webidl',
|
||||||
'InspectorUtils.webidl',
|
'InspectorUtils.webidl',
|
||||||
|
'InterAppConnection.webidl',
|
||||||
|
'InterAppConnectionRequest.webidl',
|
||||||
|
'InterAppMessagePort.webidl',
|
||||||
'KeyboardEvent.webidl',
|
'KeyboardEvent.webidl',
|
||||||
'KeyEvent.webidl',
|
'KeyEvent.webidl',
|
||||||
'LinkStyle.webidl',
|
'LinkStyle.webidl',
|
||||||
|
|
|
@ -38,6 +38,7 @@ SHARED_LIBRARY_LIBS = \
|
||||||
$(DEPTH)/content/xul/document/src/$(LIB_PREFIX)gkconxuldoc_s.$(LIB_SUFFIX) \
|
$(DEPTH)/content/xul/document/src/$(LIB_PREFIX)gkconxuldoc_s.$(LIB_SUFFIX) \
|
||||||
$(DEPTH)/view/src/$(LIB_PREFIX)gkview_s.$(LIB_SUFFIX) \
|
$(DEPTH)/view/src/$(LIB_PREFIX)gkview_s.$(LIB_SUFFIX) \
|
||||||
$(DEPTH)/dom/activities/src/$(LIB_PREFIX)dom_activities_s.$(LIB_SUFFIX) \
|
$(DEPTH)/dom/activities/src/$(LIB_PREFIX)dom_activities_s.$(LIB_SUFFIX) \
|
||||||
|
$(DEPTH)/dom/apps/src/$(LIB_PREFIX)dom_apps_s.$(LIB_SUFFIX) \
|
||||||
$(DEPTH)/dom/base/$(LIB_PREFIX)jsdombase_s.$(LIB_SUFFIX) \
|
$(DEPTH)/dom/base/$(LIB_PREFIX)jsdombase_s.$(LIB_SUFFIX) \
|
||||||
$(DEPTH)/dom/battery/$(LIB_PREFIX)dom_battery_s.$(LIB_SUFFIX) \
|
$(DEPTH)/dom/battery/$(LIB_PREFIX)dom_battery_s.$(LIB_SUFFIX) \
|
||||||
$(DEPTH)/dom/alarm/$(LIB_PREFIX)domalarm_s.$(LIB_SUFFIX) \
|
$(DEPTH)/dom/alarm/$(LIB_PREFIX)domalarm_s.$(LIB_SUFFIX) \
|
||||||
|
|
|
@ -4395,3 +4395,6 @@ pref("dom.forms.inputmode", false);
|
||||||
#else
|
#else
|
||||||
pref("dom.forms.inputmode", true);
|
pref("dom.forms.inputmode", true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// DOM Inter-App Communication API.
|
||||||
|
pref("dom.inter-app-communication-api.enabled", false);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче