2 * Copyright (C) 2007 Ryan Leavengood <leavengood@gmail.com>
3 * Copyright (C) 2009 Maxime Simon <simon.maxime@gmail.com>
4 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
5 * Copyright 2013-2014 Haiku, Inc. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef BROWSER_WINDOW_H
29 #define BROWSER_WINDOW_H
32 #include "WebWindow.h"
33 #include <Messenger.h>
53 class SettingsMessage
;
61 using BPrivate::BIconButton
;
64 INTERFACE_ELEMENT_MENU
= 1 << 0,
65 INTERFACE_ELEMENT_TABS
= 1 << 1,
66 INTERFACE_ELEMENT_NAVIGATION
= 1 << 2,
67 INTERFACE_ELEMENT_STATUS
= 1 << 3,
69 INTERFACE_ELEMENT_ALL
= 0xffff
82 WINDOW_OPENED
= 'wndo',
83 WINDOW_CLOSED
= 'wndc',
84 SHOW_DOWNLOAD_WINDOW
= 'sdwd',
85 SHOW_SETTINGS_WINDOW
= 'sswd',
86 SHOW_CONSOLE_WINDOW
= 'scwd',
87 SHOW_COOKIE_WINDOW
= 'skwd'
90 #define INTEGRATE_MENU_INTO_TAB_BAR 0
93 class BrowserWindow
: public BWebWindow
{
95 BrowserWindow(BRect frame
,
96 SettingsMessage
* appSettings
,
99 uint32 interfaceElements
100 = INTERFACE_ELEMENT_ALL
,
101 BWebView
* webView
= NULL
);
102 virtual ~BrowserWindow();
104 virtual void DispatchMessage(BMessage
* message
,
106 virtual void MessageReceived(BMessage
* message
);
107 virtual status_t
Archive(BMessage
* archive
, bool deep
=true) const;
108 virtual bool QuitRequested();
109 virtual void MenusBeginning();
110 virtual void MenusEnded();
112 virtual void ScreenChanged(BRect screenSize
,
114 virtual void WorkspacesChanged(uint32 oldWorkspaces
,
115 uint32 newWorkspaces
);
117 virtual void SetCurrentWebView(BWebView
* view
);
119 bool IsBlankTab() const;
120 void CreateNewTab(const BString
& url
, bool select
,
121 BWebView
* webView
= 0);
123 BRect
WindowFrame() const;
125 void ToggleFullscreen();
128 // WebPage notification API implementations
129 virtual void NavigationRequested(const BString
& url
,
131 virtual void NewWindowRequested(const BString
& url
,
133 virtual void CloseWindowRequested(BWebView
* view
);
134 virtual void NewPageCreated(BWebView
* view
,
135 BRect windowFrame
, bool modalDialog
,
136 bool resizable
, bool activate
);
137 virtual void LoadNegotiating(const BString
& url
,
139 virtual void LoadCommitted(const BString
& url
,
141 virtual void LoadProgress(float progress
, BWebView
* view
);
142 virtual void LoadFailed(const BString
& url
, BWebView
* view
);
143 virtual void LoadFinished(const BString
& url
,
145 virtual void MainDocumentError(const BString
& failingURL
,
146 const BString
& localizedDescription
,
148 virtual void TitleChanged(const BString
& title
,
150 virtual void IconReceived(const BBitmap
* icon
,
152 virtual void ResizeRequested(float width
, float height
,
154 virtual void SetToolBarsVisible(bool flag
, BWebView
* view
);
155 virtual void SetStatusBarVisible(bool flag
, BWebView
* view
);
156 virtual void SetMenuBarVisible(bool flag
, BWebView
* view
);
157 virtual void SetResizable(bool flag
, BWebView
* view
);
158 virtual void StatusChanged(const BString
& status
,
160 virtual void NavigationCapabilitiesChanged(
161 bool canGoBackward
, bool canGoForward
,
162 bool canStop
, BWebView
* view
);
163 virtual void UpdateGlobalHistory(const BString
& url
);
164 virtual bool AuthenticationChallenge(BString message
,
165 BString
& inOutUser
, BString
& inOutPassword
,
166 bool& inOutRememberCredentials
,
167 uint32 failureCount
, BWebView
* view
);
170 void _UpdateTitle(const BString
&title
);
171 void _UpdateTabGroupVisibility();
172 bool _TabGroupShouldBeVisible() const;
173 void _ShutdownTab(int32 index
);
174 void _TabChanged(int32 index
);
176 status_t
_BookmarkPath(BPath
& path
) const;
177 void _CreateBookmark();
178 void _ShowBookmarks();
179 bool _CheckBookmarkExists(BDirectory
& directory
,
180 const BString
& fileName
,
181 const BString
& url
) const;
182 bool _ReadURLAttr(BFile
& bookmarkFile
,
184 void _AddBookmarkURLsRecursively(
185 BDirectory
& directory
,
187 uint32
& addedCount
) const;
189 void _SetPageIcon(BWebView
* view
,
190 const BBitmap
* icon
);
192 void _UpdateHistoryMenu();
193 void _UpdateClipboardItems();
195 bool _ShowPage(BWebView
* view
);
197 void _ToggleFullscreen();
198 void _ResizeToScreen();
199 void _SetAutoHideInterfaceInFullscreen(bool doIt
);
200 void _CheckAutoHideInterface();
201 void _ShowInterface(bool show
);
202 void _ShowProgressBar(bool);
203 void _InvokeButtonVisibly(BButton
* button
);
205 BString
_NewTabURL(bool isNewWindow
) const;
207 BString
_EncodeURIComponent(const BString
& search
);
208 void _VisitURL(const BString
& url
);
209 void _VisitSearchEngine(const BString
& search
);
210 inline bool _IsValidDomainChar(char ch
);
211 void _SmartURLHandler(const BString
& url
);
213 void _HandlePageSourceResult(
214 const BMessage
* message
);
216 void _ShowBookmarkBar(bool show
);
220 int32 fHistoryMenuFixedItemCount
;
222 BMenuItem
* fCutMenuItem
;
223 BMenuItem
* fCopyMenuItem
;
224 BMenuItem
* fPasteMenuItem
;
225 BMenuItem
* fFindPreviousMenuItem
;
226 BMenuItem
* fFindNextMenuItem
;
227 BMenuItem
* fZoomTextOnlyMenuItem
;
228 BMenuItem
* fFullscreenItem
;
229 BMenuItem
* fBackMenuItem
;
230 BMenuItem
* fForwardMenuItem
;
232 BIconButton
* fBackButton
;
233 BIconButton
* fForwardButton
;
234 BIconButton
* fStopButton
;
235 BIconButton
* fHomeButton
;
236 URLInputGroup
* fURLInputGroup
;
237 BStringView
* fStatusText
;
238 BStatusBar
* fLoadingProgressBar
;
240 BLayoutItem
* fMenuGroup
;
241 BLayoutItem
* fTabGroup
;
242 BLayoutItem
* fNavigationGroup
;
243 BLayoutItem
* fFindGroup
;
244 BLayoutItem
* fStatusGroup
;
245 BLayoutItem
* fToggleFullscreenButton
;
247 BTextControl
* fFindTextControl
;
248 BButton
* fFindPreviousButton
;
249 BButton
* fFindNextButton
;
250 BButton
* fFindCloseButton
;
251 BCheckBox
* fFindCaseSensitiveCheckBox
;
252 TabManager
* fTabManager
;
255 bool fInterfaceVisible
;
257 BRect fNonFullscreenWindowFrame
;
258 BMessageRunner
* fPulseRunner
;
259 uint32 fVisibleInterfaceElements
;
260 bigtime_t fLastMouseMovedTime
;
261 BPoint fLastMousePos
;
263 BUrlContext
* fContext
;
266 SettingsMessage
* fAppSettings
;
268 bool fShowTabsIfSinglePageOpen
;
269 bool fAutoHideInterfaceInFullscreenMode
;
270 bool fAutoHidePointer
;
271 uint32 fNewWindowPolicy
;
272 uint32 fNewTabPolicy
;
273 BString fStartPageURL
;
274 BString fSearchPageURL
;
276 BMenuItem
* fBookmarkBarMenuItem
;
277 BookmarkBar
* fBookmarkBar
;
278 BFilePanel
* fSavePanel
;
282 #endif // BROWSER_WINDOW_H