blob: 6577157084a3c9f98b13dae0d4ab6b7d680c4a55 [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]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]08397d52011-02-05 01:53:3812#include "ui/gfx/native_widget_types.h"
[email protected]588300d2011-04-28 21:06:3513#include "webkit/glue/window_open_disposition.h"
[email protected]69b04b92010-11-08 22:12:1814
15class Browser;
16class BrowserWindowTesting;
17class DownloadShelf;
18class FindBar;
19class GURL;
[email protected]69b04b92010-11-08 22:12:1820class LocationBar;
21class Profile;
22class StatusBubble;
23class TabContents;
[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.
51//
52// NOTE: All getters may return NULL.
53class BrowserWindow {
54 public:
[email protected]ed2f27132011-04-04 17:19:5755 virtual ~BrowserWindow() {}
56
[email protected]69b04b92010-11-08 22:12:1857 // Show the window, or activates it if it's already visible.
[email protected]2f516c792011-09-19 22:22:0958 // Browser::OnWindowDidShow should be called after showing the window.
[email protected]69b04b92010-11-08 22:12:1859 virtual void Show() = 0;
60
[email protected]d4db6c702011-03-28 21:49:1461 // Show the window, but do not activate it. Does nothing if window
62 // is already visible.
63 virtual void ShowInactive() = 0;
64
[email protected]69b04b92010-11-08 22:12:1865 // Sets the window's size and position to the specified values.
66 virtual void SetBounds(const gfx::Rect& bounds) = 0;
67
68 // Closes the frame as soon as possible. If the frame is not in a drag
69 // session, it will close immediately; otherwise, it will move offscreen (so
70 // events are still fired) until the drag ends, then close. This assumes
71 // that the Browser is not immediately destroyed, but will be eventually
72 // destroyed by other means (eg, the tab strip going to zero elements).
73 // Bad things happen if the Browser dtor is called directly as a result of
74 // invoking this method.
75 virtual void Close() = 0;
76
77 // Activates (brings to front) the window. Restores the window from minimized
78 // state if necessary.
79 virtual void Activate() = 0;
80
81 // Deactivates the window, making the next window in the Z order the active
82 // window.
83 virtual void Deactivate() = 0;
84
85 // Returns true if the window is currently the active/focused window.
86 virtual bool IsActive() const = 0;
87
88 // Flashes the taskbar item associated with this frame.
89 virtual void FlashFrame() = 0;
90
91 // Return a platform dependent identifier for this frame. On Windows, this
92 // returns an HWND.
93 virtual gfx::NativeWindow GetNativeHandle() = 0;
94
95 // Returns a pointer to the testing interface to the Browser window, or NULL
96 // if there is none.
97 virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0;
98
99 // Return the status bubble associated with the frame
100 virtual StatusBubble* GetStatusBubble() = 0;
101
102 // Inform the receiving frame that an animation has progressed in the
103 // selected tab.
104 // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to
105 // BrowserView.
[email protected]c9bd2e82011-04-15 23:28:19106 virtual void ToolbarSizeChanged(bool is_animating) = 0;
[email protected]69b04b92010-11-08 22:12:18107
108 // Inform the frame that the selected tab favicon or title has changed. Some
109 // frames may need to refresh their title bar.
110 virtual void UpdateTitleBar() = 0;
111
[email protected]09b29342011-06-24 19:18:48112 // Invoked when the state of the bookmark bar changes. This is only invoked if
113 // the state changes for the current tab, it is not sent when switching tabs.
114 virtual void BookmarkBarStateChanged(
115 BookmarkBar::AnimateChangeType change_type) = 0;
[email protected]69b04b92010-11-08 22:12:18116
117 // Inform the frame that the dev tools window for the selected tab has
118 // changed.
119 virtual void UpdateDevTools() = 0;
120
[email protected]853e16eb2011-12-29 16:58:19121 // Requests that the docked dev tools window changes its dock mode.
122 virtual void SetDevToolsDockSide(DevToolsDockSide side) = 0;
123
[email protected]69b04b92010-11-08 22:12:18124 // Update any loading animations running in the window. |should_animate| is
125 // true if there are tabs loading and the animations should continue, false
126 // if there are no active loads and the animations should end.
127 virtual void UpdateLoadingAnimations(bool should_animate) = 0;
128
129 // Sets the starred state for the current tab.
130 virtual void SetStarredState(bool is_starred) = 0;
131
132 // Returns the nonmaximized bounds of the frame (even if the frame is
133 // currently maximized or minimized) in terms of the screen coordinates.
134 virtual gfx::Rect GetRestoredBounds() const = 0;
135
[email protected]d479b8e22011-02-09 05:19:49136 // Retrieves the window's current bounds, including its frame.
137 // This will only differ from GetRestoredBounds() for maximized
138 // and minimized windows.
139 virtual gfx::Rect GetBounds() const = 0;
140
[email protected]69b04b92010-11-08 22:12:18141 // TODO(beng): REMOVE?
142 // Returns true if the frame is maximized (aka zoomed).
143 virtual bool IsMaximized() const = 0;
144
[email protected]400eaf82011-08-22 15:47:39145 // Returns true if the frame is minimized.
146 virtual bool IsMinimized() const = 0;
147
[email protected]541e3ee2011-11-22 01:31:10148 // Maximizes/minimizes/restores the window.
149 virtual void Maximize() = 0;
150 virtual void Minimize() = 0;
151 virtual void Restore() = 0;
152
[email protected]69b04b92010-11-08 22:12:18153 // Accessors for fullscreen mode state.
[email protected]8d944b32011-10-17 06:11:53154 virtual void EnterFullscreen(const GURL& url,
155 FullscreenExitBubbleType bubble_type) = 0;
[email protected]55c87fa2011-10-15 07:28:28156 virtual void ExitFullscreen() = 0;
[email protected]8d944b32011-10-17 06:11:53157 virtual void UpdateFullscreenExitBubbleContent(
158 const GURL& url,
159 FullscreenExitBubbleType bubble_type) = 0;
[email protected]69b04b92010-11-08 22:12:18160 virtual bool IsFullscreen() const = 0;
161
162 // Returns true if the fullscreen bubble is visible.
163 virtual bool IsFullscreenBubbleVisible() const = 0;
164
165 // Returns the location bar.
166 virtual LocationBar* GetLocationBar() const = 0;
167
168 // Tries to focus the location bar. Clears the window focus (to avoid
169 // inconsistent state) if this fails.
170 virtual void SetFocusToLocationBar(bool select_all) = 0;
171
172 // Informs the view whether or not a load is in progress for the current tab.
173 // The view can use this notification to update the reload/stop button.
174 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
175
176 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49177 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18178 bool should_restore_state) = 0;
179
180 // Focuses the toolbar (for accessibility).
181 virtual void FocusToolbar() = 0;
182
183 // Focuses the app menu like it was a menu bar.
184 //
185 // Not used on the Mac, which has a "normal" menu bar.
186 virtual void FocusAppMenu() = 0;
187
188 // Focuses the bookmarks toolbar (for accessibility).
189 virtual void FocusBookmarksToolbar() = 0;
190
191 // Focuses the Chrome OS status view (for accessibility).
192 virtual void FocusChromeOSStatus() = 0;
193
194 // Moves keyboard focus to the next pane.
195 virtual void RotatePaneFocus(bool forwards) = 0;
196
197 // Returns whether the bookmark bar is visible or not.
198 virtual bool IsBookmarkBarVisible() const = 0;
199
200 // Returns whether the bookmark bar is animating or not.
201 virtual bool IsBookmarkBarAnimating() const = 0;
202
[email protected]95bf8a5b2010-12-22 16:04:07203 // Returns whether the tab strip is editable (for extensions).
204 virtual bool IsTabStripEditable() const = 0;
205
[email protected]69b04b92010-11-08 22:12:18206 // Returns whether the tool bar is visible or not.
207 virtual bool IsToolbarVisible() const = 0;
208
[email protected]5f58c2af2012-01-11 17:55:29209 // Returns whether the window is a panel. This is not always synonomous
210 // with the associated browser having type panel since some environments
211 // may draw popups in panel windows.
212 virtual bool IsPanel() const = 0;
213
[email protected]69b04b92010-11-08 22:12:18214 // Tells the frame not to render as inactive until the next activation change.
215 // This is required on Windows when dropdown selects are shown to prevent the
216 // select from deactivating the browser frame. A stub implementation is
217 // provided here since the functionality is Windows-specific.
218 virtual void DisableInactiveFrame() {}
219
220 // Shows a confirmation dialog box for setting the default search engine
221 // described by |template_url|. Takes ownership of |template_url|.
[email protected]ea049a02011-12-25 21:37:09222 virtual void ConfirmSetDefaultSearchProvider(
223 content::WebContents* web_contents,
224 TemplateURL* template_url,
225 Profile* profile) {
[email protected]69b04b92010-11-08 22:12:18226 // TODO(levin): Implement this for non-Windows platforms and make it pure.
[email protected]9219d262011-02-15 21:05:12227 // http://crbug.com/38475
[email protected]69b04b92010-11-08 22:12:18228 }
229
230 // Shows a confirmation dialog box for adding a search engine described by
231 // |template_url|. Takes ownership of |template_url|.
232 virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
233 Profile* profile) = 0;
234
235 // Shows or hides the bookmark bar depending on its current visibility.
236 virtual void ToggleBookmarkBar() = 0;
237
238 // Shows the About Chrome dialog box.
[email protected]4c6b474b72011-02-24 21:35:21239 virtual void ShowAboutChromeDialog() = 0;
[email protected]69b04b92010-11-08 22:12:18240
241 // Shows the Update Recommended dialog box.
242 virtual void ShowUpdateChromeDialog() = 0;
243
244 // Shows the Task manager.
245 virtual void ShowTaskManager() = 0;
246
[email protected]adb6a84d2011-02-07 16:58:40247 // Shows task information related to background pages.
248 virtual void ShowBackgroundPages() = 0;
249
[email protected]69b04b92010-11-08 22:12:18250 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
251 // |already_bookmarked| is true if the url is already bookmarked.
252 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
253
254 // Whether or not the shelf view is visible.
255 virtual bool IsDownloadShelfVisible() const = 0;
256
257 // Returns the DownloadShelf.
258 virtual DownloadShelf* GetDownloadShelf() = 0;
259
[email protected]69b04b92010-11-08 22:12:18260 // Shows the collected cookies dialog box.
[email protected]a3627e62011-09-07 00:04:57261 virtual void ShowCollectedCookiesDialog(TabContentsWrapper* tab_contents) = 0;
[email protected]69b04b92010-11-08 22:12:18262
[email protected]69b04b92010-11-08 22:12:18263 // Shows the confirmation dialog box warning that the browser is closing with
264 // in-progress downloads.
265 // This method should call Browser::InProgressDownloadResponse once the user
266 // has confirmed.
267 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
268
[email protected]a0ea76c2011-03-23 17:36:42269 // ThemeService calls this when a user has changed his or her theme,
[email protected]69b04b92010-11-08 22:12:18270 // indicating that it's time to redraw everything.
271 virtual void UserChangedTheme() = 0;
272
273 // Get extra vertical height that the render view should add to its requests
274 // to webkit. This can help prevent sending extraneous layout/repaint requests
275 // when the delegate is in the process of resizing the tab contents view (e.g.
276 // during infobar animations).
277 virtual int GetExtraRenderViewHeight() const = 0;
278
[email protected]2a6bc3e2011-12-28 23:51:33279 // Notification that |contents| got the focus through user action (click
[email protected]69b04b92010-11-08 22:12:18280 // on the page).
[email protected]2a6bc3e2011-12-28 23:51:33281 virtual void WebContentsFocused(content::WebContents* contents) = 0;
[email protected]69b04b92010-11-08 22:12:18282
283 // Shows the page info using the specified information.
284 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
285 // information for that page/frame. If |show_history| is true, a section
286 // showing how many times that URL has been visited is added to the page info.
287 virtual void ShowPageInfo(Profile* profile,
288 const GURL& url,
[email protected]d583e3f22011-12-27 21:38:17289 const content::SSLStatus& ssl,
[email protected]69b04b92010-11-08 22:12:18290 bool show_history) = 0;
291
292 // Shows the app menu (for accessibility).
293 virtual void ShowAppMenu() = 0;
294
295 // Allows the BrowserWindow object to handle the specified keyboard event
296 // before sending it to the renderer.
297 // Returns true if the |event| was handled. Otherwise, if the |event| would
298 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
299 // |*is_keyboard_shortcut| should be set to true.
300 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
301 bool* is_keyboard_shortcut) = 0;
302
303 // Allows the BrowserWindow object to handle the specified keyboard event,
304 // if the renderer did not process it.
305 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
306
307 // Shows the create web app shortcut dialog box.
[email protected]f847e6082011-03-24 00:08:26308 virtual void ShowCreateWebAppShortcutsDialog(
309 TabContentsWrapper* tab_contents) = 0;
[email protected]a3b734b2010-11-30 03:17:11310
311 // Shows the create chrome app shortcut dialog box.
312 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
313 const Extension* app) = 0;
[email protected]69b04b92010-11-08 22:12:18314
315 // Clipboard commands applied to the whole browser window.
316 virtual void Cut() = 0;
317 virtual void Copy() = 0;
318 virtual void Paste() = 0;
319
[email protected]69b04b92010-11-08 22:12:18320#if defined(OS_MACOSX)
321 // Opens the tabpose view.
322 virtual void OpenTabpose() = 0;
[email protected]d3766932011-08-04 22:18:23323
324 // Sets the presentation mode for the window. If the window is not already in
325 // fullscreen, also enters fullscreen mode.
[email protected]8d944b32011-10-17 06:11:53326 virtual void EnterPresentationMode(
327 const GURL& url,
328 FullscreenExitBubbleType bubble_type) = 0;
329 virtual void ExitPresentationMode() = 0;
[email protected]d3766932011-08-04 22:18:23330 virtual bool InPresentationMode() = 0;
[email protected]69b04b92010-11-08 22:12:18331#endif
332
[email protected]69b04b92010-11-08 22:12:18333 // Invoked when instant's tab contents should be shown.
[email protected]e3690ed2011-03-25 20:25:14334 virtual void ShowInstant(TabContentsWrapper* preview) = 0;
[email protected]69b04b92010-11-08 22:12:18335
336 // Invoked when the instant's tab contents should be hidden.
[email protected]3e481282011-10-15 15:39:50337 virtual void HideInstant() = 0;
[email protected]69b04b92010-11-08 22:12:18338
339 // Returns the desired bounds for instant in screen coordinates. Note that if
340 // instant isn't currently visible this returns the bounds instant would be
341 // placed at.
342 virtual gfx::Rect GetInstantBounds() = 0;
343
[email protected]588300d2011-04-28 21:06:35344 // Return the correct disposition for a popup window based on |bounds|.
345 virtual WindowOpenDisposition GetDispositionForPopupBounds(
346 const gfx::Rect& bounds) = 0;
347
[email protected]632983f2011-08-08 22:51:24348 // Construct a FindBar implementation for the |browser|.
349 virtual FindBar* CreateFindBar() = 0;
350
[email protected]d14af522010-12-02 03:54:50351#if defined(OS_CHROMEOS)
[email protected]e7137b2c2011-10-24 20:16:55352 // Shows the mobile setup dialog.
353 virtual void ShowMobileSetup() = 0;
354
[email protected]d14af522010-12-02 03:54:50355 // Shows the keyboard overlay dialog box.
356 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) = 0;
357#endif
358
[email protected]0548c5352011-09-07 00:33:33359 // Invoked when the preferred size of the contents in current tab has been
360 // changed. We might choose to update the window size to accomodate this
361 // change.
362 // Note that this won't be fired if we change tabs.
[email protected]2a6bc3e2011-12-28 23:51:33363 virtual void UpdatePreferredSize(content::WebContents* web_contents,
[email protected]0548c5352011-09-07 00:33:33364 const gfx::Size& pref_size) {}
365
[email protected]69b04b92010-11-08 22:12:18366 // Construct a BrowserWindow implementation for the specified |browser|.
367 static BrowserWindow* CreateBrowserWindow(Browser* browser);
368
[email protected]0ec4898e2011-12-30 21:09:24369 // Shows the avatar bubble inside |web_contents|. The bubble is positioned
370 // relative to |rect|. |rect| should be in the |web_contents| coordinate
[email protected]2f733a02011-10-06 15:17:34371 // system.
[email protected]0ec4898e2011-12-30 21:09:24372 virtual void ShowAvatarBubble(content::WebContents* web_contents,
[email protected]2f733a02011-10-06 15:17:34373 const gfx::Rect& rect) = 0;
374
[email protected]7d2d08152011-10-25 22:58:47375 // Shows the avatar bubble on the window frame off of the avatar button.
376 virtual void ShowAvatarBubbleFromAvatarButton() = 0;
377
[email protected]69b04b92010-11-08 22:12:18378 protected:
379 friend class BrowserList;
380 friend class BrowserView;
381 virtual void DestroyBrowser() = 0;
[email protected]69b04b92010-11-08 22:12:18382};
383
384#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
385class BookmarkBarView;
386class LocationBarView;
387
388namespace views {
389class View;
390}
391#endif // defined(OS_WIN)
392
393// A BrowserWindow utility interface used for accessing elements of the browser
394// UI used only by UI test automation.
395class BrowserWindowTesting {
396 public:
397#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
398 // Returns the BookmarkBarView.
399 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
400
401 // Returns the LocationBarView.
402 virtual LocationBarView* GetLocationBarView() const = 0;
403
404 // Returns the TabContentsContainer.
405 virtual views::View* GetTabContentsContainerView() const = 0;
406
[email protected]69b04b92010-11-08 22:12:18407 // Returns the ToolbarView.
408 virtual ToolbarView* GetToolbarView() const = 0;
409#endif
410
411 protected:
412 virtual ~BrowserWindowTesting() {}
413};
414
415#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_