BarProps.h (4129B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* BarProps are the collection of little properties of DOM windows whose 8 only property of their own is "visible". They describe the window 9 chrome which can be made visible or not through JavaScript by setting 10 the appropriate property (window.menubar.visible) 11 */ 12 13 #ifndef mozilla_dom_BarProps_h 14 #define mozilla_dom_BarProps_h 15 16 #include "mozilla/dom/BindingDeclarations.h" 17 #include "mozilla/dom/BrowsingContext.h" 18 #include "nsCycleCollectionParticipant.h" 19 #include "nsPIDOMWindow.h" 20 #include "nsWrapperCache.h" 21 22 class nsGlobalWindowInner; 23 class nsIWebBrowserChrome; 24 25 namespace mozilla { 26 27 class ErrorResult; 28 29 namespace dom { 30 31 // Script "BarProp" object 32 class BarProp : public nsISupports, public nsWrapperCache { 33 public: 34 explicit BarProp(nsGlobalWindowInner* aWindow); 35 36 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 37 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(BarProp) 38 39 nsPIDOMWindowInner* GetParentObject() const; 40 41 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final; 42 43 virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) = 0; 44 virtual void SetVisible(bool aVisible, CallerType aCallerType, 45 ErrorResult& aRv) = 0; 46 47 protected: 48 virtual ~BarProp(); 49 50 bool GetVisibleByIsPopup(); 51 bool GetVisibleByFlag(uint32_t aChromeFlag, CallerType aCallerType, 52 ErrorResult& aRv); 53 void SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag, 54 CallerType aCallerType, ErrorResult& aRv); 55 56 already_AddRefed<nsIWebBrowserChrome> GetBrowserChrome(); 57 58 BrowsingContext* GetBrowsingContext(); 59 60 RefPtr<nsGlobalWindowInner> mDOMWindow; 61 }; 62 63 // Script "menubar" object 64 class MenubarProp final : public BarProp { 65 public: 66 explicit MenubarProp(nsGlobalWindowInner* aWindow); 67 virtual ~MenubarProp(); 68 69 bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override; 70 void SetVisible(bool aVisible, CallerType aCallerType, 71 ErrorResult& aRv) override; 72 }; 73 74 // Script "toolbar" object 75 class ToolbarProp final : public BarProp { 76 public: 77 explicit ToolbarProp(nsGlobalWindowInner* aWindow); 78 virtual ~ToolbarProp(); 79 80 bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override; 81 void SetVisible(bool aVisible, CallerType aCallerType, 82 ErrorResult& aRv) override; 83 }; 84 85 // Script "locationbar" object 86 class LocationbarProp final : public BarProp { 87 public: 88 explicit LocationbarProp(nsGlobalWindowInner* aWindow); 89 virtual ~LocationbarProp(); 90 91 bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override; 92 void SetVisible(bool aVisible, CallerType aCallerType, 93 ErrorResult& aRv) override; 94 }; 95 96 // Script "personalbar" object 97 class PersonalbarProp final : public BarProp { 98 public: 99 explicit PersonalbarProp(nsGlobalWindowInner* aWindow); 100 virtual ~PersonalbarProp(); 101 102 bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override; 103 void SetVisible(bool aVisible, CallerType aCallerType, 104 ErrorResult& aRv) override; 105 }; 106 107 // Script "statusbar" object 108 class StatusbarProp final : public BarProp { 109 public: 110 explicit StatusbarProp(nsGlobalWindowInner* aWindow); 111 virtual ~StatusbarProp(); 112 113 bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override; 114 void SetVisible(bool aVisible, CallerType aCallerType, 115 ErrorResult& aRv) override; 116 }; 117 118 // Script "scrollbars" object 119 class ScrollbarsProp final : public BarProp { 120 public: 121 explicit ScrollbarsProp(nsGlobalWindowInner* aWindow); 122 virtual ~ScrollbarsProp(); 123 124 bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override; 125 void SetVisible(bool aVisible, CallerType aCallerType, 126 ErrorResult& aRv) override; 127 }; 128 129 } // namespace dom 130 } // namespace mozilla 131 132 #endif /* mozilla_dom_BarProps_h */