From bbecbc0081f573559233872e9657698dd1321b23 Mon Sep 17 00:00:00 2001 From: Mounir Lamouri Date: Thu, 10 May 2012 17:49:34 -0700 Subject: [PATCH] Bug 740192 - Screen orientation needs a specific security model for installed web apps. r=jlebar --- dom/base/nsScreen.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/dom/base/nsScreen.cpp b/dom/base/nsScreen.cpp index 6ff525ef0ee3..4512cbffc03a 100644 --- a/dom/base/nsScreen.cpp +++ b/dom/base/nsScreen.cpp @@ -45,6 +45,7 @@ #include "nsIDocShellTreeItem.h" #include "nsLayoutUtils.h" #include "nsDOMEvent.h" +#include "nsGlobalWindow.h" using namespace mozilla; using namespace mozilla::dom; @@ -381,11 +382,15 @@ nsScreen::MozLockOrientation(const nsAString& aOrientation, bool* aReturn) return NS_OK; } - bool fullscreen; - doc->GetMozFullScreen(&fullscreen); - if (!fullscreen) { - *aReturn = false; - return NS_OK; + // Apps and frames contained in apps can lock orientation. + // But non-apps can lock orientation only if they're fullscreen. + if (!static_cast(GetOwner())->IsPartOfApp()) { + bool fullscreen; + doc->GetMozFullScreen(&fullscreen); + if (!fullscreen) { + *aReturn = false; + return NS_OK; + } } nsCOMPtr target = do_QueryInterface(GetOwner());