blob: 810bf92de001fb3754eb09405d2634f548877edf [file] [log] [blame]
[email protected]69b04b92010-11-08 22:12:181// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2// 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"
11#include "gfx/native_widget_types.h"
12
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
122 // TODO(beng): REMOVE?
123 // Returns true if the frame is maximized (aka zoomed).
124 virtual bool IsMaximized() const = 0;
125
126 // Accessors for fullscreen mode state.
127 virtual void SetFullscreen(bool fullscreen) = 0;
128 virtual bool IsFullscreen() const = 0;
129
130 // Returns true if the fullscreen bubble is visible.
131 virtual bool IsFullscreenBubbleVisible() const = 0;
132
133 // Returns the location bar.
134 virtual LocationBar* GetLocationBar() const = 0;
135
136 // Tries to focus the location bar. Clears the window focus (to avoid
137 // inconsistent state) if this fails.
138 virtual void SetFocusToLocationBar(bool select_all) = 0;
139
140 // Informs the view whether or not a load is in progress for the current tab.
141 // The view can use this notification to update the reload/stop button.
142 virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;
143
144 // Updates the toolbar with the state for the specified |contents|.
[email protected]3c9e1872010-11-18 16:17:49145 virtual void UpdateToolbar(TabContentsWrapper* contents,
[email protected]69b04b92010-11-08 22:12:18146 bool should_restore_state) = 0;
147
148 // Focuses the toolbar (for accessibility).
149 virtual void FocusToolbar() = 0;
150
151 // Focuses the app menu like it was a menu bar.
152 //
153 // Not used on the Mac, which has a "normal" menu bar.
154 virtual void FocusAppMenu() = 0;
155
156 // Focuses the bookmarks toolbar (for accessibility).
157 virtual void FocusBookmarksToolbar() = 0;
158
159 // Focuses the Chrome OS status view (for accessibility).
160 virtual void FocusChromeOSStatus() = 0;
161
162 // Moves keyboard focus to the next pane.
163 virtual void RotatePaneFocus(bool forwards) = 0;
164
165 // Returns whether the bookmark bar is visible or not.
166 virtual bool IsBookmarkBarVisible() const = 0;
167
168 // Returns whether the bookmark bar is animating or not.
169 virtual bool IsBookmarkBarAnimating() const = 0;
170
171 // Returns whether the tool bar is visible or not.
172 virtual bool IsToolbarVisible() const = 0;
173
[email protected]69b04b92010-11-08 22:12:18174 // Tells the frame not to render as inactive until the next activation change.
175 // This is required on Windows when dropdown selects are shown to prevent the
176 // select from deactivating the browser frame. A stub implementation is
177 // provided here since the functionality is Windows-specific.
178 virtual void DisableInactiveFrame() {}
179
180 // Shows a confirmation dialog box for setting the default search engine
181 // described by |template_url|. Takes ownership of |template_url|.
182 virtual void ConfirmSetDefaultSearchProvider(
183 TabContents* tab_contents,
184 TemplateURL* template_url,
185 TemplateURLModel* template_url_model) {
186 // TODO(levin): Implement this for non-Windows platforms and make it pure.
187 }
188
189 // Shows a confirmation dialog box for adding a search engine described by
190 // |template_url|. Takes ownership of |template_url|.
191 virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
192 Profile* profile) = 0;
193
194 // Shows or hides the bookmark bar depending on its current visibility.
195 virtual void ToggleBookmarkBar() = 0;
196
197 // Shows the About Chrome dialog box.
198 virtual views::Window* ShowAboutChromeDialog() = 0;
199
200 // Shows the Update Recommended dialog box.
201 virtual void ShowUpdateChromeDialog() = 0;
202
203 // Shows the Task manager.
204 virtual void ShowTaskManager() = 0;
205
206 // Shows the Bookmark bubble. |url| is the URL being bookmarked,
207 // |already_bookmarked| is true if the url is already bookmarked.
208 virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;
209
210 // Whether or not the shelf view is visible.
211 virtual bool IsDownloadShelfVisible() const = 0;
212
213 // Returns the DownloadShelf.
214 virtual DownloadShelf* GetDownloadShelf() = 0;
215
216 // Shows the Report a Bug dialog box.
217 virtual void ShowReportBugDialog() = 0;
218
219 // Shows the Clear Browsing Data dialog box.
220 virtual void ShowClearBrowsingDataDialog() = 0;
221
222 // Shows the Import Bookmarks & Settings dialog box.
223 virtual void ShowImportDialog() = 0;
224
225 // Shows the Search Engines dialog box.
226 virtual void ShowSearchEnginesDialog() = 0;
227
228 // Shows the Password Manager dialog box.
229 virtual void ShowPasswordManager() = 0;
230
231 // Shows the repost form confirmation dialog box.
232 virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) = 0;
233
234 // Shows the Content Settings dialog box.
235 virtual void ShowContentSettingsWindow(ContentSettingsType content_type,
236 Profile* profile) = 0;
237
238 // Shows the collected cookies dialog box.
239 virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) = 0;
240
241 // Shows a dialog to the user that something is wrong with the profile.
242 // |message_id| is the ID for a string in the string table which will be
243 // displayed in the dialog.
244 virtual void ShowProfileErrorDialog(int message_id) = 0;
245
246 // Show the bubble that indicates to the user that a theme is being installed.
247 virtual void ShowThemeInstallBubble() = 0;
248
249 // Shows the confirmation dialog box warning that the browser is closing with
250 // in-progress downloads.
251 // This method should call Browser::InProgressDownloadResponse once the user
252 // has confirmed.
253 virtual void ConfirmBrowserCloseWithPendingDownloads() = 0;
254
255 // Shows a dialog box with HTML content, e.g. for Gears. |parent_window| is
256 // the window the dialog should be opened modal to and is a native window
257 // handle.
258 virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
259 gfx::NativeWindow parent_window) = 0;
260
[email protected]69b04b92010-11-08 22:12:18261 // BrowserThemeProvider calls this when a user has changed his or her theme,
262 // indicating that it's time to redraw everything.
263 virtual void UserChangedTheme() = 0;
264
265 // Get extra vertical height that the render view should add to its requests
266 // to webkit. This can help prevent sending extraneous layout/repaint requests
267 // when the delegate is in the process of resizing the tab contents view (e.g.
268 // during infobar animations).
269 virtual int GetExtraRenderViewHeight() const = 0;
270
271 // Notification that |tab_contents| got the focus through user action (click
272 // on the page).
273 virtual void TabContentsFocused(TabContents* tab_contents) = 0;
274
275 // Shows the page info using the specified information.
276 // |url| is the url of the page/frame the info applies to, |ssl| is the SSL
277 // information for that page/frame. If |show_history| is true, a section
278 // showing how many times that URL has been visited is added to the page info.
279 virtual void ShowPageInfo(Profile* profile,
280 const GURL& url,
281 const NavigationEntry::SSLStatus& ssl,
282 bool show_history) = 0;
283
284 // Shows the app menu (for accessibility).
285 virtual void ShowAppMenu() = 0;
286
287 // Allows the BrowserWindow object to handle the specified keyboard event
288 // before sending it to the renderer.
289 // Returns true if the |event| was handled. Otherwise, if the |event| would
290 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
291 // |*is_keyboard_shortcut| should be set to true.
292 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
293 bool* is_keyboard_shortcut) = 0;
294
295 // Allows the BrowserWindow object to handle the specified keyboard event,
296 // if the renderer did not process it.
297 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) = 0;
298
299 // Shows the create web app shortcut dialog box.
[email protected]a3b734b2010-11-30 03:17:11300 virtual void ShowCreateWebAppShortcutsDialog(TabContents* tab_contents) = 0;
301
302 // Shows the create chrome app shortcut dialog box.
303 virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
304 const Extension* app) = 0;
[email protected]69b04b92010-11-08 22:12:18305
306 // Clipboard commands applied to the whole browser window.
307 virtual void Cut() = 0;
308 virtual void Copy() = 0;
309 virtual void Paste() = 0;
310
311 // Switches between available tabstrip display modes.
312 virtual void ToggleTabStripMode() = 0;
313
314#if defined(OS_MACOSX)
315 // Opens the tabpose view.
316 virtual void OpenTabpose() = 0;
317#endif
318
[email protected]36d5e5592010-11-15 20:45:59319 // See InstantDelegate for details.
320 virtual void PrepareForInstant() = 0;
321
[email protected]69b04b92010-11-08 22:12:18322 // Invoked when instant's tab contents should be shown.
323 virtual void ShowInstant(TabContents* preview_contents) = 0;
324
325 // Invoked when the instant's tab contents should be hidden.
326 virtual void HideInstant() = 0;
327
328 // Returns the desired bounds for instant in screen coordinates. Note that if
329 // instant isn't currently visible this returns the bounds instant would be
330 // placed at.
331 virtual gfx::Rect GetInstantBounds() = 0;
332
333 // Construct a BrowserWindow implementation for the specified |browser|.
334 static BrowserWindow* CreateBrowserWindow(Browser* browser);
335
336 // Construct a FindBar implementation for the specified |browser|.
337 static FindBar* CreateFindBar(Browser* browser_window);
338
339 protected:
340 friend class BrowserList;
341 friend class BrowserView;
342 virtual void DestroyBrowser() = 0;
343
344 virtual ~BrowserWindow() {}
345};
346
347#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
348class BookmarkBarView;
349class LocationBarView;
350
351namespace views {
352class View;
353}
354#endif // defined(OS_WIN)
355
356// A BrowserWindow utility interface used for accessing elements of the browser
357// UI used only by UI test automation.
358class BrowserWindowTesting {
359 public:
360#if defined(OS_WIN) || defined(TOOLKIT_VIEWS)
361 // Returns the BookmarkBarView.
362 virtual BookmarkBarView* GetBookmarkBarView() const = 0;
363
364 // Returns the LocationBarView.
365 virtual LocationBarView* GetLocationBarView() const = 0;
366
367 // Returns the TabContentsContainer.
368 virtual views::View* GetTabContentsContainerView() const = 0;
369
370 // Returns the TabContentsContainer.
371 virtual views::View* GetSidebarContainerView() const = 0;
372
373 // Returns the ToolbarView.
374 virtual ToolbarView* GetToolbarView() const = 0;
375#endif
376
377 protected:
378 virtual ~BrowserWindowTesting() {}
379};
380
381#endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_