Bug 740192 - Screen orientation needs a specific security model for installed web apps. r=jlebar
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 10 May 2012 17:49:34 -0700
changeset 93720 c3b5e70e85e7acfe0bc8543d54343a468936ac4c
parent 93719 9f2edf9a549a1d075f25bb833c24de0fbf60eda0
child 93766 e6a9572b48f753e92aedf9464010ee0f0b55ee46
push id22666
push usermlamouri@mozilla.com
push dateFri, 11 May 2012 00:57:06 +0000
treeherdermozilla-central@c3b5e70e85e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs740192
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 740192 - Screen orientation needs a specific security model for installed web apps. r=jlebar
dom/base/nsScreen.cpp
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -40,16 +40,17 @@
 #include "nsScreen.h"
 #include "nsIDocShell.h"
 #include "nsPresContext.h"
 #include "nsCOMPtr.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsLayoutUtils.h"
 #include "nsDOMEvent.h"
+#include "nsGlobalWindow.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 namespace {
 
 bool
 IsChromeType(nsIDocShell *aDocShell)
@@ -376,21 +377,25 @@ nsScreen::MozLockOrientation(const nsASt
   if (!IsChromeType(GetOwner()->GetDocShell())) {
     nsCOMPtr<nsIDOMDocument> doc;
     GetOwner()->GetDocument(getter_AddRefs(doc));
     if (!doc) {
       *aReturn = false;
       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<nsGlobalWindow*>(GetOwner())->IsPartOfApp()) {
+      bool fullscreen;
+      doc->GetMozFullScreen(&fullscreen);
+      if (!fullscreen) {
+        *aReturn = false;
+        return NS_OK;
+      }
     }
 
     nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetOwner());
     if (!target) {
       *aReturn = false;
       return NS_OK;
     }