Bug 1148188 - part1: defaultShims. r=billm

This commit is contained in:
Gabor Krizsanits 2015-05-07 14:01:43 +02:00
parent bcba77afa1
commit 6d2b1f6962
3 changed files with 42 additions and 1 deletions

View File

@ -131,10 +131,19 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(JSContext* cx,
JSAddonId* addonId = JS::AddonIdOfObject(aGlobal);
if (gInterpositionMap) {
bool isSystem = nsContentUtils::IsSystemPrincipal(principal);
if (InterpositionMap::Ptr p = gInterpositionMap->lookup(addonId)) {
MOZ_RELEASE_ASSERT(nsContentUtils::IsSystemPrincipal(principal));
MOZ_RELEASE_ASSERT(isSystem);
mInterposition = p->value();
}
// We also want multiprocessCompatible add-ons to have a default interposition.
if (!mInterposition && addonId && isSystem) {
bool interpositionEnabled = mozilla::Preferences::GetBool(
"extensions.interposition.enabled", false);
if (interpositionEnabled) {
mInterposition = do_GetService("@mozilla.org/addons/default-addon-shims;1");
}
}
}
}

View File

@ -1,4 +1,6 @@
component {1363d5f0-d95e-11e3-9c1a-0800200c9a66} multiprocessShims.js
contract @mozilla.org/addons/multiprocess-shims;1 {1363d5f0-d95e-11e3-9c1a-0800200c9a66}
component {50bc93ce-602a-4bef-bf3a-61fc749c4caf} defaultShims.js
contract @mozilla.org/addons/default-addon-shims;1 {50bc93ce-602a-4bef-bf3a-61fc749c4caf}
component {dfd07380-6083-11e4-9803-0800200c9a66} remoteTagService.js
contract @mozilla.org/addons/remote-tag-service;1 {dfd07380-6083-11e4-9803-0800200c9a66}

View File

@ -0,0 +1,30 @@
/* 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 Ci = Components.interfaces;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
/**
* Using multiprocessShims is optional, and if an add-on is e10s compatible it should not
* use it. But in some cases we still want to use the interposition service for various
* features so we have a default shim service.
*/
function DefaultInterpositionService() {
}
DefaultInterpositionService.prototype = {
classID: Components.ID("{50bc93ce-602a-4bef-bf3a-61fc749c4caf}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAddonInterposition, Ci.nsISupportsWeakReference]),
interpose: function(addon, target, iid, prop) {
return null;
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DefaultInterpositionService]);