blob: d98b7bd6fde767fb7b6fd6516e51aca21df4ae3f [file] [log] [blame]
[email protected]35d06152011-01-10 22:19:421// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]69b04b92010-11-08 22:12:182// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_BROWSER_WINDOW_H_
6#define CHROME_BROWSER_UI_BROWSER_WINDOW_H_
7#pragma once
8
[email protected]09b29342011-06-24 19:18:489#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
[email protected]69b04b92010-11-08 22:12:1810#include "chrome/common/content_settings_types.h"
[email protected]299425b2011-03-02 07:45:2011#include "content/browser/tab_contents/navigation_entry.h"
[email protected]08397d52011-02-05 01:53:3812#include "ui/gfx/native_widget_types.h"
[email protected]588300d2011-04-28 21:06:3513#include "webkit/glue/window_open_disposition.h"
[email protected]69b04b92010-11-08 22:12:1814
15class Browser;
16class BrowserWindowTesting;
17class DownloadShelf;
18class FindBar;
19class GURL;
20class HtmlDialogUIDelegate;
21class LocationBar;
[email protected]fe90ca8e2011-04-08 20:40:4322class Panel;
[email protected]69b04b92010-11-08 22:12:1823class Profile;
24class StatusBubble;
25class TabContents;
[email protected]3c9e1872010-11-18 16:17:4926class TabContentsWrapper;
[email protected]69b04b92010-11-08 22:12:1827class TemplateURL;
[email protected]8e5c89a2011-06-07 18:13:3328class TemplateURLService;
[email protected]69b04b92010-11-08 22:12:1829#if !defined(OS_MACOSX)
30class ToolbarView;
31#endif
32struct NativeWebKeyboardEvent;
33
34namespace gfx {
35class Rect;
36}
37
[email protected]a3b734b2010-11-30 03:17:1138class Extension;
39
[email protected]69b04b92010-11-08 22:12:1840////////////////////////////////////////////////////////////////////////////////
41// BrowserWindow interface
42// An interface implemented by the "view" of the Browser window.
43//
44// NOTE: All getters may return NULL.
45class BrowserWindow {
46 public:
[email protected]ed2f27132011-04-04 17:19:5747 virtual ~BrowserWindow() {}
48
[email protected]69b04b92010-11-08 22:12:1849 // Show the window, or activates it if it's already visible.
50 virtual void Show() = 0;
51
[email protected]d4db6c702011-03-28 21:49:1452 // Show the window, but do not activate it. Does nothing if window
53 // is already visible.
54 virtual void ShowInactive() = 0;
55
[email protected]69b04b92010-11-08 22:12:1856 // Sets the window's size and position to the specified values.
57 virtual void SetBounds(const gfx::Rect& bounds) = 0;
58
59 // Closes the frame as soon as possible. If the frame is not in a drag
60 // session, it will close immediately; otherwise, it will move offscreen (so
61 // events are still fired) until the drag ends, then close. This assumes
62 // that the Browser is not immediately destroyed, but will be eventually
63 // destroyed by other means (eg, the tab strip going to zero elements).
64 // Bad things happen if the Browser dtor is called directly as a result of
65 // invoking this method.
66 virtual void Close() = 0;
67
68 // Activates (brings to front) the window. Restores the window from minimized
69 // state if necessary.
70 virtual void Activate() = 0;
71
72 // Deactivates the window, making the next window in the Z order the active
73 // window.
74 virtual void Deactivate() = 0;
75
76 // Returns true if the window is currently the active/focused window.
77 virtual bool IsActive() const = 0;
78
79 // Flashes the taskbar item associated with this frame.
80 virtual void FlashFrame() = 0;
81
82 // Return a platform dependent identifier for this frame. On Windows, this
83 // returns an HWND.
84 virtual gfx::NativeWindow GetNativeHandle() = 0;
85
86 // Returns a pointer to the testing interface to the Browser window, or NULL
87 // if there is none.
88 virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0;
89
90 // Return the status bubble associated with the frame
91 virtual StatusBubble* GetStatusBubble() = 0;
92
93 // Inform the receiving frame that an animation has progressed in the
94 // selected tab.
95 // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to
96 // BrowserView.
[email protected]c9bd2e82011-04-15 23:28:1997 virtual void ToolbarSizeChanged(bool is_animating) = 0;
[email protected]69b04b92010-11-08 22:12:1898
99 // Inform the frame that the selected tab favicon or title has changed. Some
100 // frames may need to refresh their title bar.
101 virtual void UpdateTitleBar() = 0;
102
[email protected]09b29342011-06-24 19:18:48103 // Invoked when the state of the bookmark bar changes. This is only invoked if
104 // the state changes for the current tab, it is not sent when switching tabs.
105 virtual void BookmarkBarStateChanged(
106 BookmarkBar::AnimateChangeType change_type) = 0;
[email protected]69b04b92010-11-08 22:12:18107
108 // Inform the frame that the dev tools window for the selected tab has
109 // changed.
110 virtual void UpdateDevTools() = 0;
111
112 // Update any loading animations running in the window. |should_animate| is
113 // true if there are tabs loading and the animations should continue, false
114 // if there are no active loads and the animations should end.
115 virtual void UpdateLoadingAnimations(bool should_animate) = 0;
116
117 // Sets the starred state for the current tab.
118 virtual void SetStarredState(bool is_starred) = 0;
119
120 // Returns the nonmaximized bounds of the frame (even if the frame is
121 // currently maximized or minimized) in terms of the screen coordinates.
122 virtual gfx::Rect GetRestoredBounds() const = 0;
123
[email protected]d479b8e22011-02-09 05:19:49124 // Retrieves the window's current bounds, including its frame.
125 // This will only differ from GetRestoredBounds() for maximized
126 // and minimized windows.
127 virtual gfx::Rect GetBounds() const = 0;
128
[email protected]69b04b92010-11-08 22:12:18129 // TODO(beng): REMOVE?
130 // Returns true if the frame is maximized (aka zoomed).
131 virtual bool IsMaximized() const = 0;
132
133 // Accessors for fullscreen mode state.
134 virtual void SetFullscreen(bool fullscreen) = 0;
135 virtual bool IsFullscreen() const = 0;
136
137 // Returns true if the fullscreen bubble is visible.
138 virtual bool IsFullscreenBubbleVisible() const = 0;
139
140 // Returns the location bar.
141 virtual LocationBar* GetLocationBar() const = 0;
142
143 // Tries to focus the location bar. Clears the window focus (to avoid
144 // inconsistent state) if this fails.
145 virtual void SetFocusToLocationBar(bool select_all) = 0;
146
147 // Informs the view whether or not a load is in progress for the current tab.
148 // The view can use this notification to update the reload/stop button.
149 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
150
151 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49152 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18153 bool should_restore_state) = 0;
154
155 // Focuses the toolbar (for accessibility).
156 virtual void FocusToolbar() = 0;
157
158 // Focuses the app menu like it was a menu bar.
159 //
160 // Not used on the Mac, which has a "normal" menu bar.
161 virtual void FocusAppMenu() = 0;
162
163 // Focuses the bookmarks toolbar (for accessibility).
164 virtual void FocusBookmarksToolbar() = 0;
165
166 // Focuses the Chrome OS status view (for accessibility).
167 virtual void FocusChromeOSStatus() = 0;
168
169 // Moves keyboard focus to the next pane.
170 virtual void RotatePaneFocus(bool forwards) = 0;
171
172 // Returns whether the bookmark bar is visible or not.
173 virtual bool IsBookmarkBarVisible() const = 0;
174
175 // Returns whether the bookmark bar is animating or not.
176 virtual bool IsBookmarkBarAnimating() const = 0;
177
[email protected]95bf8a5b2010-12-22 16:04:07178 // Returns whether the tab strip is editable (for extensions).
179 virtual bool IsTabStripEditable() const = 0;
180
[email protected]69b04b92010-11-08 22:12:18181 // Returns whether the tool bar is visible or not.
182 virtual bool IsToolbarVisible() const = 0;
183
[email protected]69b04b92010-11-08 22:12:18184 // Tells the frame not to render as inactive until the next activation change.
185 // This is required on Windows when dropdown selects are shown to prevent the
186 // select from deactivating the browser frame. A stub implementation is
187 // provided here since the functionality is Windows-specific.
188 virtual void DisableInactiveFrame() {}
189
190 // Shows a confirmation dialog box for setting the default search engine
191 // described by |template_url|. Takes ownership of |template_url|.
192 virtual void ConfirmSetDefaultSearchProvider(
[email protected]b5a1d11c2011-02-17 03:09:42193 TabContents* tab_contents,
[email protected]69b04b92010-11-08 22:12:18194 TemplateURL* template_url,
[email protected]8e5c89a2011-06-07 18:13:33195 TemplateURLService* template_url_service) {
[email protected]69b04b92010-11-08 22:12:18196 // TODO(levin): Implement this for non-Windows platforms and make it pure.
[email protected]9219d262011-02-15 21:05:12197 // http://crbug.com/38475
[email protected]69b04b92010-11-08 22:12:18198 }
199
200 // Shows a confirmation dialog box for adding a search engine described by
201 // |template_url|. Takes ownership of |template_url|.
202 virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
203 Profile* profile) = 0;
204
205 // Shows or hides the bookmark bar depending on its current visibility.
206 virtual void ToggleBookmarkBar() = 0;
207
208 // Shows the About Chrome dialog box.
[email protected]4c6b474b72011-02-24 21:35:21209 virtual void ShowAboutChromeDialog() = 0;
[email protected]69b04b92010-11-08 22:12:18210
211 // Shows the Update Recommended dialog box.
212 virtual void ShowUpdateChromeDialog() = 0;
213
214 // Shows the Task manager.
215 virtual void ShowTaskManager() = 0;
216
[email protected]adb6a84d2011-02-07 16:58:40217 // Shows task information related to background pages.
218 virtual void ShowBackgroundPages() = 0;
219
[email protected]69b04b92010-11-08 22:12:18220 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
221 // |already_bookmarked| is true if the url is already bookmarked.
222 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
223
224 // Whether or not the shelf view is visible.
225 virtual bool IsDownloadShelfVisible() const = 0;
226
227 // Returns the DownloadShelf.
228 virtual DownloadShelf* GetDownloadShelf() = 0;
229
[email protected]69b04b92010-11-08 22:12:18230 // Shows the repost form confirmation dialog box.
231 virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) = 0;
232
[email protected]69b04b92010-11-08 22:12:18233 // Shows the collected cookies dialog box.
234 virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) = 0;
235
[email protected]69b04b92010-11-08 22:12:18236 // Show the bubble that indicates to the user that a theme is being installed.
237 virtual void ShowThemeInstallBubble() = 0;
238
239 // Shows the confirmation dialog box warning that the browser is closing with
240 // in-progress downloads.
241 // This method should call Browser::InProgressDownloadResponse once the user
242 // has confirmed.
243 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
244
[email protected]50285ff2011-03-11 23:10:56245 // Shows a dialog box with HTML content. |parent_window| is the window the
246 // dialog should be opened modal to and is a native window handle.
[email protected]69b04b92010-11-08 22:12:18247 virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
248 gfx::NativeWindow parent_window) = 0;
249
[email protected]a0ea76c2011-03-23 17:36:42250 // ThemeService calls this when a user has changed his or her theme,
[email protected]69b04b92010-11-08 22:12:18251 // indicating that it's time to redraw everything.
252 virtual void UserChangedTheme() = 0;
253
254 // Get extra vertical height that the render view should add to its requests
255 // to webkit. This can help prevent sending extraneous layout/repaint requests
256 // when the delegate is in the process of resizing the tab contents view (e.g.
257 // during infobar animations).
258 virtual int GetExtraRenderViewHeight() const = 0;
259
260 // Notification that |tab_contents| got the focus through user action (click
261 // on the page).
262 virtual void TabContentsFocused(TabContents* tab_contents) = 0;
263
264 // Shows the page info using the specified information.
265 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
266 // information for that page/frame. If |show_history| is true, a section
267 // showing how many times that URL has been visited is added to the page info.
268 virtual void ShowPageInfo(Profile* profile,
269 const GURL& url,
270 const NavigationEntry::SSLStatus& ssl,
271 bool show_history) = 0;
272
273 // Shows the app menu (for accessibility).
274 virtual void ShowAppMenu() = 0;
275
276 // Allows the BrowserWindow object to handle the specified keyboard event
277 // before sending it to the renderer.
278 // Returns true if the |event| was handled. Otherwise, if the |event| would
279 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
280 // |*is_keyboard_shortcut| should be set to true.
281 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
282 bool* is_keyboard_shortcut) = 0;
283
284 // Allows the BrowserWindow object to handle the specified keyboard event,
285 // if the renderer did not process it.
286 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
287
288 // Shows the create web app shortcut dialog box.
[email protected]f847e6082011-03-24 00:08:26289 virtual void ShowCreateWebAppShortcutsDialog(
290 TabContentsWrapper* tab_contents) = 0;
[email protected]a3b734b2010-11-30 03:17:11291
292 // Shows the create chrome app shortcut dialog box.
293 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
294 const Extension* app) = 0;
[email protected]69b04b92010-11-08 22:12:18295
[email protected]ac86c982011-05-11 13:26:05296 // Toggles compact navigation bar.
297 virtual void ToggleUseCompactNavigationBar() = 0;
298
[email protected]69b04b92010-11-08 22:12:18299 // Clipboard commands applied to the whole browser window.
300 virtual void Cut() = 0;
301 virtual void Copy() = 0;
302 virtual void Paste() = 0;
303
304 // Switches between available tabstrip display modes.
305 virtual void ToggleTabStripMode() = 0;
306
307#if defined(OS_MACOSX)
308 // Opens the tabpose view.
309 virtual void OpenTabpose() = 0;
[email protected]d3766932011-08-04 22:18:23310
311 // Sets the presentation mode for the window. If the window is not already in
312 // fullscreen, also enters fullscreen mode.
313 virtual void SetPresentationMode(bool presentation_mode) = 0;
314 virtual bool InPresentationMode() = 0;
[email protected]69b04b92010-11-08 22:12:18315#endif
316
[email protected]36d5e5592010-11-15 20:45:59317 // See InstantDelegate for details.
318 virtual void PrepareForInstant() = 0;
319
[email protected]69b04b92010-11-08 22:12:18320 // Invoked when instant's tab contents should be shown.
[email protected]e3690ed2011-03-25 20:25:14321 virtual void ShowInstant(TabContentsWrapper* preview) = 0;
[email protected]69b04b92010-11-08 22:12:18322
323 // Invoked when the instant's tab contents should be hidden.
[email protected]1946c932010-12-15 00:07:38324 // |instant_is_active| indicates if instant is still active.
325 virtual void HideInstant(bool instant_is_active) = 0;
[email protected]69b04b92010-11-08 22:12:18326
327 // Returns the desired bounds for instant in screen coordinates. Note that if
328 // instant isn't currently visible this returns the bounds instant would be
329 // placed at.
330 virtual gfx::Rect GetInstantBounds() = 0;
331
[email protected]588300d2011-04-28 21:06:35332 // Return the correct disposition for a popup window based on |bounds|.
333 virtual WindowOpenDisposition GetDispositionForPopupBounds(
334 const gfx::Rect& bounds) = 0;
335
[email protected]632983f2011-08-08 22:51:24336 // Construct a FindBar implementation for the |browser|.
337 virtual FindBar* CreateFindBar() = 0;
338
[email protected]d14af522010-12-02 03:54:50339#if defined(OS_CHROMEOS)
340 // Shows the keyboard overlay dialog box.
341 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) = 0;
342#endif
343
[email protected]69b04b92010-11-08 22:12:18344 // Construct a BrowserWindow implementation for the specified |browser|.
345 static BrowserWindow* CreateBrowserWindow(Browser* browser);
346
[email protected]69b04b92010-11-08 22:12:18347 protected:
348 friend class BrowserList;
349 friend class BrowserView;
350 virtual void DestroyBrowser() = 0;
[email protected]69b04b92010-11-08 22:12:18351};
352
353#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
354class BookmarkBarView;
355class LocationBarView;
356
357namespace views {
358class View;
359}
360#endif // defined(OS_WIN)
361
362// A BrowserWindow utility interface used for accessing elements of the browser
363// UI used only by UI test automation.
364class BrowserWindowTesting {
365 public:
366#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
367 // Returns the BookmarkBarView.
368 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
369
370 // Returns the LocationBarView.
371 virtual LocationBarView* GetLocationBarView() const = 0;
372
373 // Returns the TabContentsContainer.
374 virtual views::View* GetTabContentsContainerView() const = 0;
375
376 // Returns the TabContentsContainer.
377 virtual views::View* GetSidebarContainerView() const = 0;
378
379 // Returns the ToolbarView.
380 virtual ToolbarView* GetToolbarView() const = 0;
381#endif
382
383 protected:
384 virtual ~BrowserWindowTesting() {}
385};
386
387#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_