blob: 3d3851bb2af7242ba1db7ceaa9af8640c4fd79db [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;
24class TabContents;
[email protected]3c9e1872010-11-18 16:17:4925class TabContentsWrapper;
[email protected]69b04b92010-11-08 22:12:1826class TemplateURL;
[email protected]69b04b92010-11-08 22:12:1827#if !defined(OS_MACOSX)
28class ToolbarView;
29#endif
30struct NativeWebKeyboardEvent;
31
[email protected]ea049a02011-12-25 21:37:0932namespace content {
33class WebContents;
[email protected]d583e3f22011-12-27 21:38:1734struct SSLStatus;
[email protected]ea049a02011-12-25 21:37:0935}
36
[email protected]69b04b92010-11-08 22:12:1837namespace gfx {
38class Rect;
[email protected]0548c5352011-09-07 00:33:3339class Size;
[email protected]69b04b92010-11-08 22:12:1840}
41
[email protected]a3b734b2010-11-30 03:17:1142class Extension;
43
[email protected]853e16eb2011-12-29 16:58:1944enum DevToolsDockSide {
45 DEVTOOLS_DOCK_SIDE_BOTTOM = 0,
46 DEVTOOLS_DOCK_SIDE_RIGHT = 1
47};
48
[email protected]69b04b92010-11-08 22:12:1849////////////////////////////////////////////////////////////////////////////////
50// BrowserWindow interface
51// An interface implemented by the "view" of the Browser window.
[email protected]41d9faf2012-02-28 23:46:0252// This interface includes BaseWindow methods as well as Browser window
53// specific methods.
[email protected]69b04b92010-11-08 22:12:1854//
55// NOTE: All getters may return NULL.
[email protected]41d9faf2012-02-28 23:46:0256//
57class BrowserWindow : public BaseWindow {
[email protected]69b04b92010-11-08 22:12:1858 public:
[email protected]ed2f27132011-04-04 17:19:5759 virtual ~BrowserWindow() {}
60
[email protected]41d9faf2012-02-28 23:46:0261 //////////////////////////////////////////////////////////////////////////////
62 // BaseWindow interface notes:
[email protected]69b04b92010-11-08 22:12:1863
[email protected]41d9faf2012-02-28 23:46:0264 // Closes the window as soon as possible. If the window is not in a drag
[email protected]69b04b92010-11-08 22:12:1865 // session, it will close immediately; otherwise, it will move offscreen (so
66 // events are still fired) until the drag ends, then close. This assumes
67 // that the Browser is not immediately destroyed, but will be eventually
68 // destroyed by other means (eg, the tab strip going to zero elements).
69 // Bad things happen if the Browser dtor is called directly as a result of
70 // invoking this method.
[email protected]41d9faf2012-02-28 23:46:0271 // virtual void Close() = 0;
[email protected]69b04b92010-11-08 22:12:1872
[email protected]41d9faf2012-02-28 23:46:0273 // Browser::OnWindowDidShow should be called after showing the window.
74 // virtual void Show() = 0;
[email protected]69b04b92010-11-08 22:12:1875
[email protected]41d9faf2012-02-28 23:46:0276 //////////////////////////////////////////////////////////////////////////////
77 // Browser specific methods:
[email protected]69b04b92010-11-08 22:12:1878
79 // Return a platform dependent identifier for this frame. On Windows, this
80 // returns an HWND.
81 virtual gfx::NativeWindow GetNativeHandle() = 0;
82
83 // Returns a pointer to the testing interface to the Browser window, or NULL
84 // if there is none.
85 virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0;
86
87 // Return the status bubble associated with the frame
88 virtual StatusBubble* GetStatusBubble() = 0;
89
90 // Inform the receiving frame that an animation has progressed in the
91 // selected tab.
92 // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to
93 // BrowserView.
[email protected]c9bd2e82011-04-15 23:28:1994 virtual void ToolbarSizeChanged(bool is_animating) = 0;
[email protected]69b04b92010-11-08 22:12:1895
96 // Inform the frame that the selected tab favicon or title has changed. Some
97 // frames may need to refresh their title bar.
98 virtual void UpdateTitleBar() = 0;
99
[email protected]09b29342011-06-24 19:18:48100 // Invoked when the state of the bookmark bar changes. This is only invoked if
101 // the state changes for the current tab, it is not sent when switching tabs.
102 virtual void BookmarkBarStateChanged(
103 BookmarkBar::AnimateChangeType change_type) = 0;
[email protected]69b04b92010-11-08 22:12:18104
105 // Inform the frame that the dev tools window for the selected tab has
106 // changed.
107 virtual void UpdateDevTools() = 0;
108
[email protected]853e16eb2011-12-29 16:58:19109 // Requests that the docked dev tools window changes its dock mode.
110 virtual void SetDevToolsDockSide(DevToolsDockSide side) = 0;
111
[email protected]69b04b92010-11-08 22:12:18112 // 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
[email protected]69b04b92010-11-08 22:12:18120 // Accessors for fullscreen mode state.
[email protected]8d944b32011-10-17 06:11:53121 virtual void EnterFullscreen(const GURL& url,
122 FullscreenExitBubbleType bubble_type) = 0;
[email protected]55c87fa2011-10-15 07:28:28123 virtual void ExitFullscreen() = 0;
[email protected]8d944b32011-10-17 06:11:53124 virtual void UpdateFullscreenExitBubbleContent(
125 const GURL& url,
126 FullscreenExitBubbleType bubble_type) = 0;
[email protected]69b04b92010-11-08 22:12:18127 virtual bool IsFullscreen() const = 0;
128
129 // Returns true if the fullscreen bubble is visible.
130 virtual bool IsFullscreenBubbleVisible() const = 0;
131
132 // Returns the location bar.
133 virtual LocationBar* GetLocationBar() const = 0;
134
135 // Tries to focus the location bar. Clears the window focus (to avoid
136 // inconsistent state) if this fails.
137 virtual void SetFocusToLocationBar(bool select_all) = 0;
138
139 // Informs the view whether or not a load is in progress for the current tab.
140 // The view can use this notification to update the reload/stop button.
141 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
142
143 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49144 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18145 bool should_restore_state) = 0;
146
147 // Focuses the toolbar (for accessibility).
148 virtual void FocusToolbar() = 0;
149
150 // Focuses the app menu like it was a menu bar.
151 //
152 // Not used on the Mac, which has a "normal" menu bar.
153 virtual void FocusAppMenu() = 0;
154
155 // Focuses the bookmarks toolbar (for accessibility).
156 virtual void FocusBookmarksToolbar() = 0;
157
158 // Focuses the Chrome OS status view (for accessibility).
159 virtual void FocusChromeOSStatus() = 0;
160
161 // Moves keyboard focus to the next pane.
162 virtual void RotatePaneFocus(bool forwards) = 0;
163
164 // Returns whether the bookmark bar is visible or not.
165 virtual bool IsBookmarkBarVisible() const = 0;
166
167 // Returns whether the bookmark bar is animating or not.
168 virtual bool IsBookmarkBarAnimating() const = 0;
169
[email protected]95bf8a5b2010-12-22 16:04:07170 // Returns whether the tab strip is editable (for extensions).
171 virtual bool IsTabStripEditable() const = 0;
172
[email protected]69b04b92010-11-08 22:12:18173 // Returns whether the tool bar is visible or not.
174 virtual bool IsToolbarVisible() const = 0;
175
[email protected]b7a756d42012-01-23 18:08:17176 // Returns the rect where the resize corner should be drawn by the render
177 // widget host view (on top of what the renderer returns). We return an empty
178 // rect to identify that there shouldn't be a resize corner (in the cases
179 // where we take care of it ourselves at the browser level).
180 virtual gfx::Rect GetRootWindowResizerRect() const = 0;
181
[email protected]5f58c2af2012-01-11 17:55:29182 // Returns whether the window is a panel. This is not always synonomous
183 // with the associated browser having type panel since some environments
184 // may draw popups in panel windows.
185 virtual bool IsPanel() const = 0;
186
[email protected]69b04b92010-11-08 22:12:18187 // Tells the frame not to render as inactive until the next activation change.
188 // This is required on Windows when dropdown selects are shown to prevent the
189 // select from deactivating the browser frame. A stub implementation is
190 // provided here since the functionality is Windows-specific.
191 virtual void DisableInactiveFrame() {}
192
[email protected]69b04b92010-11-08 22:12:18193 // Shows a confirmation dialog box for adding a search engine described by
194 // |template_url|. Takes ownership of |template_url|.
195 virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
196 Profile* profile) = 0;
197
198 // Shows or hides the bookmark bar depending on its current visibility.
199 virtual void ToggleBookmarkBar() = 0;
200
201 // Shows the About Chrome dialog box.
[email protected]4c6b474b72011-02-24 21:35:21202 virtual void ShowAboutChromeDialog() = 0;
[email protected]69b04b92010-11-08 22:12:18203
204 // Shows the Update Recommended dialog box.
205 virtual void ShowUpdateChromeDialog() = 0;
206
207 // Shows the Task manager.
208 virtual void ShowTaskManager() = 0;
209
[email protected]adb6a84d2011-02-07 16:58:40210 // Shows task information related to background pages.
211 virtual void ShowBackgroundPages() = 0;
212
[email protected]69b04b92010-11-08 22:12:18213 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
214 // |already_bookmarked| is true if the url is already bookmarked.
215 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
216
[email protected]b106ca52012-03-13 06:08:46217 // Shows the Chrome To Mobile bubble.
218 virtual void ShowChromeToMobileBubble() = 0;
219
[email protected]69b04b92010-11-08 22:12:18220 // Whether or not the shelf view is visible.
221 virtual bool IsDownloadShelfVisible() const = 0;
222
223 // Returns the DownloadShelf.
224 virtual DownloadShelf* GetDownloadShelf() = 0;
225
[email protected]69b04b92010-11-08 22:12:18226 // Shows the confirmation dialog box warning that the browser is closing with
227 // in-progress downloads.
228 // This method should call Browser::InProgressDownloadResponse once the user
229 // has confirmed.
230 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
231
[email protected]a0ea76c2011-03-23 17:36:42232 // ThemeService calls this when a user has changed his or her theme,
[email protected]69b04b92010-11-08 22:12:18233 // indicating that it's time to redraw everything.
234 virtual void UserChangedTheme() = 0;
235
236 // Get extra vertical height that the render view should add to its requests
237 // to webkit. This can help prevent sending extraneous layout/repaint requests
238 // when the delegate is in the process of resizing the tab contents view (e.g.
239 // during infobar animations).
240 virtual int GetExtraRenderViewHeight() const = 0;
241
[email protected]2a6bc3e2011-12-28 23:51:33242 // Notification that |contents| got the focus through user action (click
[email protected]69b04b92010-11-08 22:12:18243 // on the page).
[email protected]2a6bc3e2011-12-28 23:51:33244 virtual void WebContentsFocused(content::WebContents* contents) = 0;
[email protected]69b04b92010-11-08 22:12:18245
246 // Shows the page info using the specified information.
247 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
248 // information for that page/frame. If |show_history| is true, a section
249 // showing how many times that URL has been visited is added to the page info.
250 virtual void ShowPageInfo(Profile* profile,
251 const GURL& url,
[email protected]d583e3f22011-12-27 21:38:17252 const content::SSLStatus& ssl,
[email protected]69b04b92010-11-08 22:12:18253 bool show_history) = 0;
254
[email protected]b8e681e82012-02-20 10:18:47255 // Shows the website settings using the specified information. |url| is the
256 // url of the page/frame the info applies to, |ssl| is the SSL information for
257 // that page/frame. If |show_history| is true, a section showing how many
258 // times that URL has been visited is added to the page info.
259 virtual void ShowWebsiteSettings(Profile* profile,
260 TabContentsWrapper* tab_contents_wrapper,
261 const GURL& url,
262 const content::SSLStatus& ssl,
263 bool show_history) = 0;
264
[email protected]69b04b92010-11-08 22:12:18265 // Shows the app menu (for accessibility).
266 virtual void ShowAppMenu() = 0;
267
268 // Allows the BrowserWindow object to handle the specified keyboard event
269 // before sending it to the renderer.
270 // Returns true if the |event| was handled. Otherwise, if the |event| would
271 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
272 // |*is_keyboard_shortcut| should be set to true.
273 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
274 bool* is_keyboard_shortcut) = 0;
275
276 // Allows the BrowserWindow object to handle the specified keyboard event,
277 // if the renderer did not process it.
278 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
279
280 // Shows the create web app shortcut dialog box.
[email protected]f847e6082011-03-24 00:08:26281 virtual void ShowCreateWebAppShortcutsDialog(
282 TabContentsWrapper* tab_contents) = 0;
[email protected]a3b734b2010-11-30 03:17:11283
284 // Shows the create chrome app shortcut dialog box.
285 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
286 const Extension* app) = 0;
[email protected]69b04b92010-11-08 22:12:18287
288 // Clipboard commands applied to the whole browser window.
289 virtual void Cut() = 0;
290 virtual void Copy() = 0;
291 virtual void Paste() = 0;
292
[email protected]69b04b92010-11-08 22:12:18293#if defined(OS_MACOSX)
294 // Opens the tabpose view.
295 virtual void OpenTabpose() = 0;
[email protected]d3766932011-08-04 22:18:23296
297 // Sets the presentation mode for the window. If the window is not already in
298 // fullscreen, also enters fullscreen mode.
[email protected]8d944b32011-10-17 06:11:53299 virtual void EnterPresentationMode(
300 const GURL& url,
301 FullscreenExitBubbleType bubble_type) = 0;
302 virtual void ExitPresentationMode() = 0;
[email protected]d3766932011-08-04 22:18:23303 virtual bool InPresentationMode() = 0;
[email protected]69b04b92010-11-08 22:12:18304#endif
305
[email protected]69b04b92010-11-08 22:12:18306 // Invoked when instant's tab contents should be shown.
[email protected]e3690ed2011-03-25 20:25:14307 virtual void ShowInstant(TabContentsWrapper* preview) = 0;
[email protected]69b04b92010-11-08 22:12:18308
309 // Invoked when the instant's tab contents should be hidden.
[email protected]3e481282011-10-15 15:39:50310 virtual void HideInstant() = 0;
[email protected]69b04b92010-11-08 22:12:18311
312 // Returns the desired bounds for instant in screen coordinates. Note that if
313 // instant isn't currently visible this returns the bounds instant would be
314 // placed at.
315 virtual gfx::Rect GetInstantBounds() = 0;
316
[email protected]588300d2011-04-28 21:06:35317 // Return the correct disposition for a popup window based on |bounds|.
318 virtual WindowOpenDisposition GetDispositionForPopupBounds(
319 const gfx::Rect& bounds) = 0;
320
[email protected]632983f2011-08-08 22:51:24321 // Construct a FindBar implementation for the |browser|.
322 virtual FindBar* CreateFindBar() = 0;
323
[email protected]d14af522010-12-02 03:54:50324#if defined(OS_CHROMEOS)
[email protected]e7137b2c2011-10-24 20:16:55325 // Shows the mobile setup dialog.
326 virtual void ShowMobileSetup() = 0;
327
[email protected]d14af522010-12-02 03:54:50328 // Shows the keyboard overlay dialog box.
329 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) = 0;
330#endif
331
[email protected]0548c5352011-09-07 00:33:33332 // Invoked when the preferred size of the contents in current tab has been
333 // changed. We might choose to update the window size to accomodate this
334 // change.
335 // Note that this won't be fired if we change tabs.
[email protected]2a6bc3e2011-12-28 23:51:33336 virtual void UpdatePreferredSize(content::WebContents* web_contents,
[email protected]0548c5352011-09-07 00:33:33337 const gfx::Size& pref_size) {}
338
[email protected]61e2b3cc2012-03-02 16:13:34339 // Invoked when the contents auto-resized and the container should match it.
340 virtual void ResizeDueToAutoResize(content::WebContents* web_contents,
341 const gfx::Size& new_size) {}
342
[email protected]69b04b92010-11-08 22:12:18343 // Construct a BrowserWindow implementation for the specified |browser|.
344 static BrowserWindow* CreateBrowserWindow(Browser* browser);
345
[email protected]0ec4898e2011-12-30 21:09:24346 // Shows the avatar bubble inside |web_contents|. The bubble is positioned
347 // relative to |rect|. |rect| should be in the |web_contents| coordinate
[email protected]2f733a02011-10-06 15:17:34348 // system.
[email protected]0ec4898e2011-12-30 21:09:24349 virtual void ShowAvatarBubble(content::WebContents* web_contents,
[email protected]2f733a02011-10-06 15:17:34350 const gfx::Rect& rect) = 0;
351
[email protected]7d2d08152011-10-25 22:58:47352 // Shows the avatar bubble on the window frame off of the avatar button.
353 virtual void ShowAvatarBubbleFromAvatarButton() = 0;
354
[email protected]90ee09232012-03-21 02:01:01355 // Show bubble for password generation positioned relative to |rect|. A stub
356 // implementation is provided since this feature is currently only available
357 // for Windows.
358 virtual void ShowPasswordGenerationBubble(const gfx::Rect& rect) {}
359
[email protected]69b04b92010-11-08 22:12:18360 protected:
361 friend class BrowserList;
362 friend class BrowserView;
363 virtual void DestroyBrowser() = 0;
[email protected]69b04b92010-11-08 22:12:18364};
365
366#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
367class BookmarkBarView;
368class LocationBarView;
369
370namespace views {
371class View;
372}
373#endif // defined(OS_WIN)
374
375// A BrowserWindow utility interface used for accessing elements of the browser
376// UI used only by UI test automation.
377class BrowserWindowTesting {
378 public:
379#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
380 // Returns the BookmarkBarView.
381 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
382
383 // Returns the LocationBarView.
384 virtual LocationBarView* GetLocationBarView() const = 0;
385
386 // Returns the TabContentsContainer.
387 virtual views::View* GetTabContentsContainerView() const = 0;
388
[email protected]69b04b92010-11-08 22:12:18389 // Returns the ToolbarView.
390 virtual ToolbarView* GetToolbarView() const = 0;
391#endif
392
393 protected:
394 virtual ~BrowserWindowTesting() {}
395};
396
397#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_