blob: 7532fedb71a2b3624848c9c820ab88d1163dcc2e [file] [log] [blame]
[email protected]3a80ea332012-01-09 19:53:291// Copyright (c) 2012 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]fe54b4a2012-03-28 16:11:049#include "base/callback_forward.h"
[email protected]2e6389f2012-05-18 19:41:2510#include "chrome/browser/lifetime/application_lifetime.h"
[email protected]41d9faf2012-02-28 23:46:0211#include "chrome/browser/ui/base_window.h"
[email protected]09b29342011-06-24 19:18:4812#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
[email protected]8d944b32011-10-17 06:11:5313#include "chrome/browser/ui/fullscreen_exit_bubble_type.h"
[email protected]e4b66bf2012-05-29 20:39:5114#include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
[email protected]69b04b92010-11-08 22:12:1815#include "chrome/common/content_settings_types.h"
[email protected]08397d52011-02-05 01:53:3816#include "ui/gfx/native_widget_types.h"
[email protected]588300d2011-04-28 21:06:3517#include "webkit/glue/window_open_disposition.h"
[email protected]69b04b92010-11-08 22:12:1818
19class Browser;
20class BrowserWindowTesting;
21class DownloadShelf;
22class FindBar;
23class GURL;
[email protected]69b04b92010-11-08 22:12:1824class LocationBar;
25class Profile;
26class StatusBubble;
[email protected]3c9e1872010-11-18 16:17:4927class TabContentsWrapper;
[email protected]69b04b92010-11-08 22:12:1828class TemplateURL;
[email protected]69b04b92010-11-08 22:12:1829#if !defined(OS_MACOSX)
30class ToolbarView;
31#endif
[email protected]69b04b92010-11-08 22:12:1832
[email protected]ea049a02011-12-25 21:37:0933namespace content {
34class WebContents;
[email protected]b87ee522012-05-18 15:16:5435struct NativeWebKeyboardEvent;
[email protected]d583e3f22011-12-27 21:38:1736struct SSLStatus;
[email protected]ea049a02011-12-25 21:37:0937}
38
[email protected]1c321ee2012-05-21 03:02:3439namespace extensions {
40class Extension;
41}
42
[email protected]69b04b92010-11-08 22:12:1843namespace gfx {
44class Rect;
[email protected]0548c5352011-09-07 00:33:3345class Size;
[email protected]69b04b92010-11-08 22:12:1846}
47
[email protected]4d5ef8692012-05-31 02:28:5748namespace webkit {
49namespace forms {
50struct PasswordForm;
51}
52}
[email protected]a3b734b2010-11-30 03:17:1153
[email protected]853e16eb2011-12-29 16:58:1954enum DevToolsDockSide {
55 DEVTOOLS_DOCK_SIDE_BOTTOM = 0,
56 DEVTOOLS_DOCK_SIDE_RIGHT = 1
57};
58
[email protected]69b04b92010-11-08 22:12:1859////////////////////////////////////////////////////////////////////////////////
60// BrowserWindow interface
61// An interface implemented by the "view" of the Browser window.
[email protected]41d9faf2012-02-28 23:46:0262// This interface includes BaseWindow methods as well as Browser window
63// specific methods.
[email protected]69b04b92010-11-08 22:12:1864//
65// NOTE: All getters may return NULL.
[email protected]41d9faf2012-02-28 23:46:0266//
67class BrowserWindow : public BaseWindow {
[email protected]69b04b92010-11-08 22:12:1868 public:
[email protected]ed2f27132011-04-04 17:19:5769 virtual ~BrowserWindow() {}
70
[email protected]41d9faf2012-02-28 23:46:0271 //////////////////////////////////////////////////////////////////////////////
72 // BaseWindow interface notes:
[email protected]69b04b92010-11-08 22:12:1873
[email protected]41d9faf2012-02-28 23:46:0274 // Closes the window as soon as possible. If the window is not in a drag
[email protected]69b04b92010-11-08 22:12:1875 // session, it will close immediately; otherwise, it will move offscreen (so
76 // events are still fired) until the drag ends, then close. This assumes
77 // that the Browser is not immediately destroyed, but will be eventually
78 // destroyed by other means (eg, the tab strip going to zero elements).
79 // Bad things happen if the Browser dtor is called directly as a result of
80 // invoking this method.
[email protected]41d9faf2012-02-28 23:46:0281 // virtual void Close() = 0;
[email protected]69b04b92010-11-08 22:12:1882
[email protected]41d9faf2012-02-28 23:46:0283 // Browser::OnWindowDidShow should be called after showing the window.
84 // virtual void Show() = 0;
[email protected]69b04b92010-11-08 22:12:1885
[email protected]1443fe82012-04-02 08:48:0386 // No BrowserWindow supports this BaseWindow function.
87 virtual void SetDraggableRegion(SkRegion* region) OVERRIDE {}
88
[email protected]41d9faf2012-02-28 23:46:0289 //////////////////////////////////////////////////////////////////////////////
90 // Browser specific methods:
[email protected]69b04b92010-11-08 22:12:1891
92 // Return a platform dependent identifier for this frame. On Windows, this
93 // returns an HWND.
94 virtual gfx::NativeWindow GetNativeHandle() = 0;
95
96 // Returns a pointer to the testing interface to the Browser window, or NULL
97 // if there is none.
98 virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0;
99
100 // Return the status bubble associated with the frame
101 virtual StatusBubble* GetStatusBubble() = 0;
102
103 // Inform the receiving frame that an animation has progressed in the
104 // selected tab.
105 // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to
106 // BrowserView.
[email protected]c9bd2e82011-04-15 23:28:19107 virtual void ToolbarSizeChanged(bool is_animating) = 0;
[email protected]69b04b92010-11-08 22:12:18108
109 // Inform the frame that the selected tab favicon or title has changed. Some
110 // frames may need to refresh their title bar.
111 virtual void UpdateTitleBar() = 0;
112
[email protected]09b29342011-06-24 19:18:48113 // Invoked when the state of the bookmark bar changes. This is only invoked if
114 // the state changes for the current tab, it is not sent when switching tabs.
115 virtual void BookmarkBarStateChanged(
116 BookmarkBar::AnimateChangeType change_type) = 0;
[email protected]69b04b92010-11-08 22:12:18117
118 // Inform the frame that the dev tools window for the selected tab has
119 // changed.
120 virtual void UpdateDevTools() = 0;
121
[email protected]853e16eb2011-12-29 16:58:19122 // Requests that the docked dev tools window changes its dock mode.
123 virtual void SetDevToolsDockSide(DevToolsDockSide side) = 0;
124
[email protected]69b04b92010-11-08 22:12:18125 // Update any loading animations running in the window. |should_animate| is
126 // true if there are tabs loading and the animations should continue, false
127 // if there are no active loads and the animations should end.
128 virtual void UpdateLoadingAnimations(bool should_animate) = 0;
129
130 // Sets the starred state for the current tab.
131 virtual void SetStarredState(bool is_starred) = 0;
132
[email protected]69b04b92010-11-08 22:12:18133 // Accessors for fullscreen mode state.
[email protected]8d944b32011-10-17 06:11:53134 virtual void EnterFullscreen(const GURL& url,
135 FullscreenExitBubbleType bubble_type) = 0;
[email protected]55c87fa2011-10-15 07:28:28136 virtual void ExitFullscreen() = 0;
[email protected]8d944b32011-10-17 06:11:53137 virtual void UpdateFullscreenExitBubbleContent(
138 const GURL& url,
139 FullscreenExitBubbleType bubble_type) = 0;
[email protected]69b04b92010-11-08 22:12:18140
141 // Returns true if the fullscreen bubble is visible.
142 virtual bool IsFullscreenBubbleVisible() const = 0;
143
144 // Returns the location bar.
145 virtual LocationBar* GetLocationBar() const = 0;
146
147 // Tries to focus the location bar. Clears the window focus (to avoid
148 // inconsistent state) if this fails.
149 virtual void SetFocusToLocationBar(bool select_all) = 0;
150
151 // Informs the view whether or not a load is in progress for the current tab.
152 // The view can use this notification to update the reload/stop button.
153 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
154
155 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49156 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18157 bool should_restore_state) = 0;
158
159 // Focuses the toolbar (for accessibility).
160 virtual void FocusToolbar() = 0;
161
162 // Focuses the app menu like it was a menu bar.
163 //
164 // Not used on the Mac, which has a "normal" menu bar.
165 virtual void FocusAppMenu() = 0;
166
167 // Focuses the bookmarks toolbar (for accessibility).
168 virtual void FocusBookmarksToolbar() = 0;
169
[email protected]69b04b92010-11-08 22:12:18170 // Moves keyboard focus to the next pane.
171 virtual void RotatePaneFocus(bool forwards) = 0;
172
173 // Returns whether the bookmark bar is visible or not.
174 virtual bool IsBookmarkBarVisible() const = 0;
175
176 // Returns whether the bookmark bar is animating or not.
177 virtual bool IsBookmarkBarAnimating() const = 0;
178
[email protected]95bf8a5b2010-12-22 16:04:07179 // Returns whether the tab strip is editable (for extensions).
180 virtual bool IsTabStripEditable() const = 0;
181
[email protected]69b04b92010-11-08 22:12:18182 // Returns whether the tool bar is visible or not.
183 virtual bool IsToolbarVisible() const = 0;
184
[email protected]b7a756d42012-01-23 18:08:17185 // Returns the rect where the resize corner should be drawn by the render
186 // widget host view (on top of what the renderer returns). We return an empty
187 // rect to identify that there shouldn't be a resize corner (in the cases
188 // where we take care of it ourselves at the browser level).
189 virtual gfx::Rect GetRootWindowResizerRect() const = 0;
190
[email protected]5f58c2af2012-01-11 17:55:29191 // Returns whether the window is a panel. This is not always synonomous
192 // with the associated browser having type panel since some environments
193 // may draw popups in panel windows.
194 virtual bool IsPanel() const = 0;
195
[email protected]69b04b92010-11-08 22:12:18196 // Tells the frame not to render as inactive until the next activation change.
197 // This is required on Windows when dropdown selects are shown to prevent the
198 // select from deactivating the browser frame. A stub implementation is
199 // provided here since the functionality is Windows-specific.
200 virtual void DisableInactiveFrame() {}
201
[email protected]69b04b92010-11-08 22:12:18202 // Shows a confirmation dialog box for adding a search engine described by
203 // |template_url|. Takes ownership of |template_url|.
[email protected]3613347d2012-04-27 20:27:37204 virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
[email protected]69b04b92010-11-08 22:12:18205 Profile* profile) = 0;
206
207 // Shows or hides the bookmark bar depending on its current visibility.
208 virtual void ToggleBookmarkBar() = 0;
209
210 // Shows the About Chrome dialog box.
[email protected]4c6b474b72011-02-24 21:35:21211 virtual void ShowAboutChromeDialog() = 0;
[email protected]69b04b92010-11-08 22:12:18212
213 // Shows the Update Recommended dialog box.
214 virtual void ShowUpdateChromeDialog() = 0;
215
216 // Shows the Task manager.
217 virtual void ShowTaskManager() = 0;
218
[email protected]adb6a84d2011-02-07 16:58:40219 // Shows task information related to background pages.
220 virtual void ShowBackgroundPages() = 0;
221
[email protected]69b04b92010-11-08 22:12:18222 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
223 // |already_bookmarked| is true if the url is already bookmarked.
224 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
225
[email protected]b106ca52012-03-13 06:08:46226 // Shows the Chrome To Mobile bubble.
227 virtual void ShowChromeToMobileBubble() = 0;
228
[email protected]235a0562012-03-26 22:22:35229#if defined(ENABLE_ONE_CLICK_SIGNIN)
[email protected]e4b66bf2012-05-29 20:39:51230 // Callback type used with the ShowOneClickSigninBubble() method. If the
231 // user chooses to accept the sign in, the callback is called to start the
232 // sync process.
233 typedef base::Callback<void(OneClickSigninSyncStarter::StartSyncMode)>
234 StartSyncCallback;
235
236 // Shows the one-click sign in bubble.
[email protected]fe54b4a2012-03-28 16:11:04237 virtual void ShowOneClickSigninBubble(
[email protected]e4b66bf2012-05-29 20:39:51238 const StartSyncCallback& start_sync_callback) = 0;
[email protected]235a0562012-03-26 22:22:35239#endif
240
[email protected]69b04b92010-11-08 22:12:18241 // Whether or not the shelf view is visible.
242 virtual bool IsDownloadShelfVisible() const = 0;
243
244 // Returns the DownloadShelf.
245 virtual DownloadShelf* GetDownloadShelf() = 0;
246
[email protected]69b04b92010-11-08 22:12:18247 // Shows the confirmation dialog box warning that the browser is closing with
248 // in-progress downloads.
249 // This method should call Browser::InProgressDownloadResponse once the user
250 // has confirmed.
251 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
252
[email protected]a0ea76c2011-03-23 17:36:42253 // ThemeService calls this when a user has changed his or her theme,
[email protected]69b04b92010-11-08 22:12:18254 // indicating that it's time to redraw everything.
255 virtual void UserChangedTheme() = 0;
256
257 // Get extra vertical height that the render view should add to its requests
258 // to webkit. This can help prevent sending extraneous layout/repaint requests
259 // when the delegate is in the process of resizing the tab contents view (e.g.
260 // during infobar animations).
261 virtual int GetExtraRenderViewHeight() const = 0;
262
[email protected]2a6bc3e2011-12-28 23:51:33263 // Notification that |contents| got the focus through user action (click
[email protected]69b04b92010-11-08 22:12:18264 // on the page).
[email protected]2a6bc3e2011-12-28 23:51:33265 virtual void WebContentsFocused(content::WebContents* contents) = 0;
[email protected]69b04b92010-11-08 22:12:18266
267 // Shows the page info using the specified information.
268 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
269 // information for that page/frame. If |show_history| is true, a section
270 // showing how many times that URL has been visited is added to the page info.
271 virtual void ShowPageInfo(Profile* profile,
272 const GURL& url,
[email protected]d583e3f22011-12-27 21:38:17273 const content::SSLStatus& ssl,
[email protected]69b04b92010-11-08 22:12:18274 bool show_history) = 0;
275
[email protected]b8e681e82012-02-20 10:18:47276 // Shows the website settings using the specified information. |url| is the
277 // url of the page/frame the info applies to, |ssl| is the SSL information for
278 // that page/frame. If |show_history| is true, a section showing how many
279 // times that URL has been visited is added to the page info.
280 virtual void ShowWebsiteSettings(Profile* profile,
281 TabContentsWrapper* tab_contents_wrapper,
282 const GURL& url,
283 const content::SSLStatus& ssl,
284 bool show_history) = 0;
285
[email protected]69b04b92010-11-08 22:12:18286 // Shows the app menu (for accessibility).
287 virtual void ShowAppMenu() = 0;
288
289 // Allows the BrowserWindow object to handle the specified keyboard event
290 // before sending it to the renderer.
291 // Returns true if the |event| was handled. Otherwise, if the |event| would
292 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
293 // |*is_keyboard_shortcut| should be set to true.
[email protected]b87ee522012-05-18 15:16:54294 virtual bool PreHandleKeyboardEvent(
295 const content::NativeWebKeyboardEvent& event,
296 bool* is_keyboard_shortcut) = 0;
[email protected]69b04b92010-11-08 22:12:18297
298 // Allows the BrowserWindow object to handle the specified keyboard event,
299 // if the renderer did not process it.
[email protected]b87ee522012-05-18 15:16:54300 virtual void HandleKeyboardEvent(
301 const content::NativeWebKeyboardEvent& event) = 0;
[email protected]69b04b92010-11-08 22:12:18302
303 // Shows the create web app shortcut dialog box.
[email protected]f847e6082011-03-24 00:08:26304 virtual void ShowCreateWebAppShortcutsDialog(
305 TabContentsWrapper* tab_contents) = 0;
[email protected]a3b734b2010-11-30 03:17:11306
307 // Shows the create chrome app shortcut dialog box.
308 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
[email protected]1c321ee2012-05-21 03:02:34309 const extensions::Extension* app) = 0;
310
[email protected]69b04b92010-11-08 22:12:18311
312 // Clipboard commands applied to the whole browser window.
313 virtual void Cut() = 0;
314 virtual void Copy() = 0;
315 virtual void Paste() = 0;
316
[email protected]69b04b92010-11-08 22:12:18317#if defined(OS_MACOSX)
318 // Opens the tabpose view.
319 virtual void OpenTabpose() = 0;
[email protected]d3766932011-08-04 22:18:23320
321 // Sets the presentation mode for the window. If the window is not already in
322 // fullscreen, also enters fullscreen mode.
[email protected]8d944b32011-10-17 06:11:53323 virtual void EnterPresentationMode(
324 const GURL& url,
325 FullscreenExitBubbleType bubble_type) = 0;
326 virtual void ExitPresentationMode() = 0;
[email protected]d3766932011-08-04 22:18:23327 virtual bool InPresentationMode() = 0;
[email protected]69b04b92010-11-08 22:12:18328#endif
329
[email protected]69b04b92010-11-08 22:12:18330 // Invoked when instant's tab contents should be shown.
[email protected]e3690ed2011-03-25 20:25:14331 virtual void ShowInstant(TabContentsWrapper* preview) = 0;
[email protected]69b04b92010-11-08 22:12:18332
333 // Invoked when the instant's tab contents should be hidden.
[email protected]3e481282011-10-15 15:39:50334 virtual void HideInstant() = 0;
[email protected]69b04b92010-11-08 22:12:18335
336 // Returns the desired bounds for instant in screen coordinates. Note that if
337 // instant isn't currently visible this returns the bounds instant would be
338 // placed at.
339 virtual gfx::Rect GetInstantBounds() = 0;
340
[email protected]588300d2011-04-28 21:06:35341 // Return the correct disposition for a popup window based on |bounds|.
342 virtual WindowOpenDisposition GetDispositionForPopupBounds(
343 const gfx::Rect& bounds) = 0;
344
[email protected]632983f2011-08-08 22:51:24345 // Construct a FindBar implementation for the |browser|.
346 virtual FindBar* CreateFindBar() = 0;
347
[email protected]0548c5352011-09-07 00:33:33348 // Invoked when the preferred size of the contents in current tab has been
349 // changed. We might choose to update the window size to accomodate this
350 // change.
351 // Note that this won't be fired if we change tabs.
[email protected]2a6bc3e2011-12-28 23:51:33352 virtual void UpdatePreferredSize(content::WebContents* web_contents,
[email protected]0548c5352011-09-07 00:33:33353 const gfx::Size& pref_size) {}
354
[email protected]61e2b3cc2012-03-02 16:13:34355 // Invoked when the contents auto-resized and the container should match it.
356 virtual void ResizeDueToAutoResize(content::WebContents* web_contents,
357 const gfx::Size& new_size) {}
358
[email protected]69b04b92010-11-08 22:12:18359 // Construct a BrowserWindow implementation for the specified |browser|.
360 static BrowserWindow* CreateBrowserWindow(Browser* browser);
361
[email protected]0ec4898e2011-12-30 21:09:24362 // Shows the avatar bubble inside |web_contents|. The bubble is positioned
363 // relative to |rect|. |rect| should be in the |web_contents| coordinate
[email protected]2f733a02011-10-06 15:17:34364 // system.
[email protected]0ec4898e2011-12-30 21:09:24365 virtual void ShowAvatarBubble(content::WebContents* web_contents,
[email protected]2f733a02011-10-06 15:17:34366 const gfx::Rect& rect) = 0;
367
[email protected]7d2d08152011-10-25 22:58:47368 // Shows the avatar bubble on the window frame off of the avatar button.
369 virtual void ShowAvatarBubbleFromAvatarButton() = 0;
370
[email protected]4d5ef8692012-05-31 02:28:57371 // Show bubble for password generation positioned relative to |rect|. |form|
372 // is the form that contains the password field that the bubble will be
373 // associated with. A stub implementation is provided since this feature is
374 // currently not available on mac.
375 virtual void ShowPasswordGenerationBubble(
376 const gfx::Rect& rect,
377 const webkit::forms::PasswordForm& form) {}
[email protected]90ee09232012-03-21 02:01:01378
[email protected]69b04b92010-11-08 22:12:18379 protected:
[email protected]2e6389f2012-05-18 19:41:25380 friend void browser::CloseAllBrowsers();
[email protected]69b04b92010-11-08 22:12:18381 friend class BrowserView;
382 virtual void DestroyBrowser() = 0;
[email protected]69b04b92010-11-08 22:12:18383};
384
385#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
386class BookmarkBarView;
387class LocationBarView;
388
389namespace views {
390class View;
391}
392#endif // defined(OS_WIN)
393
394// A BrowserWindow utility interface used for accessing elements of the browser
395// UI used only by UI test automation.
396class BrowserWindowTesting {
397 public:
398#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
399 // Returns the BookmarkBarView.
400 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
401
402 // Returns the LocationBarView.
403 virtual LocationBarView* GetLocationBarView() const = 0;
404
405 // Returns the TabContentsContainer.
406 virtual views::View* GetTabContentsContainerView() const = 0;
407
[email protected]69b04b92010-11-08 22:12:18408 // Returns the ToolbarView.
409 virtual ToolbarView* GetToolbarView() const = 0;
410#endif
411
412 protected:
413 virtual ~BrowserWindowTesting() {}
414};
415
416#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_