mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 04:03:47 +00:00
Bug 783825 - Fix b2g breakage after bug 553102 [r=cjones]
This commit is contained in:
parent
56d3b4eb73
commit
74c76a1852
@ -16,7 +16,8 @@ Cu.import('resource://gre/modules/SettingsChangeNotifier.jsm');
|
||||
Cu.import('resource://gre/modules/Webapps.jsm');
|
||||
Cu.import('resource://gre/modules/AlarmService.jsm');
|
||||
Cu.import('resource://gre/modules/ActivitiesService.jsm');
|
||||
Cu.import("resource://gre/modules/PermissionPromptHelper.jsm");
|
||||
Cu.import('resource://gre/modules/PermissionPromptHelper.jsm');
|
||||
Cu.import('resource://gre/modules/ObjectWrapper.jsm');
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(Services, 'env',
|
||||
'@mozilla.org/process/environment;1',
|
||||
@ -315,7 +316,8 @@ var shell = {
|
||||
},
|
||||
|
||||
sendChromeEvent: function shell_sendChromeEvent(details) {
|
||||
this.sendEvent(getContentWindow(), "mozChromeEvent", details);
|
||||
this.sendEvent(getContentWindow(), "mozChromeEvent",
|
||||
ObjectWrapper.wrap(details, getContentWindow()));
|
||||
},
|
||||
|
||||
receiveMessage: function shell_receiveMessage(message) {
|
||||
@ -379,9 +381,8 @@ Services.obs.addObserver(function onSystemMessage(subject, topic, data) {
|
||||
}, 'system-messages-open-app', false);
|
||||
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
shell.sendEvent(shell.contentBrowser.contentWindow,
|
||||
"mozChromeEvent", { type: "fullscreenoriginchange",
|
||||
fullscreenorigin: aData } );
|
||||
shell.sendChromeEvent({ type: "fullscreenoriginchange",
|
||||
fullscreenorigin: aData });
|
||||
}, "fullscreen-origin-change", false);
|
||||
|
||||
(function Repl() {
|
||||
|
@ -33,13 +33,12 @@ ActivitiesDialog.prototype = {
|
||||
// activity. The front-end should display a UI to pick one.
|
||||
let browser = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let content = browser.getContentWindow();
|
||||
let event = content.document.createEvent("CustomEvent");
|
||||
event.initCustomEvent("mozChromeEvent", true, true, {
|
||||
let detail = {
|
||||
type: "activity-choice",
|
||||
id: id,
|
||||
name: activity.name,
|
||||
choices: choices
|
||||
});
|
||||
};
|
||||
|
||||
// Listen the resulting choice from the front-end. If there is no choice,
|
||||
// let's return -1, which means the user has cancelled the dialog.
|
||||
@ -51,7 +50,7 @@ ActivitiesDialog.prototype = {
|
||||
activity.callback.handleEvent(evt.detail.value ? evt.detail.value : -1);
|
||||
});
|
||||
|
||||
content.dispatchEvent(event);
|
||||
browser.shell.sendChromeEvent(detail);
|
||||
},
|
||||
|
||||
chooseActivity: function ap_chooseActivity(aName, aActivities, aCallback) {
|
||||
|
@ -58,9 +58,7 @@ ContentPermissionPrompt.prototype = {
|
||||
"id": requestId,
|
||||
"url": request.principal.URI.spec
|
||||
};
|
||||
let event = content.document.createEvent("CustomEvent");
|
||||
event.initCustomEvent("mozChromeEvent", true, true, details);
|
||||
content.dispatchEvent(event);
|
||||
browser.shell.sendChromeEvent(details);
|
||||
},
|
||||
|
||||
classID: Components.ID("{8c719f03-afe0-4aac-91ff-6c215895d467}"),
|
||||
|
@ -10,29 +10,12 @@ const Cr = Components.results;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
|
||||
return Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
|
||||
});
|
||||
|
||||
// Makes sure that we expose correctly chrome JS objects to content.
|
||||
function wrapObjectIn(aObject, aCtxt) {
|
||||
let res = Cu.createObjectIn(aCtxt);
|
||||
let propList = { };
|
||||
for (let prop in aObject) {
|
||||
propList[prop] = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (typeof(aObject[prop]) == "object") ? wrapObjectIn(aObject[prop], aCtxt)
|
||||
: aObject[prop]
|
||||
}
|
||||
}
|
||||
Object.defineProperties(res, propList);
|
||||
Cu.makeObjectPropsNormal(res);
|
||||
return res;
|
||||
};
|
||||
|
||||
function convertAppsArray(aApps, aWindow) {
|
||||
let apps = Cu.createArrayIn(aWindow);
|
||||
for (let i = 0; i < aApps.length; i++) {
|
||||
@ -268,7 +251,7 @@ WebappsApplication.prototype = {
|
||||
|
||||
init: function(aWindow, aOrigin, aManifest, aManifestURL, aReceipts, aInstallOrigin, aInstallTime) {
|
||||
this.origin = aOrigin;
|
||||
this.manifest = wrapObjectIn(aManifest, aWindow);
|
||||
this.manifest = ObjectWrapper.wrap(aManifest, aWindow);
|
||||
this.manifestURL = aManifestURL;
|
||||
this.receipts = aReceipts;
|
||||
this.installOrigin = aInstallOrigin;
|
||||
|
@ -31,6 +31,7 @@ EXTRA_JS_MODULES = ConsoleAPIStorage.jsm \
|
||||
EXTRA_JS_MODULES += \
|
||||
DOMRequestHelper.jsm \
|
||||
IndexedDBHelper.jsm \
|
||||
ObjectWrapper.jsm \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
|
42
dom/base/ObjectWrapper.jsm
Normal file
42
dom/base/ObjectWrapper.jsm
Normal file
@ -0,0 +1,42 @@
|
||||
/* 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 Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
const EXPORTED_SYMBOLS = ["ObjectWrapper"];
|
||||
|
||||
// Makes sure that we expose correctly chrome JS objects to content.
|
||||
|
||||
let ObjectWrapper = {
|
||||
wrap: function objWrapper_wrap(aObject, aCtxt) {
|
||||
let res = Cu.createObjectIn(aCtxt);
|
||||
let propList = { };
|
||||
for (let prop in aObject) {
|
||||
let value;
|
||||
if (Array.isArray(aObject[prop])) {
|
||||
value = Cu.createArrayIn(aCtxt);
|
||||
aObject[prop].forEach(function(aObj) {
|
||||
value.push(objWrapper_wrap(aObj, aCtxt));
|
||||
});
|
||||
} else if (typeof(aObject[prop]) == "object") {
|
||||
value = objWrapper_wrap(aObject[prop], aCtxt);
|
||||
} else {
|
||||
value = aObject[prop];
|
||||
}
|
||||
propList[prop] = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: value
|
||||
}
|
||||
}
|
||||
Object.defineProperties(res, propList);
|
||||
Cu.makeObjectPropsNormal(res);
|
||||
return res;
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
|
||||
return Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
@ -63,7 +64,7 @@ SystemMessageManager.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
aHandler.handleMessage(aMessage);
|
||||
aHandler.handleMessage(ObjectWrapper.wrap(aMessage, this._window));
|
||||
},
|
||||
|
||||
mozSetMessageHandler: function sysMessMgr_setMessageHandler(aType, aHandler) {
|
||||
@ -175,6 +176,7 @@ SystemMessageManager.prototype = {
|
||||
let appsService = Cc["@mozilla.org/AppsService;1"]
|
||||
.getService(Ci.nsIAppsService);
|
||||
this._manifest = appsService.getManifestURLByLocalId(principal.appId);
|
||||
this._window = aWindow;
|
||||
},
|
||||
|
||||
classID: Components.ID("{bc076ea0-609b-4d8f-83d7-5af7cbdc3bb2}"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user