blob: ac6b9200a5c0f526e3b156f68eaef1fd3dc7ad54 [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]6f80e932012-06-04 19:00:0715#include "chrome/browser/ui/zoom/zoom_controller.h"
[email protected]69b04b92010-11-08 22:12:1816#include "chrome/common/content_settings_types.h"
[email protected]08397d52011-02-05 01:53:3817#include "ui/gfx/native_widget_types.h"
[email protected]588300d2011-04-28 21:06:3518#include "webkit/glue/window_open_disposition.h"
[email protected]69b04b92010-11-08 22:12:1819
20class Browser;
21class BrowserWindowTesting;
22class DownloadShelf;
23class FindBar;
24class GURL;
[email protected]69b04b92010-11-08 22:12:1825class LocationBar;
26class Profile;
27class StatusBubble;
[email protected]c36a9e1d2012-06-05 14:31:0228class TabContents;
29typedef TabContents TabContentsWrapper;
[email protected]69b04b92010-11-08 22:12:1830class TemplateURL;
[email protected]69b04b92010-11-08 22:12:1831#if !defined(OS_MACOSX)
32class ToolbarView;
33#endif
[email protected]69b04b92010-11-08 22:12:1834
[email protected]e0f90fc2012-06-06 19:30:1035namespace autofill {
36class PasswordGenerator;
37}
[email protected]ea049a02011-12-25 21:37:0938namespace content {
39class WebContents;
[email protected]b87ee522012-05-18 15:16:5440struct NativeWebKeyboardEvent;
[email protected]d583e3f22011-12-27 21:38:1741struct SSLStatus;
[email protected]ea049a02011-12-25 21:37:0942}
43
[email protected]1c321ee2012-05-21 03:02:3444namespace extensions {
45class Extension;
46}
47
[email protected]69b04b92010-11-08 22:12:1848namespace gfx {
49class Rect;
[email protected]0548c5352011-09-07 00:33:3350class Size;
[email protected]69b04b92010-11-08 22:12:1851}
52
[email protected]4d5ef8692012-05-31 02:28:5753namespace webkit {
54namespace forms {
55struct PasswordForm;
56}
57}
[email protected]a3b734b2010-11-30 03:17:1158
[email protected]853e16eb2011-12-29 16:58:1959enum DevToolsDockSide {
60 DEVTOOLS_DOCK_SIDE_BOTTOM = 0,
61 DEVTOOLS_DOCK_SIDE_RIGHT = 1
62};
63
[email protected]69b04b92010-11-08 22:12:1864////////////////////////////////////////////////////////////////////////////////
65// BrowserWindow interface
66// An interface implemented by the "view" of the Browser window.
[email protected]41d9faf2012-02-28 23:46:0267// This interface includes BaseWindow methods as well as Browser window
68// specific methods.
[email protected]69b04b92010-11-08 22:12:1869//
70// NOTE: All getters may return NULL.
[email protected]41d9faf2012-02-28 23:46:0271//
72class BrowserWindow : public BaseWindow {
[email protected]69b04b92010-11-08 22:12:1873 public:
[email protected]ed2f27132011-04-04 17:19:5774 virtual ~BrowserWindow() {}
75
[email protected]41d9faf2012-02-28 23:46:0276 //////////////////////////////////////////////////////////////////////////////
77 // BaseWindow interface notes:
[email protected]69b04b92010-11-08 22:12:1878
[email protected]41d9faf2012-02-28 23:46:0279 // Closes the window as soon as possible. If the window is not in a drag
[email protected]69b04b92010-11-08 22:12:1880 // session, it will close immediately; otherwise, it will move offscreen (so
81 // events are still fired) until the drag ends, then close. This assumes
82 // that the Browser is not immediately destroyed, but will be eventually
83 // destroyed by other means (eg, the tab strip going to zero elements).
84 // Bad things happen if the Browser dtor is called directly as a result of
85 // invoking this method.
[email protected]41d9faf2012-02-28 23:46:0286 // virtual void Close() = 0;
[email protected]69b04b92010-11-08 22:12:1887
[email protected]41d9faf2012-02-28 23:46:0288 // Browser::OnWindowDidShow should be called after showing the window.
89 // virtual void Show() = 0;
[email protected]69b04b92010-11-08 22:12:1890
[email protected]1443fe82012-04-02 08:48:0391 // No BrowserWindow supports this BaseWindow function.
92 virtual void SetDraggableRegion(SkRegion* region) OVERRIDE {}
93
[email protected]41d9faf2012-02-28 23:46:0294 //////////////////////////////////////////////////////////////////////////////
95 // Browser specific methods:
[email protected]69b04b92010-11-08 22:12:1896
97 // Return a platform dependent identifier for this frame. On Windows, this
98 // returns an HWND.
99 virtual gfx::NativeWindow GetNativeHandle() = 0;
100
101 // Returns a pointer to the testing interface to the Browser window, or NULL
102 // if there is none.
103 virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0;
104
105 // Return the status bubble associated with the frame
106 virtual StatusBubble* GetStatusBubble() = 0;
107
108 // Inform the receiving frame that an animation has progressed in the
109 // selected tab.
110 // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to
111 // BrowserView.
[email protected]c9bd2e82011-04-15 23:28:19112 virtual void ToolbarSizeChanged(bool is_animating) = 0;
[email protected]69b04b92010-11-08 22:12:18113
114 // Inform the frame that the selected tab favicon or title has changed. Some
115 // frames may need to refresh their title bar.
116 virtual void UpdateTitleBar() = 0;
117
[email protected]09b29342011-06-24 19:18:48118 // Invoked when the state of the bookmark bar changes. This is only invoked if
119 // the state changes for the current tab, it is not sent when switching tabs.
120 virtual void BookmarkBarStateChanged(
121 BookmarkBar::AnimateChangeType change_type) = 0;
[email protected]69b04b92010-11-08 22:12:18122
123 // Inform the frame that the dev tools window for the selected tab has
124 // changed.
125 virtual void UpdateDevTools() = 0;
126
[email protected]853e16eb2011-12-29 16:58:19127 // Requests that the docked dev tools window changes its dock mode.
128 virtual void SetDevToolsDockSide(DevToolsDockSide side) = 0;
129
[email protected]69b04b92010-11-08 22:12:18130 // Update any loading animations running in the window. |should_animate| is
131 // true if there are tabs loading and the animations should continue, false
132 // if there are no active loads and the animations should end.
133 virtual void UpdateLoadingAnimations(bool should_animate) = 0;
134
135 // Sets the starred state for the current tab.
136 virtual void SetStarredState(bool is_starred) = 0;
137
[email protected]6f80e932012-06-04 19:00:07138 // Sets the zoom icon state for the current tab.
139 virtual void SetZoomIconState(ZoomController::ZoomIconState state) = 0;
140
141 // Sets the zoom icon tooltip zoom percentage for the current tab.
142 virtual void SetZoomIconTooltipPercent(int zoom_percent) = 0;
143
144 // Show zoom bubble for the current tab.
145 virtual void ShowZoomBubble(int zoom_percent) = 0;
146
[email protected]69b04b92010-11-08 22:12:18147 // Accessors for fullscreen mode state.
[email protected]8d944b32011-10-17 06:11:53148 virtual void EnterFullscreen(const GURL& url,
149 FullscreenExitBubbleType bubble_type) = 0;
[email protected]55c87fa2011-10-15 07:28:28150 virtual void ExitFullscreen() = 0;
[email protected]8d944b32011-10-17 06:11:53151 virtual void UpdateFullscreenExitBubbleContent(
152 const GURL& url,
153 FullscreenExitBubbleType bubble_type) = 0;
[email protected]69b04b92010-11-08 22:12:18154
155 // Returns true if the fullscreen bubble is visible.
156 virtual bool IsFullscreenBubbleVisible() const = 0;
157
158 // Returns the location bar.
159 virtual LocationBar* GetLocationBar() const = 0;
160
161 // Tries to focus the location bar. Clears the window focus (to avoid
162 // inconsistent state) if this fails.
163 virtual void SetFocusToLocationBar(bool select_all) = 0;
164
165 // Informs the view whether or not a load is in progress for the current tab.
166 // The view can use this notification to update the reload/stop button.
167 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
168
169 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49170 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18171 bool should_restore_state) = 0;
172
173 // Focuses the toolbar (for accessibility).
174 virtual void FocusToolbar() = 0;
175
176 // Focuses the app menu like it was a menu bar.
177 //
178 // Not used on the Mac, which has a "normal" menu bar.
179 virtual void FocusAppMenu() = 0;
180
181 // Focuses the bookmarks toolbar (for accessibility).
182 virtual void FocusBookmarksToolbar() = 0;
183
[email protected]69b04b92010-11-08 22:12:18184 // Moves keyboard focus to the next pane.
185 virtual void RotatePaneFocus(bool forwards) = 0;
186
187 // Returns whether the bookmark bar is visible or not.
188 virtual bool IsBookmarkBarVisible() const = 0;
189
190 // Returns whether the bookmark bar is animating or not.
191 virtual bool IsBookmarkBarAnimating() const = 0;
192
[email protected]95bf8a5b2010-12-22 16:04:07193 // Returns whether the tab strip is editable (for extensions).
194 virtual bool IsTabStripEditable() const = 0;
195
[email protected]69b04b92010-11-08 22:12:18196 // Returns whether the tool bar is visible or not.
197 virtual bool IsToolbarVisible() const = 0;
198
[email protected]b7a756d42012-01-23 18:08:17199 // Returns the rect where the resize corner should be drawn by the render
200 // widget host view (on top of what the renderer returns). We return an empty
201 // rect to identify that there shouldn't be a resize corner (in the cases
202 // where we take care of it ourselves at the browser level).
203 virtual gfx::Rect GetRootWindowResizerRect() const = 0;
204
[email protected]5f58c2af2012-01-11 17:55:29205 // Returns whether the window is a panel. This is not always synonomous
206 // with the associated browser having type panel since some environments
207 // may draw popups in panel windows.
208 virtual bool IsPanel() const = 0;
209
[email protected]69b04b92010-11-08 22:12:18210 // Tells the frame not to render as inactive until the next activation change.
211 // This is required on Windows when dropdown selects are shown to prevent the
212 // select from deactivating the browser frame. A stub implementation is
213 // provided here since the functionality is Windows-specific.
214 virtual void DisableInactiveFrame() {}
215
[email protected]69b04b92010-11-08 22:12:18216 // Shows a confirmation dialog box for adding a search engine described by
217 // |template_url|. Takes ownership of |template_url|.
[email protected]3613347d2012-04-27 20:27:37218 virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
[email protected]69b04b92010-11-08 22:12:18219 Profile* profile) = 0;
220
221 // Shows or hides the bookmark bar depending on its current visibility.
222 virtual void ToggleBookmarkBar() = 0;
223
224 // Shows the About Chrome dialog box.
[email protected]4c6b474b72011-02-24 21:35:21225 virtual void ShowAboutChromeDialog() = 0;
[email protected]69b04b92010-11-08 22:12:18226
227 // Shows the Update Recommended dialog box.
228 virtual void ShowUpdateChromeDialog() = 0;
229
230 // Shows the Task manager.
231 virtual void ShowTaskManager() = 0;
232
[email protected]adb6a84d2011-02-07 16:58:40233 // Shows task information related to background pages.
234 virtual void ShowBackgroundPages() = 0;
235
[email protected]69b04b92010-11-08 22:12:18236 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
237 // |already_bookmarked| is true if the url is already bookmarked.
238 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
239
[email protected]b106ca52012-03-13 06:08:46240 // Shows the Chrome To Mobile bubble.
241 virtual void ShowChromeToMobileBubble() = 0;
242
[email protected]235a0562012-03-26 22:22:35243#if defined(ENABLE_ONE_CLICK_SIGNIN)
[email protected]e4b66bf2012-05-29 20:39:51244 // Callback type used with the ShowOneClickSigninBubble() method. If the
245 // user chooses to accept the sign in, the callback is called to start the
246 // sync process.
247 typedef base::Callback<void(OneClickSigninSyncStarter::StartSyncMode)>
248 StartSyncCallback;
249
250 // Shows the one-click sign in bubble.
[email protected]fe54b4a2012-03-28 16:11:04251 virtual void ShowOneClickSigninBubble(
[email protected]e4b66bf2012-05-29 20:39:51252 const StartSyncCallback& start_sync_callback) = 0;
[email protected]235a0562012-03-26 22:22:35253#endif
254
[email protected]69b04b92010-11-08 22:12:18255 // Whether or not the shelf view is visible.
256 virtual bool IsDownloadShelfVisible() const = 0;
257
258 // Returns the DownloadShelf.
259 virtual DownloadShelf* GetDownloadShelf() = 0;
260
[email protected]69b04b92010-11-08 22:12:18261 // Shows the confirmation dialog box warning that the browser is closing with
262 // in-progress downloads.
263 // This method should call Browser::InProgressDownloadResponse once the user
264 // has confirmed.
265 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
266
[email protected]a0ea76c2011-03-23 17:36:42267 // ThemeService calls this when a user has changed his or her theme,
[email protected]69b04b92010-11-08 22:12:18268 // indicating that it's time to redraw everything.
269 virtual void UserChangedTheme() = 0;
270
271 // Get extra vertical height that the render view should add to its requests
272 // to webkit. This can help prevent sending extraneous layout/repaint requests
273 // when the delegate is in the process of resizing the tab contents view (e.g.
274 // during infobar animations).
275 virtual int GetExtraRenderViewHeight() const = 0;
276
[email protected]2a6bc3e2011-12-28 23:51:33277 // Notification that |contents| got the focus through user action (click
[email protected]69b04b92010-11-08 22:12:18278 // on the page).
[email protected]2a6bc3e2011-12-28 23:51:33279 virtual void WebContentsFocused(content::WebContents* contents) = 0;
[email protected]69b04b92010-11-08 22:12:18280
281 // Shows the page info using the specified information.
282 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
283 // information for that page/frame. If |show_history| is true, a section
284 // showing how many times that URL has been visited is added to the page info.
285 virtual void ShowPageInfo(Profile* profile,
286 const GURL& url,
[email protected]d583e3f22011-12-27 21:38:17287 const content::SSLStatus& ssl,
[email protected]69b04b92010-11-08 22:12:18288 bool show_history) = 0;
289
[email protected]b8e681e82012-02-20 10:18:47290 // Shows the website settings using the specified information. |url| is the
291 // url of the page/frame the info applies to, |ssl| is the SSL information for
292 // that page/frame. If |show_history| is true, a section showing how many
293 // times that URL has been visited is added to the page info.
294 virtual void ShowWebsiteSettings(Profile* profile,
295 TabContentsWrapper* tab_contents_wrapper,
296 const GURL& url,
297 const content::SSLStatus& ssl,
298 bool show_history) = 0;
299
[email protected]69b04b92010-11-08 22:12:18300 // Shows the app menu (for accessibility).
301 virtual void ShowAppMenu() = 0;
302
303 // Allows the BrowserWindow object to handle the specified keyboard event
304 // before sending it to the renderer.
305 // Returns true if the |event| was handled. Otherwise, if the |event| would
306 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
307 // |*is_keyboard_shortcut| should be set to true.
[email protected]b87ee522012-05-18 15:16:54308 virtual bool PreHandleKeyboardEvent(
309 const content::NativeWebKeyboardEvent& event,
310 bool* is_keyboard_shortcut) = 0;
[email protected]69b04b92010-11-08 22:12:18311
312 // Allows the BrowserWindow object to handle the specified keyboard event,
313 // if the renderer did not process it.
[email protected]b87ee522012-05-18 15:16:54314 virtual void HandleKeyboardEvent(
315 const content::NativeWebKeyboardEvent& event) = 0;
[email protected]69b04b92010-11-08 22:12:18316
317 // Shows the create web app shortcut dialog box.
[email protected]f847e6082011-03-24 00:08:26318 virtual void ShowCreateWebAppShortcutsDialog(
319 TabContentsWrapper* tab_contents) = 0;
[email protected]a3b734b2010-11-30 03:17:11320
321 // Shows the create chrome app shortcut dialog box.
322 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
[email protected]1c321ee2012-05-21 03:02:34323 const extensions::Extension* app) = 0;
324
[email protected]69b04b92010-11-08 22:12:18325
326 // Clipboard commands applied to the whole browser window.
327 virtual void Cut() = 0;
328 virtual void Copy() = 0;
329 virtual void Paste() = 0;
330
[email protected]69b04b92010-11-08 22:12:18331#if defined(OS_MACOSX)
332 // Opens the tabpose view.
333 virtual void OpenTabpose() = 0;
[email protected]d3766932011-08-04 22:18:23334
335 // Sets the presentation mode for the window. If the window is not already in
336 // fullscreen, also enters fullscreen mode.
[email protected]8d944b32011-10-17 06:11:53337 virtual void EnterPresentationMode(
338 const GURL& url,
339 FullscreenExitBubbleType bubble_type) = 0;
340 virtual void ExitPresentationMode() = 0;
[email protected]d3766932011-08-04 22:18:23341 virtual bool InPresentationMode() = 0;
[email protected]69b04b92010-11-08 22:12:18342#endif
343
[email protected]69b04b92010-11-08 22:12:18344 // Invoked when instant's tab contents should be shown.
[email protected]e3690ed2011-03-25 20:25:14345 virtual void ShowInstant(TabContentsWrapper* preview) = 0;
[email protected]69b04b92010-11-08 22:12:18346
347 // Invoked when the instant's tab contents should be hidden.
[email protected]3e481282011-10-15 15:39:50348 virtual void HideInstant() = 0;
[email protected]69b04b92010-11-08 22:12:18349
350 // Returns the desired bounds for instant in screen coordinates. Note that if
351 // instant isn't currently visible this returns the bounds instant would be
352 // placed at.
353 virtual gfx::Rect GetInstantBounds() = 0;
354
[email protected]588300d2011-04-28 21:06:35355 // Return the correct disposition for a popup window based on |bounds|.
356 virtual WindowOpenDisposition GetDispositionForPopupBounds(
357 const gfx::Rect& bounds) = 0;
358
[email protected]632983f2011-08-08 22:51:24359 // Construct a FindBar implementation for the |browser|.
360 virtual FindBar* CreateFindBar() = 0;
361
[email protected]0548c5352011-09-07 00:33:33362 // Invoked when the preferred size of the contents in current tab has been
363 // changed. We might choose to update the window size to accomodate this
364 // change.
365 // Note that this won't be fired if we change tabs.
[email protected]2a6bc3e2011-12-28 23:51:33366 virtual void UpdatePreferredSize(content::WebContents* web_contents,
[email protected]0548c5352011-09-07 00:33:33367 const gfx::Size& pref_size) {}
368
[email protected]61e2b3cc2012-03-02 16:13:34369 // Invoked when the contents auto-resized and the container should match it.
370 virtual void ResizeDueToAutoResize(content::WebContents* web_contents,
371 const gfx::Size& new_size) {}
372
[email protected]69b04b92010-11-08 22:12:18373 // Construct a BrowserWindow implementation for the specified |browser|.
374 static BrowserWindow* CreateBrowserWindow(Browser* browser);
375
[email protected]0ec4898e2011-12-30 21:09:24376 // Shows the avatar bubble inside |web_contents|. The bubble is positioned
377 // relative to |rect|. |rect| should be in the |web_contents| coordinate
[email protected]2f733a02011-10-06 15:17:34378 // system.
[email protected]0ec4898e2011-12-30 21:09:24379 virtual void ShowAvatarBubble(content::WebContents* web_contents,
[email protected]2f733a02011-10-06 15:17:34380 const gfx::Rect& rect) = 0;
381
[email protected]7d2d08152011-10-25 22:58:47382 // Shows the avatar bubble on the window frame off of the avatar button.
383 virtual void ShowAvatarBubbleFromAvatarButton() = 0;
384
[email protected]e0f90fc2012-06-06 19:30:10385 // Show bubble for password generation positioned relative to |rect|. The
386 // subclasses implementing this interface do not own the |password_generator|
387 // object which is passed to generate the password. |form| is the form that
388 // contains the password field that the bubble will be associated with. A
389 // stub implementation is provided since this feature is currently not
390 // available on mac.
[email protected]4d5ef8692012-05-31 02:28:57391 virtual void ShowPasswordGenerationBubble(
392 const gfx::Rect& rect,
[email protected]e0f90fc2012-06-06 19:30:10393 autofill::PasswordGenerator* password_generator,
[email protected]4d5ef8692012-05-31 02:28:57394 const webkit::forms::PasswordForm& form) {}
[email protected]90ee09232012-03-21 02:01:01395
[email protected]69b04b92010-11-08 22:12:18396 protected:
[email protected]2e6389f2012-05-18 19:41:25397 friend void browser::CloseAllBrowsers();
[email protected]69b04b92010-11-08 22:12:18398 friend class BrowserView;
399 virtual void DestroyBrowser() = 0;
[email protected]69b04b92010-11-08 22:12:18400};
401
402#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
403class BookmarkBarView;
404class LocationBarView;
405
406namespace views {
407class View;
408}
409#endif // defined(OS_WIN)
410
411// A BrowserWindow utility interface used for accessing elements of the browser
412// UI used only by UI test automation.
413class BrowserWindowTesting {
414 public:
415#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
416 // Returns the BookmarkBarView.
417 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
418
419 // Returns the LocationBarView.
420 virtual LocationBarView* GetLocationBarView() const = 0;
421
422 // Returns the TabContentsContainer.
423 virtual views::View* GetTabContentsContainerView() const = 0;
424
[email protected]69b04b92010-11-08 22:12:18425 // Returns the ToolbarView.
426 virtual ToolbarView* GetToolbarView() const = 0;
427#endif
428
429 protected:
430 virtual ~BrowserWindowTesting() {}
431};
432
433#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_