Bug 1317606. Get rid of LegacyIsCallerChromeOrNativeCode in barprop code. r=bkelly
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 15 Nov 2016 12:46:32 -0500
changeset 322775 55ceefe2f5aa83f8bf08ba43be938ad92c2bee22
parent 322774 1780e17c3c7a287d9cc0ce0d97a394647bb1e88b
child 322776 741ff57b2407d7245354ec4688ce9e12e218ba05
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersbkelly
bugs1317606
milestone53.0a1
Bug 1317606. Get rid of LegacyIsCallerChromeOrNativeCode in barprop code. r=bkelly
dom/base/BarProps.cpp
dom/base/BarProps.h
dom/webidl/BarProp.webidl
--- a/dom/base/BarProps.cpp
+++ b/dom/base/BarProps.cpp
@@ -111,23 +111,23 @@ MenubarProp::MenubarProp(nsGlobalWindow 
 {
 }
 
 MenubarProp::~MenubarProp()
 {
 }
 
 bool
-MenubarProp::GetVisible(ErrorResult& aRv)
+MenubarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
 {
   return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
 }
 
 void
-MenubarProp::SetVisible(bool aVisible, ErrorResult& aRv)
+MenubarProp::SetVisible(bool aVisible, CallerType aCallerType, ErrorResult& aRv)
 {
   BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
 }
 
 //
 // ToolbarProp class implementation
 //
 
@@ -136,23 +136,23 @@ ToolbarProp::ToolbarProp(nsGlobalWindow 
 {
 }
 
 ToolbarProp::~ToolbarProp()
 {
 }
 
 bool
-ToolbarProp::GetVisible(ErrorResult& aRv)
+ToolbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
 {
   return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_TOOLBAR, aRv);
 }
 
 void
-ToolbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
+ToolbarProp::SetVisible(bool aVisible, CallerType aCallerType, ErrorResult& aRv)
 {
   BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_TOOLBAR,
                             aRv);
 }
 
 //
 // LocationbarProp class implementation
 //
@@ -162,24 +162,25 @@ LocationbarProp::LocationbarProp(nsGloba
 {
 }
 
 LocationbarProp::~LocationbarProp()
 {
 }
 
 bool
-LocationbarProp::GetVisible(ErrorResult& aRv)
+LocationbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
 {
   return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_LOCATIONBAR,
                                    aRv);
 }
 
 void
-LocationbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
+LocationbarProp::SetVisible(bool aVisible, CallerType aCallerType,
+                            ErrorResult& aRv)
 {
   BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_LOCATIONBAR,
                             aRv);
 }
 
 //
 // PersonalbarProp class implementation
 //
@@ -189,24 +190,25 @@ PersonalbarProp::PersonalbarProp(nsGloba
 {
 }
 
 PersonalbarProp::~PersonalbarProp()
 {
 }
 
 bool
-PersonalbarProp::GetVisible(ErrorResult& aRv)
+PersonalbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
 {
   return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
                                    aRv);
 }
 
 void
-PersonalbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
+PersonalbarProp::SetVisible(bool aVisible, CallerType aCallerType,
+                            ErrorResult& aRv)
 {
   BarProp::SetVisibleByFlag(aVisible,
                             nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
                             aRv);
 }
 
 //
 // StatusbarProp class implementation
