blob: 06b0dc407adf3b250101867fb10dcf6a37012778 [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]8d944b32011-10-17 06:11:5310#include "chrome/browser/ui/fullscreen_exit_bubble_type.h"
[email protected]69b04b92010-11-08 22:12:1811#include "chrome/common/content_settings_types.h"
[email protected]299425b2011-03-02 07:45:2012#include "content/browser/tab_contents/navigation_entry.h"
[email protected]08397d52011-02-05 01:53:3813#include "ui/gfx/native_widget_types.h"
[email protected]588300d2011-04-28 21:06:3514#include "webkit/glue/window_open_disposition.h"
[email protected]69b04b92010-11-08 22:12:1815
16class Browser;
17class BrowserWindowTesting;
18class DownloadShelf;
19class FindBar;
20class GURL;
21class HtmlDialogUIDelegate;
22class LocationBar;
[email protected]fe90ca8e2011-04-08 20:40:4323class Panel;
[email protected]69b04b92010-11-08 22:12:1824class Profile;
25class StatusBubble;
26class TabContents;
[email protected]3c9e1872010-11-18 16:17:4927class TabContentsWrapper;
[email protected]69b04b92010-11-08 22:12:1828class TemplateURL;
[email protected]8e5c89a2011-06-07 18:13:3329class TemplateURLService;
[email protected]69b04b92010-11-08 22:12:1830#if !defined(OS_MACOSX)
31class ToolbarView;
32#endif
33struct NativeWebKeyboardEvent;
34
35namespace gfx {
36class Rect;
[email protected]0548c5352011-09-07 00:33:3337class Size;
[email protected]69b04b92010-11-08 22:12:1838}
39
[email protected]a3b734b2010-11-30 03:17:1140class Extension;
41
[email protected]69b04b92010-11-08 22:12:1842////////////////////////////////////////////////////////////////////////////////
43// BrowserWindow interface
44// An interface implemented by the "view" of the Browser window.
45//
46// NOTE: All getters may return NULL.
47class BrowserWindow {
48 public:
[email protected]ed2f27132011-04-04 17:19:5749 virtual ~BrowserWindow() {}
50
[email protected]69b04b92010-11-08 22:12:1851 // Show the window, or activates it if it's already visible.
[email protected]2f516c792011-09-19 22:22:0952 // Browser::OnWindowDidShow should be called after showing the window.
[email protected]69b04b92010-11-08 22:12:1853 virtual void Show() = 0;
54
[email protected]d4db6c702011-03-28 21:49:1455 // Show the window, but do not activate it. Does nothing if window
56 // is already visible.
57 virtual void ShowInactive() = 0;
58
[email protected]69b04b92010-11-08 22:12:1859 // Sets the window's size and position to the specified values.
60 virtual void SetBounds(const gfx::Rect& bounds) = 0;
61
62 // Closes the frame as soon as possible. If the frame is not in a drag
63 // session, it will close immediately; otherwise, it will move offscreen (so
64 // events are still fired) until the drag ends, then close. This assumes
65 // that the Browser is not immediately destroyed, but will be eventually
66 // destroyed by other means (eg, the tab strip going to zero elements).
67 // Bad things happen if the Browser dtor is called directly as a result of
68 // invoking this method.
69 virtual void Close() = 0;
70
71 // Activates (brings to front) the window. Restores the window from minimized
72 // state if necessary.
73 virtual void Activate() = 0;
74
75 // Deactivates the window, making the next window in the Z order the active
76 // window.
77 virtual void Deactivate() = 0;
78
79 // Returns true if the window is currently the active/focused window.
80 virtual bool IsActive() const = 0;
81
82 // Flashes the taskbar item associated with this frame.
83 virtual void FlashFrame() = 0;
84
85 // Return a platform dependent identifier for this frame. On Windows, this
86 // returns an HWND.
87 virtual gfx::NativeWindow GetNativeHandle() = 0;
88
89 // Returns a pointer to the testing interface to the Browser window, or NULL
90 // if there is none.
91 virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0;
92
93 // Return the status bubble associated with the frame
94 virtual StatusBubble* GetStatusBubble() = 0;
95
96 // Inform the receiving frame that an animation has progressed in the
97 // selected tab.
98 // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to
99 // BrowserView.
[email protected]c9bd2e82011-04-15 23:28:19100 virtual void ToolbarSizeChanged(bool is_animating) = 0;
[email protected]69b04b92010-11-08 22:12:18101
102 // Inform the frame that the selected tab favicon or title has changed. Some
103 // frames may need to refresh their title bar.
104 virtual void UpdateTitleBar() = 0;
105
[email protected]09b29342011-06-24 19:18:48106 // Invoked when the state of the bookmark bar changes. This is only invoked if
107 // the state changes for the current tab, it is not sent when switching tabs.
108 virtual void BookmarkBarStateChanged(
109 BookmarkBar::AnimateChangeType change_type) = 0;
[email protected]69b04b92010-11-08 22:12:18110
111 // Inform the frame that the dev tools window for the selected tab has
112 // changed.
113 virtual void UpdateDevTools() = 0;
114
115 // Update any loading animations running in the window. |should_animate| is
116 // true if there are tabs loading and the animations should continue, false
117 // if there are no active loads and the animations should end.
118 virtual void UpdateLoadingAnimations(bool should_animate) = 0;
119
120 // Sets the starred state for the current tab.
121 virtual void SetStarredState(bool is_starred) = 0;
122
123 // Returns the nonmaximized bounds of the frame (even if the frame is
124 // currently maximized or minimized) in terms of the screen coordinates.
125 virtual gfx::Rect GetRestoredBounds() const = 0;
126
[email protected]d479b8e22011-02-09 05:19:49127 // Retrieves the window's current bounds, including its frame.
128 // This will only differ from GetRestoredBounds() for maximized
129 // and minimized windows.
130 virtual gfx::Rect GetBounds() const = 0;
131
[email protected]69b04b92010-11-08 22:12:18132 // TODO(beng): REMOVE?
133 // Returns true if the frame is maximized (aka zoomed).
134 virtual bool IsMaximized() const = 0;
135
[email protected]400eaf82011-08-22 15:47:39136 // Returns true if the frame is minimized.
137 virtual bool IsMinimized() const = 0;
138
[email protected]69b04b92010-11-08 22:12:18139 // Accessors for fullscreen mode state.
[email protected]8d944b32011-10-17 06:11:53140 virtual void EnterFullscreen(const GURL& url,
141 FullscreenExitBubbleType bubble_type) = 0;
[email protected]55c87fa2011-10-15 07:28:28142 virtual void ExitFullscreen() = 0;
[email protected]8d944b32011-10-17 06:11:53143 virtual void UpdateFullscreenExitBubbleContent(
144 const GURL& url,
145 FullscreenExitBubbleType bubble_type) = 0;
[email protected]69b04b92010-11-08 22:12:18146 virtual bool IsFullscreen() const = 0;
147
148 // Returns true if the fullscreen bubble is visible.
149 virtual bool IsFullscreenBubbleVisible() const = 0;
150
151 // Returns the location bar.
152 virtual LocationBar* GetLocationBar() const = 0;
153
154 // Tries to focus the location bar. Clears the window focus (to avoid
155 // inconsistent state) if this fails.
156 virtual void SetFocusToLocationBar(bool select_all) = 0;
157
158 // Informs the view whether or not a load is in progress for the current tab.
159 // The view can use this notification to update the reload/stop button.
160 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
161
162 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49163 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18164 bool should_restore_state) = 0;
165
166 // Focuses the toolbar (for accessibility).
167 virtual void FocusToolbar() = 0;
168
169 // Focuses the app menu like it was a menu bar.
170 //
171 // Not used on the Mac, which has a "normal" menu bar.
172 virtual void FocusAppMenu() = 0;
173
174 // Focuses the bookmarks toolbar (for accessibility).
175 virtual void FocusBookmarksToolbar() = 0;
176
177 // Focuses the Chrome OS status view (for accessibility).
178 virtual void FocusChromeOSStatus() = 0;
179
180 // Moves keyboard focus to the next pane.
181 virtual void RotatePaneFocus(bool forwards) = 0;
182
183 // Returns whether the bookmark bar is visible or not.
184 virtual bool IsBookmarkBarVisible() const = 0;
185
186 // Returns whether the bookmark bar is animating or not.
187 virtual bool IsBookmarkBarAnimating() const = 0;
188
[email protected]95bf8a5b2010-12-22 16:04:07189 // Returns whether the tab strip is editable (for extensions).
190 virtual bool IsTabStripEditable() const = 0;
191
[email protected]69b04b92010-11-08 22:12:18192 // Returns whether the tool bar is visible or not.
193 virtual bool IsToolbarVisible() const = 0;
194
[email protected]69b04b92010-11-08 22:12:18195 // Tells the frame not to render as inactive until the next activation change.
196 // This is required on Windows when dropdown selects are shown to prevent the
197 // select from deactivating the browser frame. A stub implementation is
198 // provided here since the functionality is Windows-specific.
199 virtual void DisableInactiveFrame() {}
200
201 // Shows a confirmation dialog box for setting the default search engine
202 // described by |template_url|. Takes ownership of |template_url|.
[email protected]9b0e63e52011-10-12 23:08:10203 virtual void ConfirmSetDefaultSearchProvider(TabContents* tab_contents,
204 TemplateURL* template_url,
205 Profile* profile) {
[email protected]69b04b92010-11-08 22:12:18206 // TODO(levin): Implement this for non-Windows platforms and make it pure.
[email protected]9219d262011-02-15 21:05:12207 // http://crbug.com/38475
[email protected]69b04b92010-11-08 22:12:18208 }
209
210 // Shows a confirmation dialog box for adding a search engine described by
211 // |template_url|. Takes ownership of |template_url|.
212 virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
213 Profile* profile) = 0;
214
215 // Shows or hides the bookmark bar depending on its current visibility.
216 virtual void ToggleBookmarkBar() = 0;
217
218 // Shows the About Chrome dialog box.
[email protected]4c6b474b72011-02-24 21:35:21219 virtual void ShowAboutChromeDialog() = 0;
[email protected]69b04b92010-11-08 22:12:18220
221 // Shows the Update Recommended dialog box.
222 virtual void ShowUpdateChromeDialog() = 0;
223
224 // Shows the Task manager.
225 virtual void ShowTaskManager() = 0;
226
[email protected]adb6a84d2011-02-07 16:58:40227 // Shows task information related to background pages.
228 virtual void ShowBackgroundPages() = 0;
229
[email protected]69b04b92010-11-08 22:12:18230 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
231 // |already_bookmarked| is true if the url is already bookmarked.
232 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
233
234 // Whether or not the shelf view is visible.
235 virtual bool IsDownloadShelfVisible() const = 0;
236
237 // Returns the DownloadShelf.
238 virtual DownloadShelf* GetDownloadShelf() = 0;
239
[email protected]69b04b92010-11-08 22:12:18240 // Shows the repost form confirmation dialog box.
241 virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) = 0;
242
[email protected]69b04b92010-11-08 22:12:18243 // Shows the collected cookies dialog box.
[email protected]a3627e62011-09-07 00:04:57244 virtual void ShowCollectedCookiesDialog(TabContentsWrapper* tab_contents) = 0;
[email protected]69b04b92010-11-08 22:12:18245
[email protected]69b04b92010-11-08 22:12:18246 // Show the bubble that indicates to the user that a theme is being installed.
247 virtual void ShowThemeInstallBubble() = 0;
248
249 // Shows the confirmation dialog box warning that the browser is closing with
250 // in-progress downloads.
251 // This method should call Browser::InProgressDownloadResponse once the user
252 // has confirmed.
253 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
254
[email protected]a0ea76c2011-03-23 17:36:42255 // ThemeService calls this when a user has changed his or her theme,
[email protected]69b04b92010-11-08 22:12:18256 // indicating that it's time to redraw everything.
257 virtual void UserChangedTheme() = 0;
258
259 // Get extra vertical height that the render view should add to its requests
260 // to webkit. This can help prevent sending extraneous layout/repaint requests
261 // when the delegate is in the process of resizing the tab contents view (e.g.
262 // during infobar animations).
263 virtual int GetExtraRenderViewHeight() const = 0;
264
265 // Notification that |tab_contents| got the focus through user action (click
266 // on the page).
267 virtual void TabContentsFocused(TabContents* tab_contents) = 0;
268
269 // Shows the page info using the specified information.
270 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
271 // information for that page/frame. If |show_history| is true, a section
272 // showing how many times that URL has been visited is added to the page info.
273 virtual void ShowPageInfo(Profile* profile,
274 const GURL& url,
275 const NavigationEntry::SSLStatus& ssl,
276 bool show_history) = 0;
277
278 // Shows the app menu (for accessibility).
279 virtual void ShowAppMenu() = 0;
280
281 // Allows the BrowserWindow object to handle the specified keyboard event
282 // before sending it to the renderer.
283 // Returns true if the |event| was handled. Otherwise, if the |event| would
284 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
285 // |*is_keyboard_shortcut| should be set to true.
286 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
287 bool* is_keyboard_shortcut) = 0;
288
289 // Allows the BrowserWindow object to handle the specified keyboard event,
290 // if the renderer did not process it.
291 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
292
293 // Shows the create web app shortcut dialog box.
[email protected]f847e6082011-03-24 00:08:26294 virtual void ShowCreateWebAppShortcutsDialog(
295 TabContentsWrapper* tab_contents) = 0;
[email protected]a3b734b2010-11-30 03:17:11296
297 // Shows the create chrome app shortcut dialog box.
298 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
299 const Extension* app) = 0;
[email protected]69b04b92010-11-08 22:12:18300
301 // Clipboard commands applied to the whole browser window.
302 virtual void Cut() = 0;
303 virtual void Copy() = 0;
304 virtual void Paste() = 0;
305
[email protected]69b04b92010-11-08 22:12:18306#if defined(OS_MACOSX)
307 // Opens the tabpose view.
308 virtual void OpenTabpose() = 0;
[email protected]d3766932011-08-04 22:18:23309
310 // Sets the presentation mode for the window. If the window is not already in
311 // fullscreen, also enters fullscreen mode.
[email protected]8d944b32011-10-17 06:11:53312 virtual void EnterPresentationMode(
313 const GURL& url,
314 FullscreenExitBubbleType bubble_type) = 0;
315 virtual void ExitPresentationMode() = 0;
[email protected]d3766932011-08-04 22:18:23316 virtual bool InPresentationMode() = 0;
[email protected]69b04b92010-11-08 22:12:18317#endif
318
[email protected]69b04b92010-11-08 22:12:18319 // Invoked when instant's tab contents should be shown.
[email protected]e3690ed2011-03-25 20:25:14320 virtual void ShowInstant(TabContentsWrapper* preview) = 0;
[email protected]69b04b92010-11-08 22:12:18321
322 // Invoked when the instant's tab contents should be hidden.
[email protected]3e481282011-10-15 15:39:50323 virtual void HideInstant() = 0;
[email protected]69b04b92010-11-08 22:12:18324
325 // Returns the desired bounds for instant in screen coordinates. Note that if
326 // instant isn't currently visible this returns the bounds instant would be
327 // placed at.
328 virtual gfx::Rect GetInstantBounds() = 0;
329
[email protected]588300d2011-04-28 21:06:35330 // Return the correct disposition for a popup window based on |bounds|.
331 virtual WindowOpenDisposition GetDispositionForPopupBounds(
332 const gfx::Rect& bounds) = 0;
333
[email protected]632983f2011-08-08 22:51:24334 // Construct a FindBar implementation for the |browser|.
335 virtual FindBar* CreateFindBar() = 0;
336
[email protected]d14af522010-12-02 03:54:50337#if defined(OS_CHROMEOS)
[email protected]e7137b2c2011-10-24 20:16:55338 // Shows the mobile setup dialog.
339 virtual void ShowMobileSetup() = 0;
340
[email protected]d14af522010-12-02 03:54:50341 // Shows the keyboard overlay dialog box.
342 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) = 0;
343#endif
344
[email protected]0548c5352011-09-07 00:33:33345 // Invoked when the preferred size of the contents in current tab has been
346 // changed. We might choose to update the window size to accomodate this
347 // change.
348 // Note that this won't be fired if we change tabs.
349 virtual void UpdatePreferredSize(TabContents* tab_contents,
350 const gfx::Size& pref_size) {}
351
[email protected]69b04b92010-11-08 22:12:18352 // Construct a BrowserWindow implementation for the specified |browser|.
353 static BrowserWindow* CreateBrowserWindow(Browser* browser);
354
[email protected]2f733a02011-10-06 15:17:34355 // Shows the avatar bubble inside |tab_contents|. The bubble is positioned
356 // relative to |rect|. |rect| should be in the |tab_contents| coordinate
357 // system.
358 virtual void ShowAvatarBubble(TabContents* tab_contents,
359 const gfx::Rect& rect) = 0;
360
[email protected]7d2d08152011-10-25 22:58:47361 // Shows the avatar bubble on the window frame off of the avatar button.
362 virtual void ShowAvatarBubbleFromAvatarButton() = 0;
363
[email protected]69b04b92010-11-08 22:12:18364 protected:
365 friend class BrowserList;
366 friend class BrowserView;
367 virtual void DestroyBrowser() = 0;
[email protected]69b04b92010-11-08 22:12:18368};
369
370#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
371class BookmarkBarView;
372class LocationBarView;
373
374namespace views {
375class View;
376}
377#endif // defined(OS_WIN)
378
379// A BrowserWindow utility interface used for accessing elements of the browser
380// UI used only by UI test automation.
381class BrowserWindowTesting {
382 public:
383#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
384 // Returns the BookmarkBarView.
385 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
386
387 // Returns the LocationBarView.
388 virtual LocationBarView* GetLocationBarView() const = 0;
389
390 // Returns the TabContentsContainer.
391 virtual views::View* GetTabContentsContainerView() const = 0;
392
393 // Returns the TabContentsContainer.
394 virtual views::View* GetSidebarContainerView() const = 0;
395
396 // Returns the ToolbarView.
397 virtual ToolbarView* GetToolbarView() const = 0;
398#endif
399
400 protected:
401 virtual ~BrowserWindowTesting() {}
402};
403
404#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_