зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1529164 - Remove FakePlugin frame loading; r=nika
Remove the ability for fake plugins to create frames. Fake plugins aren't used anymore, so we can simplify nsFrameLoader a bit by removing some of the related checks. Differential Revision: https://phabricator.services.mozilla.com/D20430 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
367d689ebc
Коммит
342d109220
|
@ -163,13 +163,12 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameLoader)
|
|||
NS_INTERFACE_MAP_END
|
||||
|
||||
nsFrameLoader::nsFrameLoader(Element* aOwner, nsPIDOMWindowOuter* aOpener,
|
||||
bool aNetworkCreated, int32_t aJSPluginID)
|
||||
bool aNetworkCreated)
|
||||
: mOwnerContent(aOwner),
|
||||
mDetachedSubdocFrame(nullptr),
|
||||
mOpener(aOpener),
|
||||
mRemoteBrowser(nullptr),
|
||||
mChildID(0),
|
||||
mJSPluginID(aJSPluginID),
|
||||
mDepthTooGreat(false),
|
||||
mIsTopLevelContent(false),
|
||||
mDestroyCalled(false),
|
||||
|
@ -197,8 +196,7 @@ nsFrameLoader::~nsFrameLoader() {
|
|||
|
||||
nsFrameLoader* nsFrameLoader::Create(Element* aOwner,
|
||||
nsPIDOMWindowOuter* aOpener,
|
||||
bool aNetworkCreated,
|
||||
int32_t aJSPluginId) {
|
||||
bool aNetworkCreated) {
|
||||
NS_ENSURE_TRUE(aOwner, nullptr);
|
||||
Document* doc = aOwner->OwnerDoc();
|
||||
|
||||
|
@ -227,7 +225,7 @@ nsFrameLoader* nsFrameLoader::Create(Element* aOwner,
|
|||
doc->IsStaticDocument()),
|
||||
nullptr);
|
||||
|
||||
return new nsFrameLoader(aOwner, aOpener, aNetworkCreated, aJSPluginId);
|
||||
return new nsFrameLoader(aOwner, aOpener, aNetworkCreated);
|
||||
}
|
||||
|
||||
void nsFrameLoader::LoadFrame(bool aOriginalSrc) {
|
||||
|
@ -318,14 +316,8 @@ nsresult nsFrameLoader::LoadURI(nsIURI* aURI,
|
|||
nsCOMPtr<Document> doc = mOwnerContent->OwnerDoc();
|
||||
|
||||
nsresult rv;
|
||||
// If IsForJSPlugin() returns true then we want to allow the load. We're just
|
||||
// loading the source for the implementation of the JS plugin from a URI
|
||||
// that's under our control. We will already have done the security checks for
|
||||
// loading the plugin content itself in the object/embed loading code.
|
||||
if (!IsForJSPlugin()) {
|
||||
rv = CheckURILoad(aURI, aTriggeringPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = CheckURILoad(aURI, aTriggeringPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mURIToLoad = aURI;
|
||||
mTriggeringPrincipal = aTriggeringPrincipal;
|
||||
|
@ -1784,10 +1776,6 @@ bool nsFrameLoader::OwnerIsIsolatedMozBrowserFrame() {
|
|||
}
|
||||
|
||||
bool nsFrameLoader::ShouldUseRemoteProcess() {
|
||||
if (IsForJSPlugin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PR_GetEnv("MOZ_DISABLE_OOP_TABS") ||
|
||||
Preferences::GetBool("dom.ipc.tabs.disabled", false)) {
|
||||
return false;
|
||||
|
@ -2457,8 +2445,7 @@ bool nsFrameLoader::TryRemoteBrowser() {
|
|||
// that gets loaded, but the load is triggered from the document containing
|
||||
// the plugin.
|
||||
// out of process iframes also get to skip this check.
|
||||
if (!OwnerIsMozBrowserFrame() && !IsForJSPlugin() &&
|
||||
!XRE_IsContentProcess()) {
|
||||
if (!OwnerIsMozBrowserFrame() && !XRE_IsContentProcess()) {
|
||||
if (parentDocShell->ItemType() != nsIDocShellTreeItem::typeChrome) {
|
||||
// Allow about:addon an exception to this rule so it can load remote
|
||||
// extension options pages.
|
||||
|
@ -3173,12 +3160,6 @@ void nsFrameLoader::MaybeUpdatePrimaryTabParent(TabParentChange aChange) {
|
|||
|
||||
nsresult nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
||||
nsIURI* aURI) {
|
||||
if (IsForJSPlugin()) {
|
||||
return aTabContext->SetTabContextForJSPluginFrame(mJSPluginID)
|
||||
? NS_OK
|
||||
: NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
OriginAttributes attrs;
|
||||
attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
|
||||
nsresult rv;
|
||||
|
|
|
@ -97,8 +97,7 @@ class nsFrameLoader final : public nsStubMutationObserver,
|
|||
public:
|
||||
static nsFrameLoader* Create(
|
||||
mozilla::dom::Element* aOwner, nsPIDOMWindowOuter* aOpener,
|
||||
bool aNetworkCreated,
|
||||
int32_t aJSPluginID = nsFakePluginTag::NOT_JSPLUGIN);
|
||||
bool aNetworkCreated);
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAMELOADER_IID)
|
||||
|
||||
|
@ -356,15 +355,13 @@ class nsFrameLoader final : public nsStubMutationObserver,
|
|||
|
||||
private:
|
||||
nsFrameLoader(mozilla::dom::Element* aOwner, nsPIDOMWindowOuter* aOpener,
|
||||
bool aNetworkCreated, int32_t aJSPluginID);
|
||||
bool aNetworkCreated);
|
||||
~nsFrameLoader();
|
||||
|
||||
void SetOwnerContent(mozilla::dom::Element* aContent);
|
||||
|
||||
bool ShouldUseRemoteProcess();
|
||||
|
||||
bool IsForJSPlugin() { return mJSPluginID != nsFakePluginTag::NOT_JSPLUGIN; }
|
||||
|
||||
/**
|
||||
* Is this a frame loader for an isolated <iframe mozbrowser>?
|
||||
*
|
||||
|
@ -459,8 +456,6 @@ class nsFrameLoader final : public nsStubMutationObserver,
|
|||
// This is used when this refers to a remote sub frame
|
||||
RefPtr<mozilla::dom::RemoteFrameChild> mRemoteFrameChild;
|
||||
|
||||
int32_t mJSPluginID;
|
||||
|
||||
// Holds the last known size of the frame.
|
||||
mozilla::ScreenIntSize mLazySize;
|
||||
|
||||
|
|
|
@ -525,8 +525,7 @@ void nsObjectLoadingContent::SetupFrameLoader(int32_t aJSPluginId) {
|
|||
NS_ASSERTION(thisContent, "must be a content");
|
||||
|
||||
mFrameLoader = nsFrameLoader::Create(thisContent->AsElement(),
|
||||
/* aOpener = */ nullptr, mNetworkCreated,
|
||||
aJSPluginId);
|
||||
/* aOpener = */ nullptr, mNetworkCreated);
|
||||
MOZ_ASSERT(mFrameLoader, "nsFrameLoader::Create failed");
|
||||
}
|
||||
|
||||
|
@ -2108,100 +2107,6 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad,
|
|||
rv = AsyncStartPluginInstance();
|
||||
}
|
||||
} break;
|
||||
case eType_FakePlugin: {
|
||||
if (mChannel) {
|
||||
/// XXX(johns): Ideally we'd have some way to pass the channel to the
|
||||
/// fake plugin handler, but for now handlers will need to
|
||||
/// request element.srcURI themselves if they want it
|
||||
LOG(("OBJLC [%p]: Closing unused channel for fake plugin type", this));
|
||||
CloseChannel();
|
||||
}
|
||||
|
||||
/// XXX(johns) Bug FIXME - We need to cleanup the various plugintag
|
||||
/// classes to be more sane and avoid this dance
|
||||
nsCOMPtr<nsIPluginTag> basetag =
|
||||
nsContentUtils::PluginTagForType(mContentType, false);
|
||||
nsCOMPtr<nsIFakePluginTag> tag = do_QueryInterface(basetag);
|
||||
|
||||
uint32_t id;
|
||||
if (NS_FAILED(tag->GetId(&id))) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(id <= PR_INT32_MAX,
|
||||
"Something went wrong, nsPluginHost::RegisterFakePlugin "
|
||||
"shouldn't have "
|
||||
"given out this id.");
|
||||
|
||||
SetupFrameLoader(int32_t(id));
|
||||
if (!mFrameLoader) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
nsString sandboxScript;
|
||||
tag->GetSandboxScript(sandboxScript);
|
||||
if (!sandboxScript.IsEmpty()) {
|
||||
// Create a sandbox.
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JS::Rooted<JSObject*> sandbox(jsapi.cx());
|
||||
rv = nsContentUtils::XPConnect()->CreateSandbox(
|
||||
jsapi.cx(), nsContentUtils::GetSystemPrincipal(),
|
||||
sandbox.address());
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
|
||||
AutoEntryScript aes(sandbox, "JS plugin sandbox code");
|
||||
|
||||
JS::Rooted<JS::Value> element(aes.cx());
|
||||
if (!ToJSValue(aes.cx(), thisContent, &element)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!JS_DefineProperty(aes.cx(), sandbox, "pluginElement", element,
|
||||
JSPROP_ENUMERATE)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> rval(aes.cx());
|
||||
// If the eval'ed code throws we won't load and do fallback instead.
|
||||
rv = nsContentUtils::XPConnect()->EvalInSandboxObject(
|
||||
sandboxScript, nullptr, aes.cx(), sandbox, &rval);
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> handlerURI;
|
||||
if (tag) {
|
||||
tag->GetHandlerURI(getter_AddRefs(handlerURI));
|
||||
}
|
||||
|
||||
if (!handlerURI) {
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
"Selected type is not a proper fake plugin "
|
||||
"handler");
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
nsCString spec;
|
||||
handlerURI->GetSpec(spec);
|
||||
LOG(("OBJLC [%p]: Loading fake plugin handler (%s)", this, spec.get()));
|
||||
|
||||
rv = mFrameLoader->LoadURI(
|
||||
handlerURI, thisContent->AsElement()->NodePrincipal(), false);
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG(("OBJLC [%p]: LoadURI() failed for fake handler", this));
|
||||
mFrameLoader->Destroy();
|
||||
mFrameLoader = nullptr;
|
||||
}
|
||||
} break;
|
||||
case eType_Document: {
|
||||
if (!mChannel) {
|
||||
// We could mFrameLoader->LoadURI(mURI), but UpdateObjectParameters
|
||||
|
@ -2252,6 +2157,9 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad,
|
|||
case eType_Null:
|
||||
// Handled below, silence compiler warnings
|
||||
break;
|
||||
case eType_FakePlugin:
|
||||
// We're now in the process of removing FakePlugin. See bug 1529133.
|
||||
MOZ_CRASH("Shouldn't reach here! This means there's a fakeplugin trying to be loaded.");
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче