Bug 760102 - Authorize web applications to use fullscreen by default. r=cpearce

This commit is contained in:
Vivien Nicolas 2012-06-28 20:54:37 +12:00
parent 407767521d
commit 714578e283
4 changed files with 14 additions and 7 deletions

View File

@ -8991,6 +8991,7 @@ nsDocument::RequestFullScreen(Element* aElement, bool aWasCallerChrome)
// to the document's principal's host, if it has one.
if (!mIsApprovedForFullscreen) {
mIsApprovedForFullscreen =
GetWindow()->IsPartOfApp() ||
nsContentUtils::IsSitePermAllow(NodePrincipal(), "fullscreen");
}

View File

@ -4762,6 +4762,11 @@ nsGenericElement::MozRequestPointerLock()
static const char*
GetFullScreenError(nsIDocument* aDoc)
{
nsCOMPtr<nsPIDOMWindow> win = aDoc->GetWindow();
if (win && win->IsPartOfApp()) {
return nsnull;
}
if (!nsContentUtils::IsRequestFullScreenAllowed()) {
return "FullScreenDeniedNotInputDriven";
}

View File

@ -340,6 +340,7 @@ public:
virtual NS_HIDDEN_(bool) DispatchCustomEvent(const char *aEventName);
virtual NS_HIDDEN_(void) RefreshCompartmentPrincipal();
virtual NS_HIDDEN_(nsresult) SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust);
virtual NS_HIDDEN_(bool) IsPartOfApp();
// nsIDOMStorageIndexedDB
NS_DECL_NSIDOMSTORAGEINDEXEDDB
@ -545,13 +546,6 @@ public:
void AddEventTargetObject(nsDOMEventTargetHelper* aObject);
void RemoveEventTargetObject(nsDOMEventTargetHelper* aObject);
/**
* Returns if the window is part of an application.
* It will check for the window app state and its parents until a window has
* an app state different from |TriState_Unknown|.
*/
bool IsPartOfApp();
protected:
friend class HashchangeCallback;
friend class nsBarProp;

View File

@ -592,6 +592,13 @@ public:
*/
virtual void RefreshCompartmentPrincipal() = 0;
/**
* Returns if the window is part of an application.
* It will check for the window app state and its parents until a window has
* an app state different from |TriState_Unknown|.
*/
virtual bool IsPartOfApp() = 0;
protected:
// The nsPIDOMWindow constructor. The aOuterWindow argument should
// be null if and only if the created window itself is an outer