Bug 1943650 - Command-line --help output misformatted after --dbus-service. r=emilio
[gecko.git] / toolkit / components / browser / nsWebBrowser.h
blob6b032f2a57d892416c2a0dddf1ecb216482b07dd
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/. */
7 #ifndef nsWebBrowser_h__
8 #define nsWebBrowser_h__
10 // Local Includes
11 #include "nsDocShellTreeOwner.h"
13 // Core Includes
14 #include "nsCOMPtr.h"
15 #include "nsCycleCollectionParticipant.h"
17 // Interfaces needed
18 #include "nsIBaseWindow.h"
19 #include "nsIDocShell.h"
20 #include "nsIDocShellTreeItem.h"
21 #include "nsIInterfaceRequestor.h"
22 #include "nsIInterfaceRequestorUtils.h"
23 #include "nsIWidget.h"
24 #include "nsIWebProgress.h"
25 #include "nsIWebBrowser.h"
26 #include "nsIWebNavigation.h"
27 #include "nsIWebBrowserPersist.h"
28 #include "nsIWindowWatcher.h"
29 #include "nsIPrintSettings.h"
30 #include "nsIWidgetListener.h"
32 #include "mozilla/BasePrincipal.h"
33 #include "nsTArray.h"
34 #include "nsIWeakReferenceUtils.h"
36 class nsWebBrowserInitInfo {
37 public:
38 // nsIBaseWindow Stuff
39 int32_t x;
40 int32_t y;
41 int32_t cx;
42 int32_t cy;
43 bool visible;
44 nsString name;
47 // {cda5863a-aa9c-411e-be49-ea0d525ab4b5} -
48 #define NS_WEBBROWSER_CID \
49 { \
50 0xcda5863a, 0xaa9c, 0x411e, { \
51 0xbe, 0x49, 0xea, 0x0d, 0x52, 0x5a, 0xb4, 0xb5 \
52 } \
55 class mozIDOMWindowProxy;
56 class nsDocShell;
58 namespace mozilla {
59 namespace dom {
60 class WindowGlobalChild;
61 } // namespace dom
62 } // namespace mozilla
64 class nsWebBrowser final : public nsIWebBrowser,
65 public nsIWebNavigation,
66 public nsIDocShellTreeItem,
67 public nsIBaseWindow,
68 public nsIInterfaceRequestor,
69 public nsIWebBrowserPersist,
70 public nsIWebProgressListener,
71 public nsSupportsWeakReference {
72 friend class nsDocShellTreeOwner;
74 public:
75 // The implementation of non-refcounted nsIWidgetListener, which would hold a
76 // strong reference on stack before calling nsWebBrowser's
77 // MOZ_CAN_RUN_SCRIPT methods.
78 class WidgetListenerDelegate : public nsIWidgetListener {
79 public:
80 explicit WidgetListenerDelegate(nsWebBrowser* aWebBrowser)
81 : mWebBrowser(aWebBrowser) {}
82 MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void WindowActivated() override;
83 MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void WindowDeactivated() override;
84 MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual bool PaintWindow(
85 nsIWidget* aWidget, mozilla::LayoutDeviceIntRegion aRegion) override;
87 private:
88 // The lifetime of WidgetListenerDelegate is bound to nsWebBrowser so we
89 // just use raw pointer here.
90 nsWebBrowser* mWebBrowser;
93 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
94 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsWebBrowser, nsIWebBrowser)
96 NS_DECL_NSIBASEWINDOW
97 NS_DECL_NSIDOCSHELLTREEITEM
98 NS_DECL_NSIINTERFACEREQUESTOR
99 NS_DECL_NSIWEBBROWSER
100 NS_DECL_NSIWEBNAVIGATION
101 NS_DECL_NSIWEBBROWSERPERSIST
102 NS_DECL_NSICANCELABLE
103 NS_DECL_NSIWEBPROGRESSLISTENER
105 void SetAllowDNSPrefetch(bool aAllowPrefetch);
106 // TODO: Convert FocusDeactivate() to MOZ_CAN_RUN_SCRIPT
107 MOZ_CAN_RUN_SCRIPT_BOUNDARY void FocusActivate(uint64_t aActionId);
108 // TODO: Convert FocusDeactivate() to MOZ_CAN_RUN_SCRIPT
109 MOZ_CAN_RUN_SCRIPT_BOUNDARY void FocusDeactivate(uint64_t aActionId);
110 void SetWillChangeProcess();
112 static already_AddRefed<nsWebBrowser> Create(
113 nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget,
114 mozilla::dom::BrowsingContext* aBrowsingContext,
115 mozilla::dom::WindowGlobalChild* aInitialWindowChild);
117 protected:
118 virtual ~nsWebBrowser();
119 void InternalDestroy();
121 void SetDocShell(nsDocShell* aDocShell);
122 void EnsureDocShellTreeOwner();
124 nsIWidget* EnsureWidget();
126 // nsIWidgetListener methods for WidgetListenerDelegate.
127 MOZ_CAN_RUN_SCRIPT void WindowActivated();
128 MOZ_CAN_RUN_SCRIPT void WindowDeactivated();
129 MOZ_CAN_RUN_SCRIPT bool PaintWindow(nsIWidget* aWidget,
130 mozilla::LayoutDeviceIntRegion aRegion);
132 explicit nsWebBrowser(int aItemType);
134 protected:
135 RefPtr<nsDocShellTreeOwner> mDocShellTreeOwner;
136 RefPtr<nsDocShell> mDocShell;
137 mozilla::OriginAttributes mOriginAttributes;
139 nsCOMPtr<nsIWidget> mInternalWidget;
140 nsCOMPtr<nsIWindowWatcher> mWWatch;
141 const uint32_t mContentType;
142 bool mShouldEnableHistory;
143 bool mWillChangeProcess;
144 nsIWebProgressListener* mProgressListener;
146 nsCOMPtr<nsIPrintSettings> mPrintSettings;
148 WidgetListenerDelegate mWidgetListenerDelegate;
150 // cached background color
151 nscolor mBackgroundColor;
153 // persistence object
154 nsCOMPtr<nsIWebBrowserPersist> mPersist;
155 uint32_t mPersistCurrentState;
156 nsresult mPersistResult;
157 uint32_t mPersistFlags;
159 // Weak Reference interfaces...
160 nsIWidget* mParentWidget;
163 #endif /* nsWebBrowser_h__ */