@@ -217,23 +219,24 @@ StatusbarProp::StatusbarProp(nsGlobalWin
 {
 }
 
 StatusbarProp::~StatusbarProp()
 {
 }
 
 bool
-StatusbarProp::GetVisible(ErrorResult& aRv)
+StatusbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
 {
   return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
 }
 
 void
-StatusbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
+StatusbarProp::SetVisible(bool aVisible, CallerType aCallerType,
+                          ErrorResult& aRv)
 {
   return BarProp::SetVisibleByFlag(aVisible,
                                    nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
 }
 
 //
 // ScrollbarsProp class implementation
 //
@@ -243,17 +246,17 @@ ScrollbarsProp::ScrollbarsProp(nsGlobalW
 {
 }
 
 ScrollbarsProp::~ScrollbarsProp()
 {
 }
 
 bool
-ScrollbarsProp::GetVisible(ErrorResult& aRv)
+ScrollbarsProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
 {
   if (!mDOMWindow) {
     return true;
   }
 
   nsCOMPtr<nsIScrollable> scroller =
     do_QueryInterface(mDOMWindow->GetDocShell());
 
@@ -269,19 +272,20 @@ ScrollbarsProp::GetVisible(ErrorResult& 
   }
 
   scroller->GetDefaultScrollbarPreferences(
               nsIScrollable::ScrollOrientation_X, &prefValue);
   return prefValue != nsIScrollable::Scrollbar_Never;
 }
 
 void
-ScrollbarsProp::SetVisible(bool aVisible, ErrorResult& aRv)
+ScrollbarsProp::SetVisible(bool aVisible, CallerType aCallerType,
+                           ErrorResult& aRv)
 {
-  if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
+  if (aCallerType != CallerType::System) {
     return;
   }
 
   /* Scrollbars, unlike the other barprops, implement visibility directly
      rather than handing off to the superclass (and from there to the
      chrome window) because scrollbar visibility uniquely applies only
      to the window making the change (arguably. it does now, anyway.)
      and because embedding apps have no interface for implementing this
--- a/dom/base/BarProps.h
+++ b/dom/base/BarProps.h
@@ -12,16 +12,17 @@
 
 #ifndef mozilla_dom_BarProps_h
 #define mozilla_dom_BarProps_h
 
 #include "mozilla/Attributes.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsPIDOMWindow.h"
+#include "mozilla/dom/BindingDeclarations.h"
 
 class nsGlobalWindow;
 class nsIWebBrowserChrome;
 
 namespace mozilla {
 
 class ErrorResult;
 
@@ -37,18 +38,19 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BarProp)
 
   nsPIDOMWindowInner* GetParentObject() const;
 
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
-  virtual bool GetVisible(ErrorResult& aRv) = 0;
-  virtual void SetVisible(bool aVisible, ErrorResult& aRv) = 0;
+  virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) = 0;
+  virtual void SetVisible(bool aVisible, CallerType aCallerType,
+                          ErrorResult& aRv) = 0;
 
 protected:
   virtual ~BarProp();
 
   bool GetVisibleByFlag(uint32_t aChromeFlag, ErrorResult& aRv);
   void SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag, ErrorResult &aRv);
 
   already_AddRefed<nsIWebBrowserChrome> GetBrowserChrome();
@@ -58,72 +60,78 @@ protected:
 
 // Script "menubar" object
 class MenubarProp final : public BarProp
 {
 public:
   explicit MenubarProp(nsGlobalWindow *aWindow);
   virtual ~MenubarProp();
 
-  virtual bool GetVisible(ErrorResult& aRv) override;
-  virtual void SetVisible(bool aVisible, ErrorResult& aRv) override;
+  virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
+  virtual void SetVisible(bool aVisible, CallerType aCallerType,
+                          ErrorResult& aRv) override;
 };
 
 // Script "toolbar" object
 class ToolbarProp final : public BarProp
 {
 public:
   explicit ToolbarProp(nsGlobalWindow *aWindow);
   virtual ~ToolbarProp();
 
-  virtual bool GetVisible(ErrorResult& aRv) override;
-  virtual void SetVisible(bool aVisible, ErrorResult& aRv) override;
+  virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
+  virtual void SetVisible(bool aVisible, CallerType aCallerType,
+                          ErrorResult& aRv) override;
 };
 
 // Script "locationbar" object
 class LocationbarProp final : public BarProp
 {
 public:
   explicit LocationbarProp(nsGlobalWindow *aWindow);
   virtual ~LocationbarProp();
 
-  virtual bool GetVisible(ErrorResult& aRv) override;
-  virtual void SetVisible(bool aVisible, ErrorResult& aRv) override;
+  virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
+  virtual void SetVisible(bool aVisible, CallerType aCallerType,
+                          ErrorResult& aRv) override;
 };
 
 // Script "personalbar" object
 class PersonalbarProp final : public BarProp
 {
 public:
   explicit PersonalbarProp(nsGlobalWindow *aWindow);
   virtual ~PersonalbarProp();
 
-  virtual bool GetVisible(ErrorResult& aRv) override;
-  virtual void SetVisible(bool aVisible, ErrorResult& aRv) override;
+  virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
+  virtual void SetVisible(bool aVisible, CallerType aCallerType,
+                          ErrorResult& aRv) override;
 };
 
 // Script "statusbar" object
 class StatusbarProp final : public BarProp
 {
 public:
   explicit StatusbarProp(nsGlobalWindow *aWindow);
   virtual ~StatusbarProp();
 
-  virtual bool GetVisible(ErrorResult& aRv) override;
-  virtual void SetVisible(bool aVisible, ErrorResult& aRv) override;
+  virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
+  virtual void SetVisible(bool aVisible, CallerType aCallerType,
+                          ErrorResult& aRv) override;
 };
 
 // Script "scrollbars" object
 class ScrollbarsProp final : public BarProp
 {
 public:
   explicit ScrollbarsProp(nsGlobalWindow *aWindow);
   virtual ~ScrollbarsProp();
 
-  virtual bool GetVisible(ErrorResult& aRv) override;
-  virtual void SetVisible(bool aVisible, ErrorResult& aRv) override;
+  virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
+  virtual void SetVisible(bool aVisible, CallerType aCallerType,
+                          ErrorResult& aRv) override;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_BarProps_h */
 
--- a/dom/webidl/BarProp.webidl
+++ b/dom/webidl/BarProp.webidl
@@ -1,11 +1,11 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 interface BarProp
 {
-  [Throws]
+  [Throws, NeedsCallerType]
            attribute boolean visible;
 };