blob: 1f69c6acd740a9d76137d44f494cab2ea38151fa [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]41d9faf2012-02-28 23:46:029#include "chrome/browser/ui/base_window.h"
[email protected]09b29342011-06-24 19:18:4810#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
[email protected]8d944b32011-10-17 06:11:5311#include "chrome/browser/ui/fullscreen_exit_bubble_type.h"
[email protected]69b04b92010-11-08 22:12:1812#include "chrome/common/content_settings_types.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;
[email protected]69b04b92010-11-08 22:12:1821class LocationBar;
22class Profile;
23class StatusBubble;
[email protected]3c9e1872010-11-18 16:17:4924class TabContentsWrapper;
[email protected]69b04b92010-11-08 22:12:1825class TemplateURL;
[email protected]69b04b92010-11-08 22:12:1826#if !defined(OS_MACOSX)
27class ToolbarView;
28#endif
29struct NativeWebKeyboardEvent;
30
[email protected]ea049a02011-12-25 21:37:0931namespace content {
32class WebContents;
[email protected]d583e3f22011-12-27 21:38:1733struct SSLStatus;
[email protected]ea049a02011-12-25 21:37:0934}
35
[email protected]69b04b92010-11-08 22:12:1836namespace gfx {
37class Rect;
[email protected]0548c5352011-09-07 00:33:3338class Size;
[email protected]69b04b92010-11-08 22:12:1839}
40
[email protected]a3b734b2010-11-30 03:17:1141class Extension;
42
[email protected]853e16eb2011-12-29 16:58:1943enum DevToolsDockSide {
44 DEVTOOLS_DOCK_SIDE_BOTTOM = 0,
45 DEVTOOLS_DOCK_SIDE_RIGHT = 1
46};
47
[email protected]69b04b92010-11-08 22:12:1848////////////////////////////////////////////////////////////////////////////////
49// BrowserWindow interface
50// An interface implemented by the "view" of the Browser window.
[email protected]41d9faf2012-02-28 23:46:0251// This interface includes BaseWindow methods as well as Browser window
52// specific methods.
[email protected]69b04b92010-11-08 22:12:1853//
54// NOTE: All getters may return NULL.
[email protected]41d9faf2012-02-28 23:46:0255//
56class BrowserWindow : public BaseWindow {
[email protected]69b04b92010-11-08 22:12:1857 public:
[email protected]ed2f27132011-04-04 17:19:5758 virtual ~BrowserWindow() {}
59
[email protected]41d9faf2012-02-28 23:46:0260 //////////////////////////////////////////////////////////////////////////////
61 // BaseWindow interface notes:
[email protected]69b04b92010-11-08 22:12:1862
[email protected]41d9faf2012-02-28 23:46:0263 // Closes the window as soon as possible. If the window is not in a drag
[email protected]69b04b92010-11-08 22:12:1864 // session, it will close immediately; otherwise, it will move offscreen (so
65 // events are still fired) until the drag ends, then close. This assumes
66 // that the Browser is not immediately destroyed, but will be eventually
67 // destroyed by other means (eg, the tab strip going to zero elements).
68 // Bad things happen if the Browser dtor is called directly as a result of
69 // invoking this method.
[email protected]41d9faf2012-02-28 23:46:0270 // virtual void Close() = 0;
[email protected]69b04b92010-11-08 22:12:1871
[email protected]41d9faf2012-02-28 23:46:0272 // Browser::OnWindowDidShow should be called after showing the window.
73 // virtual void Show() = 0;
[email protected]69b04b92010-11-08 22:12:1874
[email protected]41d9faf2012-02-28 23:46:0275 //////////////////////////////////////////////////////////////////////////////
76 // Browser specific methods:
[email protected]69b04b92010-11-08 22:12:1877
78 // Return a platform dependent identifier for this frame. On Windows, this
79 // returns an HWND.
80 virtual gfx::NativeWindow GetNativeHandle() = 0;
81
82 // Returns a pointer to the testing interface to the Browser window, or NULL
83 // if there is none.
84 virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0;
85
86 // Return the status bubble associated with the frame
87 virtual StatusBubble* GetStatusBubble() = 0;
88
89 // Inform the receiving frame that an animation has progressed in the
90 // selected tab.
91 // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to
92 // BrowserView.
[email protected]c9bd2e82011-04-15 23:28:1993 virtual void ToolbarSizeChanged(bool is_animating) = 0;
[email protected]69b04b92010-11-08 22:12:1894
95 // Inform the frame that the selected tab favicon or title has changed. Some
96 // frames may need to refresh their title bar.
97 virtual void UpdateTitleBar() = 0;
98
[email protected]09b29342011-06-24 19:18:4899 // Invoked when the state of the bookmark bar changes. This is only invoked if
100 // the state changes for the current tab, it is not sent when switching tabs.
101 virtual void BookmarkBarStateChanged(
102 BookmarkBar::AnimateChangeType change_type) = 0;
[email protected]69b04b92010-11-08 22:12:18103
104 // Inform the frame that the dev tools window for the selected tab has
105 // changed.
106 virtual void UpdateDevTools() = 0;
107
[email protected]853e16eb2011-12-29 16:58:19108 // Requests that the docked dev tools window changes its dock mode.
109 virtual void SetDevToolsDockSide(DevToolsDockSide side) = 0;
110
[email protected]69b04b92010-11-08 22:12:18111 // Update any loading animations running in the window. |should_animate| is
112 // true if there are tabs loading and the animations should continue, false
113 // if there are no active loads and the animations should end.
114 virtual void UpdateLoadingAnimations(bool should_animate) = 0;
115
116 // Sets the starred state for the current tab.
117 virtual void SetStarredState(bool is_starred) = 0;
118
[email protected]69b04b92010-11-08 22:12:18119 // Accessors for fullscreen mode state.
[email protected]8d944b32011-10-17 06:11:53120 virtual void EnterFullscreen(const GURL& url,
121 FullscreenExitBubbleType bubble_type) = 0;
[email protected]55c87fa2011-10-15 07:28:28122 virtual void ExitFullscreen() = 0;
[email protected]8d944b32011-10-17 06:11:53123 virtual void UpdateFullscreenExitBubbleContent(
124 const GURL& url,
125 FullscreenExitBubbleType bubble_type) = 0;
[email protected]69b04b92010-11-08 22:12:18126 virtual bool IsFullscreen() const = 0;
127
128 // Returns true if the fullscreen bubble is visible.
129 virtual bool IsFullscreenBubbleVisible() const = 0;
130
131 // Returns the location bar.
132 virtual LocationBar* GetLocationBar() const = 0;
133
134 // Tries to focus the location bar. Clears the window focus (to avoid
135 // inconsistent state) if this fails.
136 virtual void SetFocusToLocationBar(bool select_all) = 0;
137
138 // Informs the view whether or not a load is in progress for the current tab.
139 // The view can use this notification to update the reload/stop button.
140 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
141
142 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49143 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18144 bool should_restore_state) = 0;
145
146 // Focuses the toolbar (for accessibility).
147 virtual void FocusToolbar() = 0;
148
149 // Focuses the app menu like it was a menu bar.
150 //
151 // Not used on the Mac, which has a "normal" menu bar.
152 virtual void FocusAppMenu() = 0;
153
154 // Focuses the bookmarks toolbar (for accessibility).
155 virtual void FocusBookmarksToolbar() = 0;
156
157 // Focuses the Chrome OS status view (for accessibility).
158 virtual void FocusChromeOSStatus() = 0;
159
160 // Moves keyboard focus to the next pane.
161 virtual void RotatePaneFocus(bool forwards) = 0;
162
163 // Returns whether the bookmark bar is visible or not.
164 virtual bool IsBookmarkBarVisible() const = 0;
165
166 // Returns whether the bookmark bar is animating or not.
167 virtual bool IsBookmarkBarAnimating() const = 0;
168
[email protected]95bf8a5b2010-12-22 16:04:07169 // Returns whether the tab strip is editable (for extensions).
170 virtual bool IsTabStripEditable() const = 0;
171
[email protected]69b04b92010-11-08 22:12:18172 // Returns whether the tool bar is visible or not.
173 virtual bool IsToolbarVisible() const = 0;
174
[email protected]b7a756d42012-01-23 18:08:17175 // Returns the rect where the resize corner should be drawn by the render
176 // widget host view (on top of what the renderer returns). We return an empty
177 // rect to identify that there shouldn't be a resize corner (in the cases
178 // where we take care of it ourselves at the browser level).
179 virtual gfx::Rect GetRootWindowResizerRect() const = 0;
180
[email protected]5f58c2af2012-01-11 17:55:29181 // Returns whether the window is a panel. This is not always synonomous
182 // with the associated browser having type panel since some environments
183 // may draw popups in panel windows.
184 virtual bool IsPanel() const = 0;
185
[email protected]69b04b92010-11-08 22:12:18186 // Tells the frame not to render as inactive until the next activation change.
187 // This is required on Windows when dropdown selects are shown to prevent the
188 // select from deactivating the browser frame. A stub implementation is
189 // provided here since the functionality is Windows-specific.
190 virtual void DisableInactiveFrame() {}
191
[email protected]69b04b92010-11-08 22:12:18192 // Shows a confirmation dialog box for adding a search engine described by
193 // |template_url|. Takes ownership of |template_url|.
194 virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
195 Profile* profile) = 0;
196
197 // Shows or hides the bookmark bar depending on its current visibility.
198 virtual void ToggleBookmarkBar() = 0;
199
200 // Shows the About Chrome dialog box.
[email protected]4c6b474b72011-02-24 21:35:21201 virtual void ShowAboutChromeDialog() = 0;
[email protected]69b04b92010-11-08 22:12:18202
203 // Shows the Update Recommended dialog box.
204 virtual void ShowUpdateChromeDialog() = 0;
205
206 // Shows the Task manager.
207 virtual void ShowTaskManager() = 0;
208
[email protected]adb6a84d2011-02-07 16:58:40209 // Shows task information related to background pages.
210 virtual void ShowBackgroundPages() = 0;
211
[email protected]69b04b92010-11-08 22:12:18212 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
213 // |already_bookmarked| is true if the url is already bookmarked.
214 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
215
[email protected]b106ca52012-03-13 06:08:46216 // Shows the Chrome To Mobile bubble.
217 virtual void ShowChromeToMobileBubble() = 0;
218
[email protected]235a0562012-03-26 22:22:35219#if defined(ENABLE_ONE_CLICK_SIGNIN)
220 // Shows the one-click sign in bubble.
221 virtual void ShowOneClickSigninBubble() = 0;
222#endif
223
[email protected]69b04b92010-11-08 22:12:18224 // 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 confirmation dialog box warning that the browser is closing with
231 // in-progress downloads.
232 // This method should call Browser::InProgressDownloadResponse once the user
233 // has confirmed.
234 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
235
[email protected]a0ea76c2011-03-23 17:36:42236 // ThemeService calls this when a user has changed his or her theme,
[email protected]69b04b92010-11-08 22:12:18237 // indicating that it's time to redraw everything.
238 virtual void UserChangedTheme() = 0;
239
240 // Get extra vertical height that the render view should add to its requests
241 // to webkit. This can help prevent sending extraneous layout/repaint requests
242 // when the delegate is in the process of resizing the tab contents view (e.g.
243 // during infobar animations).
244 virtual int GetExtraRenderViewHeight() const = 0;
245
[email protected]2a6bc3e2011-12-28 23:51:33246 // Notification that |contents| got the focus through user action (click
[email protected]69b04b92010-11-08 22:12:18247 // on the page).
[email protected]2a6bc3e2011-12-28 23:51:33248 virtual void WebContentsFocused(content::WebContents* contents) = 0;
[email protected]69b04b92010-11-08 22:12:18249
250 // Shows the page info using the specified information.
251 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
252 // information for that page/frame. If |show_history| is true, a section
253 // showing how many times that URL has been visited is added to the page info.
254 virtual void ShowPageInfo(Profile* profile,
255 const GURL& url,
[email protected]d583e3f22011-12-27 21:38:17256 const content::SSLStatus& ssl,
[email protected]69b04b92010-11-08 22:12:18257 bool show_history) = 0;
258
[email protected]b8e681e82012-02-20 10:18:47259 // Shows the website settings using the specified information. |url| is the
260 // url of the page/frame the info applies to, |ssl| is the SSL information for
261 // that page/frame. If |show_history| is true, a section showing how many
262 // times that URL has been visited is added to the page info.
263 virtual void ShowWebsiteSettings(Profile* profile,
264 TabContentsWrapper* tab_contents_wrapper,
265 const GURL& url,
266 const content::SSLStatus& ssl,
267 bool show_history) = 0;
268
[email protected]69b04b92010-11-08 22:12:18269 // Shows the app menu (for accessibility).
270 virtual void ShowAppMenu() = 0;
271
272 // Allows the BrowserWindow object to handle the specified keyboard event
273 // before sending it to the renderer.
274 // Returns true if the |event| was handled. Otherwise, if the |event| would
275 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
276 // |*is_keyboard_shortcut| should be set to true.
277 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
278 bool* is_keyboard_shortcut) = 0;
279
280 // Allows the BrowserWindow object to handle the specified keyboard event,
281 // if the renderer did not process it.
282 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
283
284 // Shows the create web app shortcut dialog box.
[email protected]f847e6082011-03-24 00:08:26285 virtual void ShowCreateWebAppShortcutsDialog(
286 TabContentsWrapper* tab_contents) = 0;
[email protected]a3b734b2010-11-30 03:17:11287
288 // Shows the create chrome app shortcut dialog box.
289 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
290 const Extension* app) = 0;
[email protected]69b04b92010-11-08 22:12:18291
292 // Clipboard commands applied to the whole browser window.
293 virtual void Cut() = 0;
294 virtual void Copy() = 0;
295 virtual void Paste() = 0;
296
[email protected]69b04b92010-11-08 22:12:18297#if defined(OS_MACOSX)
298 // Opens the tabpose view.
299 virtual void OpenTabpose() = 0;
[email protected]d3766932011-08-04 22:18:23300
301 // Sets the presentation mode for the window. If the window is not already in
302 // fullscreen, also enters fullscreen mode.
[email protected]8d944b32011-10-17 06:11:53303 virtual void EnterPresentationMode(
304 const GURL& url,
305 FullscreenExitBubbleType bubble_type) = 0;
306 virtual void ExitPresentationMode() = 0;
[email protected]d3766932011-08-04 22:18:23307 virtual bool InPresentationMode() = 0;
[email protected]69b04b92010-11-08 22:12:18308#endif
309
[email protected]69b04b92010-11-08 22:12:18310 // Invoked when instant's tab contents should be shown.
[email protected]e3690ed2011-03-25 20:25:14311 virtual void ShowInstant(TabContentsWrapper* preview) = 0;
[email protected]69b04b92010-11-08 22:12:18312
313 // Invoked when the instant's tab contents should be hidden.
[email protected]3e481282011-10-15 15:39:50314 virtual void HideInstant() = 0;
[email protected]69b04b92010-11-08 22:12:18315
316 // Returns the desired bounds for instant in screen coordinates. Note that if
317 // instant isn't currently visible this returns the bounds instant would be
318 // placed at.
319 virtual gfx::Rect GetInstantBounds() = 0;
320
[email protected]588300d2011-04-28 21:06:35321 // Return the correct disposition for a popup window based on |bounds|.
322 virtual WindowOpenDisposition GetDispositionForPopupBounds(
323 const gfx::Rect& bounds) = 0;
324
[email protected]632983f2011-08-08 22:51:24325 // Construct a FindBar implementation for the |browser|.
326 virtual FindBar* CreateFindBar() = 0;
327
[email protected]d14af522010-12-02 03:54:50328#if defined(OS_CHROMEOS)
[email protected]e7137b2c2011-10-24 20:16:55329 // Shows the mobile setup dialog.
330 virtual void ShowMobileSetup() = 0;
331
[email protected]d14af522010-12-02 03:54:50332 // Shows the keyboard overlay dialog box.
333 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) = 0;
334#endif
335
[email protected]0548c5352011-09-07 00:33:33336 // Invoked when the preferred size of the contents in current tab has been
337 // changed. We might choose to update the window size to accomodate this
338 // change.
339 // Note that this won't be fired if we change tabs.
[email protected]2a6bc3e2011-12-28 23:51:33340 virtual void UpdatePreferredSize(content::WebContents* web_contents,
[email protected]0548c5352011-09-07 00:33:33341 const gfx::Size& pref_size) {}
342
[email protected]61e2b3cc2012-03-02 16:13:34343 // Invoked when the contents auto-resized and the container should match it.
344 virtual void ResizeDueToAutoResize(content::WebContents* web_contents,
345 const gfx::Size& new_size) {}
346
[email protected]69b04b92010-11-08 22:12:18347 // Construct a BrowserWindow implementation for the specified |browser|.
348 static BrowserWindow* CreateBrowserWindow(Browser* browser);
349
[email protected]0ec4898e2011-12-30 21:09:24350 // Shows the avatar bubble inside |web_contents|. The bubble is positioned
351 // relative to |rect|. |rect| should be in the |web_contents| coordinate
[email protected]2f733a02011-10-06 15:17:34352 // system.
[email protected]0ec4898e2011-12-30 21:09:24353 virtual void ShowAvatarBubble(content::WebContents* web_contents,
[email protected]2f733a02011-10-06 15:17:34354 const gfx::Rect& rect) = 0;
355
[email protected]7d2d08152011-10-25 22:58:47356 // Shows the avatar bubble on the window frame off of the avatar button.
357 virtual void ShowAvatarBubbleFromAvatarButton() = 0;
358
[email protected]90ee09232012-03-21 02:01:01359 // Show bubble for password generation positioned relative to |rect|. A stub
360 // implementation is provided since this feature is currently only available
361 // for Windows.
362 virtual void ShowPasswordGenerationBubble(const gfx::Rect& rect) {}
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
[email protected]69b04b92010-11-08 22:12:18393 // Returns the ToolbarView.
394 virtual ToolbarView* GetToolbarView() const = 0;
395#endif
396
397 protected:
398 virtual ~BrowserWindowTesting() {}
399};
400
401#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_