Bug 1623562 - Refactor allowPlugins to use BrowsingContext. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D67428

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dan Glastonbury 2020-03-20 04:53:43 +00:00
Родитель 9e5deb3526
Коммит 04870fc980
3 изменённых файлов: 13 добавлений и 13 удалений

Просмотреть файл

@ -32,10 +32,9 @@ uint32_t nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
// an nsSHistory, but not much we can do with that). So if we start using
// it here, we need to be careful to get to the docshell correctly.
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));
bool pluginsAllowed = true;
if (docShell) {
docShell->GetAllowPlugins(&pluginsAllowed);
}
auto* browsingContext = docShell ? docShell->GetBrowsingContext() : nullptr;
bool pluginsAllowed =
browsingContext ? browsingContext->GetAllowPlugins() : true;
return IsTypeSupported(aType, pluginsAllowed);
}

Просмотреть файл

@ -3835,12 +3835,10 @@ void Document::SetContentType(const nsAString& aContentType) {
bool Document::GetAllowPlugins() {
// First, we ask our docshell if it allows plugins.
nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
auto* browsingContext = GetBrowsingContext();
if (docShell) {
bool allowPlugins = false;
docShell->GetAllowPlugins(&allowPlugins);
if (!allowPlugins) {
if (browsingContext) {
if (!browsingContext->GetAllowPlugins()) {
return false;
}

Просмотреть файл

@ -112,8 +112,8 @@ nsEditingSession::MakeWindowEditable(mozIDOMWindowProxy* aWindow,
// disable plugins
nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
mDocShell = do_GetWeakReference(docShell);
mInteractive = aInteractive;
mMakeWholeDocumentEditable = aMakeWholeDocumentEditable;
@ -184,8 +184,7 @@ nsresult nsEditingSession::DisableJSAndPlugins(nsIDocShell& aDocShell) {
// Disable plugins in this document:
mPluginsEnabled = aDocShell.PluginsAllowedInCurrentDoc();
rv = aDocShell.SetAllowPlugins(false);
NS_ENSURE_SUCCESS(rv, rv);
aDocShell.GetBrowsingContext()->SetAllowPlugins(false);
mDisabledJSAndPlugins = true;
@ -210,7 +209,11 @@ nsresult nsEditingSession::RestoreJSAndPlugins(nsPIDOMWindowOuter* aWindow) {
NS_ENSURE_SUCCESS(rv, rv);
// Disable plugins in this document:
return docShell->SetAllowPlugins(mPluginsEnabled);
auto* browsingContext = aWindow->GetBrowsingContext();
NS_ENSURE_TRUE(browsingContext, NS_ERROR_FAILURE);
browsingContext->SetAllowPlugins(mPluginsEnabled);
return NS_OK;
}
/*---------------------------------------------------------------------------