Bug 1317606. Get rid of LegacyIsCallerChromeOrNativeCode in barprop code. r=bkelly

This commit is contained in:
Boris Zbarsky 2016-11-15 12:46:32 -05:00
parent 784a52fd02
commit 192d20fb6e
3 changed files with 40 additions and 28 deletions

View File

@ -116,13 +116,13 @@ MenubarProp::~MenubarProp()
} }
bool bool
MenubarProp::GetVisible(ErrorResult& aRv) MenubarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
{ {
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_MENUBAR, aRv); return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
} }
void void
MenubarProp::SetVisible(bool aVisible, ErrorResult& aRv) MenubarProp::SetVisible(bool aVisible, CallerType aCallerType, ErrorResult& aRv)
{ {
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_MENUBAR, aRv); BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
} }
@ -141,13 +141,13 @@ ToolbarProp::~ToolbarProp()
} }
bool bool
ToolbarProp::GetVisible(ErrorResult& aRv) ToolbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
{ {
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_TOOLBAR, aRv); return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_TOOLBAR, aRv);
} }
void void
ToolbarProp::SetVisible(bool aVisible, ErrorResult& aRv) ToolbarProp::SetVisible(bool aVisible, CallerType aCallerType, ErrorResult& aRv)
{ {
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_TOOLBAR, BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_TOOLBAR,
aRv); aRv);
@ -167,14 +167,15 @@ LocationbarProp::~LocationbarProp()
} }
bool bool
LocationbarProp::GetVisible(ErrorResult& aRv) LocationbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
{ {
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_LOCATIONBAR, return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_LOCATIONBAR,
aRv); aRv);
} }
void void
LocationbarProp::SetVisible(bool aVisible, ErrorResult& aRv) LocationbarProp::SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv)
{ {
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_LOCATIONBAR, BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_LOCATIONBAR,
aRv); aRv);
@ -194,14 +195,15 @@ PersonalbarProp::~PersonalbarProp()
} }
bool bool
PersonalbarProp::GetVisible(ErrorResult& aRv) PersonalbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
{ {
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR, return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
aRv); aRv);
} }
void void
PersonalbarProp::SetVisible(bool aVisible, ErrorResult& aRv) PersonalbarProp::SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv)
{ {
BarProp::SetVisibleByFlag(aVisible, BarProp::SetVisibleByFlag(aVisible,
nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR, nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
@ -222,13 +224,14 @@ StatusbarProp::~StatusbarProp()
} }
bool bool
StatusbarProp::GetVisible(ErrorResult& aRv) StatusbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
{ {
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_STATUSBAR, aRv); return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
} }
void void
StatusbarProp::SetVisible(bool aVisible, ErrorResult& aRv) StatusbarProp::SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv)
{ {
return BarProp::SetVisibleByFlag(aVisible, return BarProp::SetVisibleByFlag(aVisible,
nsIWebBrowserChrome::CHROME_STATUSBAR, aRv); nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
@ -248,7 +251,7 @@ ScrollbarsProp::~ScrollbarsProp()
} }
bool bool
ScrollbarsProp::GetVisible(ErrorResult& aRv) ScrollbarsProp::GetVisible(CallerType aCallerType, ErrorResult& aRv)
{ {
if (!mDOMWindow) { if (!mDOMWindow) {
return true; return true;
@ -274,9 +277,10 @@ ScrollbarsProp::GetVisible(ErrorResult& aRv)
} }
void void
ScrollbarsProp::SetVisible(bool aVisible, ErrorResult& aRv) ScrollbarsProp::SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv)
{ {
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) { if (aCallerType != CallerType::System) {
return; return;
} }

View File

@ -17,6 +17,7 @@
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "nsPIDOMWindow.h" #include "nsPIDOMWindow.h"
#include "mozilla/dom/BindingDeclarations.h"
class nsGlobalWindow; class nsGlobalWindow;
class nsIWebBrowserChrome; class nsIWebBrowserChrome;
@ -42,8 +43,9 @@ public:
virtual JSObject* virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
virtual bool GetVisible(ErrorResult& aRv) = 0; virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) = 0;
virtual void SetVisible(bool aVisible, ErrorResult& aRv) = 0; virtual void SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv) = 0;
protected: protected:
virtual ~BarProp(); virtual ~BarProp();
@ -63,8 +65,9 @@ public:
explicit MenubarProp(nsGlobalWindow *aWindow); explicit MenubarProp(nsGlobalWindow *aWindow);
virtual ~MenubarProp(); virtual ~MenubarProp();
virtual bool GetVisible(ErrorResult& aRv) override; virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
virtual void SetVisible(bool aVisible, ErrorResult& aRv) override; virtual void SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv) override;
}; };
// Script "toolbar" object // Script "toolbar" object
@ -74,8 +77,9 @@ public:
explicit ToolbarProp(nsGlobalWindow *aWindow); explicit ToolbarProp(nsGlobalWindow *aWindow);
virtual ~ToolbarProp(); virtual ~ToolbarProp();
virtual bool GetVisible(ErrorResult& aRv) override; virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
virtual void SetVisible(bool aVisible, ErrorResult& aRv) override; virtual void SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv) override;
}; };
// Script "locationbar" object // Script "locationbar" object
@ -85,8 +89,9 @@ public:
explicit LocationbarProp(nsGlobalWindow *aWindow); explicit LocationbarProp(nsGlobalWindow *aWindow);
virtual ~LocationbarProp(); virtual ~LocationbarProp();
virtual bool GetVisible(ErrorResult& aRv) override; virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
virtual void SetVisible(bool aVisible, ErrorResult& aRv) override; virtual void SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv) override;
}; };
// Script "personalbar" object // Script "personalbar" object
@ -96,8 +101,9 @@ public:
explicit PersonalbarProp(nsGlobalWindow *aWindow); explicit PersonalbarProp(nsGlobalWindow *aWindow);
virtual ~PersonalbarProp(); virtual ~PersonalbarProp();
virtual bool GetVisible(ErrorResult& aRv) override; virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
virtual void SetVisible(bool aVisible, ErrorResult& aRv) override; virtual void SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv) override;
}; };
// Script "statusbar" object // Script "statusbar" object
@ -107,8 +113,9 @@ public:
explicit StatusbarProp(nsGlobalWindow *aWindow); explicit StatusbarProp(nsGlobalWindow *aWindow);
virtual ~StatusbarProp(); virtual ~StatusbarProp();
virtual bool GetVisible(ErrorResult& aRv) override; virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
virtual void SetVisible(bool aVisible, ErrorResult& aRv) override; virtual void SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv) override;
}; };
// Script "scrollbars" object // Script "scrollbars" object
@ -118,8 +125,9 @@ public:
explicit ScrollbarsProp(nsGlobalWindow *aWindow); explicit ScrollbarsProp(nsGlobalWindow *aWindow);
virtual ~ScrollbarsProp(); virtual ~ScrollbarsProp();
virtual bool GetVisible(ErrorResult& aRv) override; virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
virtual void SetVisible(bool aVisible, ErrorResult& aRv) override; virtual void SetVisible(bool aVisible, CallerType aCallerType,
ErrorResult& aRv) override;
}; };
} // namespace dom } // namespace dom

View File

@ -6,6 +6,6 @@
interface BarProp interface BarProp
{ {
[Throws] [Throws, NeedsCallerType]
attribute boolean visible; attribute boolean visible;
}; };