blob: cc1b4d816526747ce9fbadd6eac3597b2919c058 [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
9#include "chrome/browser/tab_contents/navigation_entry.h"
10#include "chrome/common/content_settings_types.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 Clear Browsing Data dialog box.
229 virtual void ShowClearBrowsingDataDialog() = 0;
230
231 // Shows the Import Bookmarks & Settings dialog box.
232 virtual void ShowImportDialog() = 0;
233
234 // Shows the Search Engines dialog box.
235 virtual void ShowSearchEnginesDialog() = 0;
236
237 // Shows the Password Manager dialog box.
238 virtual void ShowPasswordManager() = 0;
239
240 // Shows the repost form confirmation dialog box.
241 virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) = 0;
242
243 // Shows the Content Settings dialog box.
244 virtual void ShowContentSettingsWindow(ContentSettingsType content_type,
245 Profile* profile) = 0;
246
247 // Shows the collected cookies dialog box.
248 virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) = 0;
249
250 // Shows a dialog to the user that something is wrong with the profile.
251 // |message_id| is the ID for a string in the string table which will be
252 // displayed in the dialog.
253 virtual void ShowProfileErrorDialog(int message_id) = 0;
254
255 // Show the bubble that indicates to the user that a theme is being installed.
256 virtual void ShowThemeInstallBubble() = 0;
257
258 // Shows the confirmation dialog box warning that the browser is closing with
259 // in-progress downloads.
260 // This method should call Browser::InProgressDownloadResponse once the user
261 // has confirmed.
262 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
263
264 // Shows a dialog box with HTML content, e.g. for Gears. |parent_window| is
265 // the window the dialog should be opened modal to and is a native window
266 // handle.
267 virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
268 gfx::NativeWindow parent_window) = 0;
269
[email protected]69b04b92010-11-08 22:12:18270 // BrowserThemeProvider calls this when a user has changed his or her theme,
271 // indicating that it's time to redraw everything.
272 virtual void UserChangedTheme() = 0;
273
274 // Get extra vertical height that the render view should add to its requests
275 // to webkit. This can help prevent sending extraneous layout/repaint requests
276 // when the delegate is in the process of resizing the tab contents view (e.g.
277 // during infobar animations).
278 virtual int GetExtraRenderViewHeight() const = 0;
279
280 // Notification that |tab_contents| got the focus through user action (click
281 // on the page).
282 virtual void TabContentsFocused(TabContents* tab_contents) = 0;
283
284 // Shows the page info using the specified information.
285 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
286 // information for that page/frame. If |show_history| is true, a section
287 // showing how many times that URL has been visited is added to the page info.
288 virtual void ShowPageInfo(Profile* profile,
289 const GURL& url,
290 const NavigationEntry::SSLStatus& ssl,
291 bool show_history) = 0;
292
293 // Shows the app menu (for accessibility).
294 virtual void ShowAppMenu() = 0;
295
296 // Allows the BrowserWindow object to handle the specified keyboard event
297 // before sending it to the renderer.
298 // Returns true if the |event| was handled. Otherwise, if the |event| would
299 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
300 // |*is_keyboard_shortcut| should be set to true.
301 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
302 bool* is_keyboard_shortcut) = 0;
303
304 // Allows the BrowserWindow object to handle the specified keyboard event,
305 // if the renderer did not process it.
306 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
307
308 // Shows the create web app shortcut dialog box.
[email protected]a3b734b2010-11-30 03:17:11309 virtual void ShowCreateWebAppShortcutsDialog(TabContents* tab_contents) = 0;
310
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
320 // Switches between available tabstrip display modes.
321 virtual void ToggleTabStripMode() = 0;
322
323#if defined(OS_MACOSX)
324 // Opens the tabpose view.
325 virtual void OpenTabpose() = 0;
326#endif
327
[email protected]36d5e5592010-11-15 20:45:59328 // See InstantDelegate for details.
329 virtual void PrepareForInstant() = 0;
330
[email protected]69b04b92010-11-08 22:12:18331 // Invoked when instant's tab contents should be shown.
332 virtual void ShowInstant(TabContents* preview_contents) = 0;
333
334 // Invoked when the instant's tab contents should be hidden.
[email protected]1946c932010-12-15 00:07:38335 // |instant_is_active| indicates if instant is still active.
336 virtual void HideInstant(bool instant_is_active) = 0;
[email protected]69b04b92010-11-08 22:12:18337
338 // Returns the desired bounds for instant in screen coordinates. Note that if
339 // instant isn't currently visible this returns the bounds instant would be
340 // placed at.
341 virtual gfx::Rect GetInstantBounds() = 0;
342
[email protected]d14af522010-12-02 03:54:50343#if defined(OS_CHROMEOS)
344 // Shows the keyboard overlay dialog box.
345 virtual void ShowKeyboardOverlay(gfx::NativeWindow owning_window) = 0;
346#endif
347
[email protected]69b04b92010-11-08 22:12:18348 // Construct a BrowserWindow implementation for the specified |browser|.
349 static BrowserWindow* CreateBrowserWindow(Browser* browser);
350
351 // Construct a FindBar implementation for the specified |browser|.
352 static FindBar* CreateFindBar(Browser* browser_window);
353
[email protected]69b04b92010-11-08 22:12:18354 protected:
355 friend class BrowserList;
356 friend class BrowserView;
357 virtual void DestroyBrowser() = 0;
358
359 virtual ~BrowserWindow() {}
360};
361
362#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
363class BookmarkBarView;
364class LocationBarView;
365
366namespace views {
367class View;
368}
369#endif // defined(OS_WIN)
370
371// A BrowserWindow utility interface used for accessing elements of the browser
372// UI used only by UI test automation.
373class BrowserWindowTesting {
374 public:
375#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
376 // Returns the BookmarkBarView.
377 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
378
379 // Returns the LocationBarView.
380 virtual LocationBarView* GetLocationBarView() const = 0;
381
382 // Returns the TabContentsContainer.
383 virtual views::View* GetTabContentsContainerView() const = 0;
384
385 // Returns the TabContentsContainer.
386 virtual views::View* GetSidebarContainerView() const = 0;
387
388 // Returns the ToolbarView.
389 virtual ToolbarView* GetToolbarView() const = 0;
390#endif
391
392 protected:
393 virtual ~BrowserWindowTesting() {}
394};
395
396#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_