Bug 1621192 - P1: Move allowPlugins to BrowsingContext. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D66167
This commit is contained in:
@@ -241,6 +241,9 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
|
|||||||
|
|
||||||
context->mFields.SetWithoutSyncing<IDX_IsActive>(true);
|
context->mFields.SetWithoutSyncing<IDX_IsActive>(true);
|
||||||
|
|
||||||
|
const bool allowPlugins = inherit ? inherit->GetAllowPlugins() : true;
|
||||||
|
context->mFields.SetWithoutSyncing<IDX_AllowPlugins>(allowPlugins);
|
||||||
|
|
||||||
return context.forget();
|
return context.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1420,13 +1423,7 @@ void BrowsingContext::DidSet(FieldIndex<IDX_UserAgentOverride>) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BrowsingContext::CanSet(FieldIndex<IDX_UserAgentOverride>,
|
bool BrowsingContext::CheckOnlyOwningProcessCanSet(ContentParent* aSource) {
|
||||||
const nsString& aUserAgent,
|
|
||||||
ContentParent* aSource) {
|
|
||||||
if (!IsTop()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aSource) {
|
if (aSource) {
|
||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
|
||||||
@@ -1444,6 +1441,22 @@ bool BrowsingContext::CanSet(FieldIndex<IDX_UserAgentOverride>,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BrowsingContext::CanSet(FieldIndex<IDX_AllowPlugins>,
|
||||||
|
const bool& aAllowPlugins,
|
||||||
|
ContentParent* aSource) {
|
||||||
|
return CheckOnlyOwningProcessCanSet(aSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BrowsingContext::CanSet(FieldIndex<IDX_UserAgentOverride>,
|
||||||
|
const nsString& aUserAgent,
|
||||||
|
ContentParent* aSource) {
|
||||||
|
if (!IsTop()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CheckOnlyOwningProcessCanSet(aSource);
|
||||||
|
}
|
||||||
|
|
||||||
bool BrowsingContext::CheckOnlyEmbedderCanSet(ContentParent* aSource) {
|
bool BrowsingContext::CheckOnlyEmbedderCanSet(ContentParent* aSource) {
|
||||||
if (aSource) {
|
if (aSource) {
|
||||||
// Set by a content process, verify that it's this BC's embedder.
|
// Set by a content process, verify that it's this BC's embedder.
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ class WindowProxyHolder;
|
|||||||
FIELD(InRDMPane, bool) \
|
FIELD(InRDMPane, bool) \
|
||||||
FIELD(Loading, bool) \
|
FIELD(Loading, bool) \
|
||||||
FIELD(AncestorLoading, bool) \
|
FIELD(AncestorLoading, bool) \
|
||||||
|
FIELD(AllowPlugins, bool) \
|
||||||
/* These field are used to store the states of autoplay media request on \
|
/* These field are used to store the states of autoplay media request on \
|
||||||
* GeckoView only, and it would only be modified on the top level browsing \
|
* GeckoView only, and it would only be modified on the top level browsing \
|
||||||
* context. */ \
|
* context. */ \
|
||||||
@@ -645,6 +646,9 @@ class BrowsingContext : public nsISupports, public nsWrapperCache {
|
|||||||
bool CanSet(FieldIndex<IDX_EmbedderElementType>,
|
bool CanSet(FieldIndex<IDX_EmbedderElementType>,
|
||||||
const Maybe<nsString>& aInitiatorType, ContentParent* aSource);
|
const Maybe<nsString>& aInitiatorType, ContentParent* aSource);
|
||||||
|
|
||||||
|
bool CanSet(FieldIndex<IDX_AllowPlugins>, const bool& aAllowPlugins,
|
||||||
|
ContentParent* aSource);
|
||||||
|
|
||||||
template <size_t I, typename T>
|
template <size_t I, typename T>
|
||||||
bool CanSet(FieldIndex<I>, const T&, ContentParent*) {
|
bool CanSet(FieldIndex<I>, const T&, ContentParent*) {
|
||||||
return true;
|
return true;
|
||||||
@@ -653,6 +657,10 @@ class BrowsingContext : public nsISupports, public nsWrapperCache {
|
|||||||
template <size_t I>
|
template <size_t I>
|
||||||
void DidSet(FieldIndex<I>) {}
|
void DidSet(FieldIndex<I>) {}
|
||||||
|
|
||||||
|
// True if the process attemping to set field is the same as the owning
|
||||||
|
// process.
|
||||||
|
bool CheckOnlyOwningProcessCanSet(ContentParent* aSource);
|
||||||
|
|
||||||
// True if the process attempting to set field is the same as the embedder's
|
// True if the process attempting to set field is the same as the embedder's
|
||||||
// process.
|
// process.
|
||||||
bool CheckOnlyEmbedderCanSet(ContentParent* aSource);
|
bool CheckOnlyEmbedderCanSet(ContentParent* aSource);
|
||||||
|
|||||||
@@ -371,7 +371,6 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
|
|||||||
#endif
|
#endif
|
||||||
mCreated(false),
|
mCreated(false),
|
||||||
mAllowSubframes(true),
|
mAllowSubframes(true),
|
||||||
mAllowPlugins(true),
|
|
||||||
mAllowJavascript(true),
|
mAllowJavascript(true),
|
||||||
mAllowMetaRedirects(true),
|
mAllowMetaRedirects(true),
|
||||||
mAllowImages(true),
|
mAllowImages(true),
|
||||||
@@ -1478,13 +1477,13 @@ NS_IMETHODIMP
|
|||||||
nsDocShell::GetAllowPlugins(bool* aAllowPlugins) {
|
nsDocShell::GetAllowPlugins(bool* aAllowPlugins) {
|
||||||
NS_ENSURE_ARG_POINTER(aAllowPlugins);
|
NS_ENSURE_ARG_POINTER(aAllowPlugins);
|
||||||
|
|
||||||
*aAllowPlugins = mAllowPlugins;
|
*aAllowPlugins = mBrowsingContext->GetAllowPlugins();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::SetAllowPlugins(bool aAllowPlugins) {
|
nsDocShell::SetAllowPlugins(bool aAllowPlugins) {
|
||||||
mAllowPlugins = aAllowPlugins;
|
mBrowsingContext->SetAllowPlugins(aAllowPlugins);
|
||||||
// XXX should enable or disable a plugin host
|
// XXX should enable or disable a plugin host
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -2646,10 +2645,6 @@ nsresult nsDocShell::SetDocLoaderParent(nsDocLoader* aParent) {
|
|||||||
nsCOMPtr<nsIDocShell> parentAsDocShell(do_QueryInterface(parent));
|
nsCOMPtr<nsIDocShell> parentAsDocShell(do_QueryInterface(parent));
|
||||||
|
|
||||||
if (parentAsDocShell) {
|
if (parentAsDocShell) {
|
||||||
if (mAllowPlugins &&
|
|
||||||
NS_SUCCEEDED(parentAsDocShell->GetAllowPlugins(&value))) {
|
|
||||||
SetAllowPlugins(value);
|
|
||||||
}
|
|
||||||
if (mAllowJavascript &&
|
if (mAllowJavascript &&
|
||||||
NS_SUCCEEDED(parentAsDocShell->GetAllowJavascript(&value))) {
|
NS_SUCCEEDED(parentAsDocShell->GetAllowJavascript(&value))) {
|
||||||
SetAllowJavascript(value);
|
SetAllowJavascript(value);
|
||||||
@@ -7393,9 +7388,6 @@ nsresult nsDocShell::RestoreFromHistory() {
|
|||||||
|
|
||||||
// Make sure to not clobber the state of the child. Since AddChild
|
// Make sure to not clobber the state of the child. Since AddChild
|
||||||
// always clobbers it, save it off first.
|
// always clobbers it, save it off first.
|
||||||
bool allowPlugins;
|
|
||||||
childShell->GetAllowPlugins(&allowPlugins);
|
|
||||||
|
|
||||||
bool allowJavascript;
|
bool allowJavascript;
|
||||||
childShell->GetAllowJavascript(&allowJavascript);
|
childShell->GetAllowJavascript(&allowJavascript);
|
||||||
|
|
||||||
@@ -7427,7 +7419,6 @@ nsresult nsDocShell::RestoreFromHistory() {
|
|||||||
|
|
||||||
contexts.AppendElement(childShell->GetBrowsingContext());
|
contexts.AppendElement(childShell->GetBrowsingContext());
|
||||||
|
|
||||||
childShell->SetAllowPlugins(allowPlugins);
|
|
||||||
childShell->SetAllowJavascript(allowJavascript);
|
childShell->SetAllowJavascript(allowJavascript);
|
||||||
childShell->SetAllowMetaRedirects(allowRedirects);
|
childShell->SetAllowMetaRedirects(allowRedirects);
|
||||||
childShell->SetAllowSubframes(allowSubframes);
|
childShell->SetAllowSubframes(allowSubframes);
|
||||||
@@ -11391,7 +11382,8 @@ void nsDocShell::SetHistoryEntryAndUpdateBC(const Maybe<nsISHEntry*>& aLSHE,
|
|||||||
// Do not update the BC if the SH pref is off and we are not a parent process
|
// Do not update the BC if the SH pref is off and we are not a parent process
|
||||||
// or if it is discarded
|
// or if it is discarded
|
||||||
if ((!StaticPrefs::fission_sessionHistoryInParent() &&
|
if ((!StaticPrefs::fission_sessionHistoryInParent() &&
|
||||||
XRE_IsContentProcess()) || mBrowsingContext->IsDiscarded()) {
|
XRE_IsContentProcess()) ||
|
||||||
|
mBrowsingContext->IsDiscarded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (XRE_IsParentProcess()) {
|
if (XRE_IsParentProcess()) {
|
||||||
|
|||||||
@@ -1293,7 +1293,6 @@ class nsDocShell final : public nsDocLoader,
|
|||||||
|
|
||||||
bool mCreated : 1;
|
bool mCreated : 1;
|
||||||
bool mAllowSubframes : 1;
|
bool mAllowSubframes : 1;
|
||||||
bool mAllowPlugins : 1;
|
|
||||||
bool mAllowJavascript : 1;
|
bool mAllowJavascript : 1;
|
||||||
bool mAllowMetaRedirects : 1;
|
bool mAllowMetaRedirects : 1;
|
||||||
bool mAllowImages : 1;
|
bool mAllowImages : 1;
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ class ParentProcessDocumentOpenInfo final : public nsDocumentOpenInfo,
|
|||||||
// channel listener so that we forward onto DocumentLoadListener.
|
// channel listener so that we forward onto DocumentLoadListener.
|
||||||
bool TryDefaultContentListener(nsIChannel* aChannel,
|
bool TryDefaultContentListener(nsIChannel* aChannel,
|
||||||
const nsCString& aContentType) {
|
const nsCString& aContentType) {
|
||||||
uint32_t canHandle =
|
uint32_t canHandle = nsWebNavigationInfo::IsTypeSupported(
|
||||||
nsWebNavigationInfo::IsTypeSupported(aContentType, mPluginsAllowed);
|
aContentType, mBrowsingContext->GetAllowPlugins());
|
||||||
if (canHandle != nsIWebNavigationInfo::UNSUPPORTED) {
|
if (canHandle != nsIWebNavigationInfo::UNSUPPORTED) {
|
||||||
m_targetStreamListener = mListener;
|
m_targetStreamListener = mListener;
|
||||||
nsLoadFlags loadFlags = 0;
|
nsLoadFlags loadFlags = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user