blob: ea54e3cf6100e2f2a07179b0df3cc022f3cfca47 [file] [log] [blame]
[email protected]35d06152011-01-10 22:19:421// Copyright (c) 2011 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]69b04b92010-11-08 22:12:189#include "chrome/common/content_settings_types.h"
[email protected]299425b2011-03-02 07:45:2010#include "content/browser/tab_contents/navigation_entry.h"
[email protected]08397d52011-02-05 01:53:3811#include "ui/gfx/native_widget_types.h"
[email protected]69b04b92010-11-08 22:12:1812
13class Browser;
14class BrowserWindowTesting;
15class DownloadShelf;
16class FindBar;
17class GURL;
18class HtmlDialogUIDelegate;
19class LocationBar;
20class Profile;
21class StatusBubble;
22class TabContents;
[email protected]3c9e1872010-11-18 16:17:4923class TabContentsWrapper;
[email protected]69b04b92010-11-08 22:12:1824class TemplateURL;
25class TemplateURLModel;
26#if !defined(OS_MACOSX)
27class ToolbarView;
28#endif
29struct NativeWebKeyboardEvent;
30
31namespace gfx {
32class Rect;
33}
34
35namespace views {
36class Window;
37}
38
[email protected]a3b734b2010-11-30 03:17:1139class Extension;
40
[email protected]69b04b92010-11-08 22:12:1841////////////////////////////////////////////////////////////////////////////////
42// BrowserWindow interface
43// An interface implemented by the "view" of the Browser window.
44//
45// NOTE: All getters may return NULL.
46class BrowserWindow {
47 public:
48 // Show the window, or activates it if it's already visible.
49 virtual void Show() = 0;
50
51 // Sets the window's size and position to the specified values.
52 virtual void SetBounds(const gfx::Rect& bounds) = 0;
53
54 // Closes the frame as soon as possible. If the frame is not in a drag
55 // session, it will close immediately; otherwise, it will move offscreen (so
56 // events are still fired) until the drag ends, then close. This assumes
57 // that the Browser is not immediately destroyed, but will be eventually
58 // destroyed by other means (eg, the tab strip going to zero elements).
59 // Bad things happen if the Browser dtor is called directly as a result of
60 // invoking this method.
61 virtual void Close() = 0;
62
63 // Activates (brings to front) the window. Restores the window from minimized
64 // state if necessary.
65 virtual void Activate() = 0;
66
67 // Deactivates the window, making the next window in the Z order the active
68 // window.
69 virtual void Deactivate() = 0;
70
71 // Returns true if the window is currently the active/focused window.
72 virtual bool IsActive() const = 0;
73
74 // Flashes the taskbar item associated with this frame.
75 virtual void FlashFrame() = 0;
76
77 // Return a platform dependent identifier for this frame. On Windows, this
78 // returns an HWND.
79 virtual gfx::NativeWindow GetNativeHandle() = 0;
80
81 // Returns a pointer to the testing interface to the Browser window, or NULL
82 // if there is none.
83 virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0;
84
85 // Return the status bubble associated with the frame
86 virtual StatusBubble* GetStatusBubble() = 0;
87
88 // Inform the receiving frame that an animation has progressed in the
89 // selected tab.
90 // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to
91 // BrowserView.
92 virtual void SelectedTabToolbarSizeChanged(bool is_animating) = 0;
93
94 // Inform the frame that the selected tab favicon or title has changed. Some
95 // frames may need to refresh their title bar.
96 virtual void UpdateTitleBar() = 0;
97
98 // Invoked when the visibility of the bookmark bar.
99 // NOTE: this is NOT sent when the user toggles the visibility of this,
100 // but rather when the user transitions from a page that forces
101 // it to be visibile to one that doesn't have it visible (or
102 // vice-versa).
103 // TODO(sky): see about routing visibility pref changing through here too.
104 virtual void ShelfVisibilityChanged() = 0;
105
106 // Inform the frame that the dev tools window for the selected tab has
107 // changed.
108 virtual void UpdateDevTools() = 0;
109
110 // Update any loading animations running in the window. |should_animate| is
111 // true if there are tabs loading and the animations should continue, false
112 // if there are no active loads and the animations should end.
113 virtual void UpdateLoadingAnimations(bool should_animate) = 0;
114
115 // Sets the starred state for the current tab.
116 virtual void SetStarredState(bool is_starred) = 0;
117
118 // Returns the nonmaximized bounds of the frame (even if the frame is
119 // currently maximized or minimized) in terms of the screen coordinates.
120 virtual gfx::Rect GetRestoredBounds() const = 0;
121
[email protected]d479b8e22011-02-09 05:19:49122 // Retrieves the window's current bounds, including its frame.
123 // This will only differ from GetRestoredBounds() for maximized
124 // and minimized windows.
125 virtual gfx::Rect GetBounds() const = 0;
126
[email protected]69b04b92010-11-08 22:12:18127 // TODO(beng): REMOVE?
128 // Returns true if the frame is maximized (aka zoomed).
129 virtual bool IsMaximized() const = 0;
130
131 // Accessors for fullscreen mode state.
132 virtual void SetFullscreen(bool fullscreen) = 0;
133 virtual bool IsFullscreen() const = 0;
134
135 // Returns true if the fullscreen bubble is visible.
136 virtual bool IsFullscreenBubbleVisible() const = 0;
137
138 // Returns the location bar.
139 virtual LocationBar* GetLocationBar() const = 0;
140
141 // Tries to focus the location bar. Clears the window focus (to avoid
142 // inconsistent state) if this fails.
143 virtual void SetFocusToLocationBar(bool select_all) = 0;
144
145 // Informs the view whether or not a load is in progress for the current tab.
146 // The view can use this notification to update the reload/stop button.
147 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
148
149 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49150 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18151 bool should_restore_state) = 0;
152
153 // Focuses the toolbar (for accessibility).
154 virtual void FocusToolbar() = 0;
155
156 // Focuses the app menu like it was a menu bar.
157 //
158 // Not used on the Mac, which has a "normal" menu bar.
159 virtual void FocusAppMenu() = 0;
160
161 // Focuses the bookmarks toolbar (for accessibility).
162 virtual void FocusBookmarksToolbar() = 0;
163
164 // Focuses the Chrome OS status view (for accessibility).
165 virtual void FocusChromeOSStatus() = 0;
166
167 // Moves keyboard focus to the next pane.
168 virtual void RotatePaneFocus(bool forwards) = 0;
169
170 // Returns whether the bookmark bar is visible or not.
171 virtual bool IsBookmarkBarVisible() const = 0;
172
173 // Returns whether the bookmark bar is animating or not.
174 virtual bool IsBookmarkBarAnimating() const = 0;
175
[email protected]95bf8a5b2010-12-22 16:04:07176 // Returns whether the tab strip is editable (for extensions).
177 virtual bool IsTabStripEditable() const = 0;
178
[email protected]69b04b92010-11-08 22:12:18179 // Returns whether the tool bar is visible or not.
180 virtual bool IsToolbarVisible() const = 0;
181
[email protected]69b04b92010-11-08 22:12:18182 // Tells the frame not to render as inactive until the next activation change.
183 // This is required on Windows when dropdown selects are shown to prevent the
184 // select from deactivating the browser frame. A stub implementation is
185 // provided here since the functionality is Windows-specific.
186 virtual void DisableInactiveFrame() {}
187
188 // Shows a confirmation dialog box for setting the default search engine
189 // described by |template_url|. Takes ownership of |template_url|.
190 virtual void ConfirmSetDefaultSearchProvider(
[email protected]b5a1d11c2011-02-17 03:09:42191 TabContents* tab_contents,
[email protected]69b04b92010-11-08 22:12:18192 TemplateURL* template_url,
193 TemplateURLModel* template_url_model) {
194 // TODO(levin): Implement this for non-Windows platforms and make it pure.
[email protected]9219d262011-02-15 21:05:12195 // http://crbug.com/38475
[email protected]69b04b92010-11-08 22:12:18196 }
197
198 // Shows a confirmation dialog box for adding a search engine described by
199 // |template_url|. Takes ownership of |template_url|.
200 virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
201 Profile* profile) = 0;
202
203 // Shows or hides the bookmark bar depending on its current visibility.
204 virtual void ToggleBookmarkBar() = 0;
205
206 // Shows the About Chrome dialog box.
[email protected]4c6b474b72011-02-24 21:35:21207 virtual void ShowAboutChromeDialog() = 0;
[email protected]69b04b92010-11-08 22:12:18208
209 // Shows the Update Recommended dialog box.
210 virtual void ShowUpdateChromeDialog() = 0;
211
212 // Shows the Task manager.
213 virtual void ShowTaskManager() = 0;
214
[email protected]adb6a84d2011-02-07 16:58:40215 // Shows task information related to background pages.
216 virtual void ShowBackgroundPages() = 0;
217
[email protected]69b04b92010-11-08 22:12:18218 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
219 // |already_bookmarked| is true if the url is already bookmarked.
220 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
221
222 // Whether or not the shelf view is visible.
223 virtual bool IsDownloadShelfVisible() const = 0;
224
225 // Returns the DownloadShelf.
226 virtual DownloadShelf* GetDownloadShelf() = 0;
227
[email protected]69b04b92010-11-08 22:12:18228 // Shows the repost form confirmation dialog box.
229 virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) = 0;
230
[email protected]69b04b92010-11-08 22:12:18231 // Shows the collected cookies dialog box.
232 virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) = 0;
233
234 // Shows a dialog to the user that something is wrong with the profile.
235 // |message_id| is the ID for a string in the string table which will be
236 // displayed in the dialog.
237 virtual void ShowProfileErrorDialog(int message_id) = 0;
238
239 // Show the bubble that indicates to the user that a theme is being installed.
240 virtual void ShowThemeInstallBubble() = 0;
241
242 // Shows the confirmation dialog box warning that the browser is closing with
243 // in-progress downloads.
244 // This method should call Browser::InProgressDownloadResponse once the user
245 // has confirmed.
246 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
247
[email protected]50285ff2011-03-11 23:10:56248 // Shows a dialog box with HTML content. |parent_window| is the window the
249 // dialog should be opened modal to and is a native window handle.
[email protected]69b04b92010-11-08 22:12:18250 virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
251 gfx::NativeWindow parent_window) = 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
263 // Notification that |tab_contents| got the focus through user action (click
264 // on the page).
265 virtual void TabContentsFocused(TabContents* tab_contents) = 0;
266
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,
273 const NavigationEntry::SSLStatus& ssl,
274 bool show_history) = 0;
275
276 // Shows the app menu (for accessibility).
277 virtual void ShowAppMenu() = 0;
278
279 // Allows the BrowserWindow object to handle the specified keyboard event
280 // before sending it to the renderer.
281 // Returns true if the |event| was handled. Otherwise, if the |event| would
282 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
283 // |*is_keyboard_shortcut| should be set to true.
284 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
285 bool* is_keyboard_shortcut) = 0;
286
287 // Allows the BrowserWindow object to handle the specified keyboard event,
288 // if the renderer did not process it.
289 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
290
291 // Shows the create web app shortcut dialog box.
[email protected]a3b734b2010-11-30 03:17:11292 virtual void ShowCreateWebAppShortcutsDialog(TabContents* tab_contents) = 0;
293
294 // Shows the create chrome app shortcut dialog box.
295 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
296 const Extension* app) = 0;
[email protected]69b04b92010-11-08 22:12:18297
298 // Clipboard commands applied to the whole browser window.
299 virtual void Cut() = 0;
300 virtual void Copy() = 0;
301 virtual void Paste() = 0;
302
303 // Switches between available tabstrip display modes.
304 virtual void ToggleTabStripMode() = 0;
305
306#if defined(OS_MACOSX)
307 // Opens the tabpose view.
308 virtual void OpenTabpose() = 0;
309#endif
310
[email protected]36d5e5592010-11-15 20:45:59311 // See InstantDelegate for details.
312 virtual void PrepareForInstant() = 0;
313
[email protected]69b04b92010-11-08 22:12:18314 // Invoked when instant's tab contents should be shown.
315 virtual void ShowInstant(TabContents* preview_contents) = 0;
316
317 // Invoked when the instant's tab contents should be hidden.
[email protected]1946c932010-12-15 00:07:38318 // |instant_is_active| indicates if instant is still active.
319 virtual void HideInstant(bool instant_is_active) = 0;
[email protected]69b04b92010-11-08 22:12:18320
321 // Returns the desired bounds for instant in screen coordinates. Note that if
322 // instant isn't currently visible this returns the bounds instant would be
323 // placed at.
324 virtual gfx::Rect GetInstantBounds() = 0;
325
[email protected]d14af522010-12-02 03:54:50326#if defined(OS_CHROMEOS)
327 // Shows the keyboard overlay dialog box.
328 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) = 0;
329#endif
330
[email protected]69b04b92010-11-08 22:12:18331 // Construct a BrowserWindow implementation for the specified |browser|.
332 static BrowserWindow* CreateBrowserWindow(Browser* browser);
333
334 // Construct a FindBar implementation for the specified |browser|.
335 static FindBar* CreateFindBar(Browser* browser_window);
336
[email protected]69b04b92010-11-08 22:12:18337 protected:
338 friend class BrowserList;
339 friend class BrowserView;
340 virtual void DestroyBrowser() = 0;
341
342 virtual ~BrowserWindow() {}
343};
344
345#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
346class BookmarkBarView;
347class LocationBarView;
348
349namespace views {
350class View;
351}
352#endif // defined(OS_WIN)
353
354// A BrowserWindow utility interface used for accessing elements of the browser
355// UI used only by UI test automation.
356class BrowserWindowTesting {
357 public:
358#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
359 // Returns the BookmarkBarView.
360 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
361
362 // Returns the LocationBarView.
363 virtual LocationBarView* GetLocationBarView() const = 0;
364
365 // Returns the TabContentsContainer.
366 virtual views::View* GetTabContentsContainerView() const = 0;
367
368 // Returns the TabContentsContainer.
369 virtual views::View* GetSidebarContainerView() const = 0;
370
371 // Returns the ToolbarView.
372 virtual ToolbarView* GetToolbarView() const = 0;
373#endif
374
375 protected:
376 virtual ~BrowserWindowTesting() {}
377};
378
379#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_