mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 759964 - Part 1 - Add allowMedia attribute to nsIDocShell to disable HTML5 media elements. r=bz
This commit is contained in:
parent
32ae6cd6c6
commit
172c89a430
@ -22,6 +22,7 @@
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsError.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -1060,6 +1061,15 @@ nsresult HTMLMediaElement::LoadResource()
|
||||
mChannel = nullptr;
|
||||
}
|
||||
|
||||
// Check if media is allowed for the docshell.
|
||||
nsCOMPtr<nsISupports> container = OwnerDoc()->GetContainer();
|
||||
if (container) {
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
|
||||
if (docShell && !docShell->GetAllowMedia()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_MEDIA,
|
||||
mLoadingSrc,
|
||||
|
@ -753,6 +753,7 @@ nsDocShell::nsDocShell():
|
||||
mAllowJavascript(true),
|
||||
mAllowMetaRedirects(true),
|
||||
mAllowImages(true),
|
||||
mAllowMedia(true),
|
||||
mAllowDNSPrefetch(true),
|
||||
mAllowWindowControl(true),
|
||||
mCreatingDocument(false),
|
||||
@ -2283,6 +2284,18 @@ NS_IMETHODIMP nsDocShell::SetAllowImages(bool aAllowImages)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetAllowMedia(bool * aAllowMedia)
|
||||
{
|
||||
*aAllowMedia = mAllowMedia;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::SetAllowMedia(bool aAllowMedia)
|
||||
{
|
||||
mAllowMedia = aAllowMedia;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetAllowDNSPrefetch(bool * aAllowDNSPrefetch)
|
||||
{
|
||||
*aAllowDNSPrefetch = mAllowDNSPrefetch;
|
||||
@ -2825,6 +2838,7 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
|
||||
{
|
||||
SetAllowImages(value);
|
||||
}
|
||||
SetAllowMedia(parentAsDocShell->GetAllowMedia());
|
||||
if (NS_SUCCEEDED(parentAsDocShell->GetAllowWindowControl(&value)))
|
||||
{
|
||||
SetAllowWindowControl(value);
|
||||
@ -7728,6 +7742,8 @@ nsDocShell::RestoreFromHistory()
|
||||
bool allowImages;
|
||||
childShell->GetAllowImages(&allowImages);
|
||||
|
||||
bool allowMedia = childShell->GetAllowMedia();
|
||||
|
||||
bool allowDNSPrefetch;
|
||||
childShell->GetAllowDNSPrefetch(&allowDNSPrefetch);
|
||||
|
||||
@ -7742,6 +7758,7 @@ nsDocShell::RestoreFromHistory()
|
||||
childShell->SetAllowMetaRedirects(allowRedirects);
|
||||
childShell->SetAllowSubframes(allowSubframes);
|
||||
childShell->SetAllowImages(allowImages);
|
||||
childShell->SetAllowMedia(allowMedia);
|
||||
childShell->SetAllowDNSPrefetch(allowDNSPrefetch);
|
||||
|
||||
rv = childShell->BeginRestore(nullptr, false);
|
||||
|
@ -803,6 +803,7 @@ protected:
|
||||
bool mAllowJavascript;
|
||||
bool mAllowMetaRedirects;
|
||||
bool mAllowImages;
|
||||
bool mAllowMedia;
|
||||
bool mAllowDNSPrefetch;
|
||||
bool mAllowWindowControl;
|
||||
bool mCreatingDocument; // (should be) debugging only
|
||||
|
@ -42,7 +42,7 @@ interface nsIVariant;
|
||||
interface nsIPrivacyTransitionObserver;
|
||||
interface nsIReflowObserver;
|
||||
|
||||
[scriptable, builtinclass, uuid(bb1a1c98-4deb-44ea-b607-aa7a1ad8abae)]
|
||||
[scriptable, builtinclass, uuid(f453d2ee-bac7-46f9-a553-df918f0cc0d0)]
|
||||
interface nsIDocShell : nsIDocShellTreeItem
|
||||
{
|
||||
/**
|
||||
@ -234,6 +234,11 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
*/
|
||||
attribute boolean allowImages;
|
||||
|
||||
/**
|
||||
* Attribute stating whether or not media (audio/video) should be loaded.
|
||||
*/
|
||||
[infallible] attribute boolean allowMedia;
|
||||
|
||||
/**
|
||||
* Attribute that determines whether DNS prefetch is allowed for this subtree
|
||||
* of the docshell tree. Defaults to true. Setting this will make it take
|
||||
|
Loading…
Reference in New Issue
Block a user