[email protected] | e41982a7 | 2012-11-20 07:16:51 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors. All rights reserved. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 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_ |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 7 | |
[email protected] | fe54b4a | 2012-03-28 16:11:04 | [diff] [blame] | 8 | #include "base/callback_forward.h" |
[email protected] | 2e9d79f | 2013-08-16 05:45:56 | [diff] [blame] | 9 | #include "chrome/browser/lifetime/browser_close_manager.h" |
[email protected] | bccf5ab | 2014-02-15 08:20:30 | [diff] [blame] | 10 | #include "chrome/browser/translate/translate_tab_helper.h" |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 11 | #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
[email protected] | edfca70 | 2013-08-16 08:58:14 | [diff] [blame] | 12 | #include "chrome/browser/ui/browser.h" |
[email protected] | 9d5c059a8 | 2012-06-29 20:13:07 | [diff] [blame] | 13 | #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" |
[email protected] | ddeb0e843 | 2012-12-21 07:27:54 | [diff] [blame] | 14 | #include "chrome/browser/ui/host_desktop.h" |
[email protected] | e4b66bf | 2012-05-29 20:39:51 | [diff] [blame] | 15 | #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 16 | #include "chrome/common/content_settings_types.h" |
[email protected] | eba93c9 | 2014-01-07 17:34:17 | [diff] [blame] | 17 | #include "components/translate/core/common/translate_errors.h" |
[email protected] | 5f39adc | 2013-05-23 11:50:46 | [diff] [blame] | 18 | #include "ui/base/base_window.h" |
[email protected] | f47621b | 2013-01-22 20:50:33 | [diff] [blame] | 19 | #include "ui/base/window_open_disposition.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 20 | #include "ui/gfx/native_widget_types.h" |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 21 | |
| 22 | class Browser; |
| 23 | class BrowserWindowTesting; |
| 24 | class DownloadShelf; |
| 25 | class FindBar; |
| 26 | class GURL; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 27 | class LocationBar; |
| 28 | class Profile; |
| 29 | class StatusBubble; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 30 | class TemplateURL; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 31 | #if !defined(OS_MACOSX) |
| 32 | class ToolbarView; |
| 33 | #endif |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 34 | |
[email protected] | 4660146 | 2014-02-04 11:08:50 | [diff] [blame] | 35 | struct WebApplicationInfo; |
| 36 | |
[email protected] | e0f90fc | 2012-06-06 19:30:10 | [diff] [blame] | 37 | namespace autofill { |
| 38 | class PasswordGenerator; |
[email protected] | e620d36 | 2013-09-09 08:01:53 | [diff] [blame] | 39 | struct PasswordForm; |
[email protected] | e0f90fc | 2012-06-06 19:30:10 | [diff] [blame] | 40 | } |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame] | 41 | namespace content { |
| 42 | class WebContents; |
[email protected] | b87ee52 | 2012-05-18 15:16:54 | [diff] [blame] | 43 | struct NativeWebKeyboardEvent; |
[email protected] | d583e3f2 | 2011-12-27 21:38:17 | [diff] [blame] | 44 | struct SSLStatus; |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame] | 45 | } |
| 46 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 47 | namespace extensions { |
| 48 | class Extension; |
| 49 | } |
| 50 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 51 | namespace gfx { |
| 52 | class Rect; |
[email protected] | 0548c535 | 2011-09-07 00:33:33 | [diff] [blame] | 53 | class Size; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 54 | } |
| 55 | |
[email protected] | e41d008 | 2013-05-16 04:37:54 | [diff] [blame] | 56 | namespace web_modal { |
| 57 | class WebContentsModalDialogHost; |
| 58 | } |
| 59 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 60 | //////////////////////////////////////////////////////////////////////////////// |
| 61 | // BrowserWindow interface |
| 62 | // An interface implemented by the "view" of the Browser window. |
[email protected] | 5f39adc | 2013-05-23 11:50:46 | [diff] [blame] | 63 | // This interface includes ui::BaseWindow methods as well as Browser window |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 64 | // specific methods. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 65 | // |
| 66 | // NOTE: All getters may return NULL. |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 67 | // |
[email protected] | 5f39adc | 2013-05-23 11:50:46 | [diff] [blame] | 68 | class BrowserWindow : public ui::BaseWindow { |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 69 | public: |
[email protected] | ed2f2713 | 2011-04-04 17:19:57 | [diff] [blame] | 70 | virtual ~BrowserWindow() {} |
| 71 | |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 72 | ////////////////////////////////////////////////////////////////////////////// |
[email protected] | 5f39adc | 2013-05-23 11:50:46 | [diff] [blame] | 73 | // ui::BaseWindow interface notes: |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 74 | |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 75 | // Closes the window as soon as possible. If the window is not in a drag |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 76 | // session, it will close immediately; otherwise, it will move offscreen (so |
| 77 | // events are still fired) until the drag ends, then close. This assumes |
| 78 | // that the Browser is not immediately destroyed, but will be eventually |
| 79 | // destroyed by other means (eg, the tab strip going to zero elements). |
| 80 | // Bad things happen if the Browser dtor is called directly as a result of |
| 81 | // invoking this method. |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 82 | // virtual void Close() = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 83 | |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 84 | // Browser::OnWindowDidShow should be called after showing the window. |
| 85 | // virtual void Show() = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 86 | |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 87 | ////////////////////////////////////////////////////////////////////////////// |
| 88 | // Browser specific methods: |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 89 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 90 | // Returns a pointer to the testing interface to the Browser window, or NULL |
| 91 | // if there is none. |
| 92 | virtual BrowserWindowTesting* GetBrowserWindowTesting() = 0; |
| 93 | |
| 94 | // Return the status bubble associated with the frame |
| 95 | virtual StatusBubble* GetStatusBubble() = 0; |
| 96 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 97 | // Inform the frame that the selected tab favicon or title has changed. Some |
| 98 | // frames may need to refresh their title bar. |
| 99 | virtual void UpdateTitleBar() = 0; |
| 100 | |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 101 | // Invoked when the state of the bookmark bar changes. This is only invoked if |
| 102 | // the state changes for the current tab, it is not sent when switching tabs. |
| 103 | virtual void BookmarkBarStateChanged( |
| 104 | BookmarkBar::AnimateChangeType change_type) = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 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 | |
[email protected] | 3917f82a | 2013-11-21 06:25:54 | [diff] [blame] | 118 | // Sets whether the translate icon is lit for the current tab. |
| 119 | virtual void SetTranslateIconToggled(bool is_lit) = 0; |
| 120 | |
[email protected] | 08726d5e | 2013-09-24 21:52:55 | [diff] [blame] | 121 | // Called when the active tab changes. Subclasses which implement |
| 122 | // TabStripModelObserver should implement this instead of ActiveTabChanged(); |
| 123 | // the Browser will call this method while processing that one. |
| 124 | virtual void OnActiveTabChanged(content::WebContents* old_contents, |
| 125 | content::WebContents* new_contents, |
| 126 | int index, |
| 127 | int reason) = 0; |
| 128 | |
[email protected] | 5423c37 | 2012-08-22 05:50:16 | [diff] [blame] | 129 | // Called to force the zoom state to for the active tab to be recalculated. |
| 130 | // |can_show_bubble| is true when a user presses the zoom up or down keyboard |
| 131 | // shortcuts and will be false in other cases (e.g. switching tabs, "clicking" |
| 132 | // + or - in the wrench menu to change zoom). |
| 133 | virtual void ZoomChangedForActiveTab(bool can_show_bubble) = 0; |
[email protected] | 6f80e93 | 2012-06-04 19:00:07 | [diff] [blame] | 134 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 135 | // Accessors for fullscreen mode state. |
[email protected] | 8d944b3 | 2011-10-17 06:11:53 | [diff] [blame] | 136 | virtual void EnterFullscreen(const GURL& url, |
| 137 | FullscreenExitBubbleType bubble_type) = 0; |
[email protected] | 55c87fa | 2011-10-15 07:28:28 | [diff] [blame] | 138 | virtual void ExitFullscreen() = 0; |
[email protected] | 8d944b3 | 2011-10-17 06:11:53 | [diff] [blame] | 139 | virtual void UpdateFullscreenExitBubbleContent( |
| 140 | const GURL& url, |
| 141 | FullscreenExitBubbleType bubble_type) = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 142 | |
[email protected] | 6a414ff | 2013-02-27 08:22:54 | [diff] [blame] | 143 | // Windows and GTK remove the top controls in fullscreen, but Mac and Ash |
| 144 | // keep the controls in a slide-down panel. |
| 145 | virtual bool ShouldHideUIForFullscreen() const = 0; |
| 146 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 147 | // Returns true if the fullscreen bubble is visible. |
| 148 | virtual bool IsFullscreenBubbleVisible() const = 0; |
| 149 | |
[email protected] | 77cbe50e | 2012-06-14 02:44:38 | [diff] [blame] | 150 | #if defined(OS_WIN) |
| 151 | // Sets state for entering or exiting Win8 Metro snap mode. |
| 152 | virtual void SetMetroSnapMode(bool enable) = 0; |
| 153 | |
| 154 | // Returns whether the window is currently in Win8 Metro snap mode. |
| 155 | virtual bool IsInMetroSnapMode() const = 0; |
| 156 | #endif |
| 157 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 158 | // Returns the location bar. |
| 159 | virtual LocationBar* GetLocationBar() const = 0; |
| 160 | |
| 161 | // Tries to focus the location bar. Clears the window focus (to avoid |
| 162 | // inconsistent state) if this fails. |
| 163 | virtual void SetFocusToLocationBar(bool select_all) = 0; |
| 164 | |
| 165 | // Informs the view whether or not a load is in progress for the current tab. |
| 166 | // The view can use this notification to update the reload/stop button. |
| 167 | virtual void UpdateReloadStopState(bool is_loading, bool force) = 0; |
| 168 | |
| 169 | // Updates the toolbar with the state for the specified |contents|. |
[email protected] | 2e7fe431 | 2013-08-21 17:19:48 | [diff] [blame] | 170 | virtual void UpdateToolbar(content::WebContents* contents) = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 171 | |
| 172 | // Focuses the toolbar (for accessibility). |
| 173 | virtual void FocusToolbar() = 0; |
| 174 | |
| 175 | // Focuses the app menu like it was a menu bar. |
| 176 | // |
| 177 | // Not used on the Mac, which has a "normal" menu bar. |
| 178 | virtual void FocusAppMenu() = 0; |
| 179 | |
| 180 | // Focuses the bookmarks toolbar (for accessibility). |
| 181 | virtual void FocusBookmarksToolbar() = 0; |
| 182 | |
[email protected] | 822ca8c6 | 2013-04-19 00:49:15 | [diff] [blame] | 183 | // Focuses an infobar, if shown (for accessibility). |
| 184 | virtual void FocusInfobars() = 0; |
| 185 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 186 | // Moves keyboard focus to the next pane. |
| 187 | virtual void RotatePaneFocus(bool forwards) = 0; |
| 188 | |
| 189 | // Returns whether the bookmark bar is visible or not. |
| 190 | virtual bool IsBookmarkBarVisible() const = 0; |
| 191 | |
| 192 | // Returns whether the bookmark bar is animating or not. |
| 193 | virtual bool IsBookmarkBarAnimating() const = 0; |
| 194 | |
[email protected] | 95bf8a5b | 2010-12-22 16:04:07 | [diff] [blame] | 195 | // Returns whether the tab strip is editable (for extensions). |
| 196 | virtual bool IsTabStripEditable() const = 0; |
| 197 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 198 | // Returns whether the tool bar is visible or not. |
| 199 | virtual bool IsToolbarVisible() const = 0; |
| 200 | |
[email protected] | b7a756d4 | 2012-01-23 18:08:17 | [diff] [blame] | 201 | // Returns the rect where the resize corner should be drawn by the render |
| 202 | // widget host view (on top of what the renderer returns). We return an empty |
| 203 | // rect to identify that there shouldn't be a resize corner (in the cases |
| 204 | // where we take care of it ourselves at the browser level). |
| 205 | virtual gfx::Rect GetRootWindowResizerRect() const = 0; |
| 206 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 207 | // Shows a confirmation dialog box for adding a search engine described by |
| 208 | // |template_url|. Takes ownership of |template_url|. |
[email protected] | 3613347d | 2012-04-27 20:27:37 | [diff] [blame] | 209 | virtual void ConfirmAddSearchProvider(TemplateURL* template_url, |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 210 | Profile* profile) = 0; |
| 211 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 212 | // Shows the Update Recommended dialog box. |
| 213 | virtual void ShowUpdateChromeDialog() = 0; |
| 214 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 215 | // Shows the Bookmark bubble. |url| is the URL being bookmarked, |
| 216 | // |already_bookmarked| is true if the url is already bookmarked. |
| 217 | virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0; |
| 218 | |
[email protected] | 4660146 | 2014-02-04 11:08:50 | [diff] [blame] | 219 | // Shows the Bookmark App bubble. |
| 220 | // See Extension::InitFromValueFlags::FROM_BOOKMARK for a description of |
| 221 | // bookmark apps. |
| 222 | // |
| 223 | // |web_app_info| is the WebApplicationInfo being converted into an app. |
| 224 | // |extension_id| is the id of the bookmark app. |
| 225 | virtual void ShowBookmarkAppBubble(const WebApplicationInfo& web_app_info, |
| 226 | const std::string& extension_id) = 0; |
| 227 | |
[email protected] | 195c99c | 2012-10-31 06:24:51 | [diff] [blame] | 228 | // Shows the bookmark prompt. |
| 229 | // TODO(yosin): Make ShowBookmarkPrompt pure virtual. |
| 230 | virtual void ShowBookmarkPrompt() {} |
| 231 | |
[email protected] | e625b760 | 2013-10-28 09:24:56 | [diff] [blame] | 232 | // Shows the translate bubble. |
[email protected] | bccf5ab | 2014-02-15 08:20:30 | [diff] [blame] | 233 | virtual void ShowTranslateBubble(content::WebContents* contents, |
| 234 | TranslateTabHelper::TranslateStep step, |
| 235 | TranslateErrors::Type error_type) = 0; |
[email protected] | e625b760 | 2013-10-28 09:24:56 | [diff] [blame] | 236 | |
[email protected] | 235a056 | 2012-03-26 22:22:35 | [diff] [blame] | 237 | #if defined(ENABLE_ONE_CLICK_SIGNIN) |
[email protected] | 265c927 | 2013-01-25 19:18:45 | [diff] [blame] | 238 | enum OneClickSigninBubbleType { |
| 239 | ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, |
[email protected] | 0cf5d28 | 2013-04-12 18:33:12 | [diff] [blame] | 240 | ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG, |
| 241 | ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG |
[email protected] | 265c927 | 2013-01-25 19:18:45 | [diff] [blame] | 242 | }; |
| 243 | |
[email protected] | e4b66bf | 2012-05-29 20:39:51 | [diff] [blame] | 244 | // Callback type used with the ShowOneClickSigninBubble() method. If the |
| 245 | // user chooses to accept the sign in, the callback is called to start the |
| 246 | // sync process. |
| 247 | typedef base::Callback<void(OneClickSigninSyncStarter::StartSyncMode)> |
| 248 | StartSyncCallback; |
| 249 | |
[email protected] | 0cf5d28 | 2013-04-12 18:33:12 | [diff] [blame] | 250 | // Shows the one-click sign in bubble. |email| holds the full email address |
| 251 | // of the account that has signed in. |
[email protected] | fe54b4a | 2012-03-28 16:11:04 | [diff] [blame] | 252 | virtual void ShowOneClickSigninBubble( |
[email protected] | 265c927 | 2013-01-25 19:18:45 | [diff] [blame] | 253 | OneClickSigninBubbleType type, |
[email protected] | dcd024987 | 2013-12-06 23:58:45 | [diff] [blame] | 254 | const base::string16& email, |
| 255 | const base::string16& error_message, |
[email protected] | e4b66bf | 2012-05-29 20:39:51 | [diff] [blame] | 256 | const StartSyncCallback& start_sync_callback) = 0; |
[email protected] | e625b760 | 2013-10-28 09:24:56 | [diff] [blame] | 257 | #endif |
[email protected] | 235a056 | 2012-03-26 22:22:35 | [diff] [blame] | 258 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 259 | // Whether or not the shelf view is visible. |
| 260 | virtual bool IsDownloadShelfVisible() const = 0; |
| 261 | |
| 262 | // Returns the DownloadShelf. |
| 263 | virtual DownloadShelf* GetDownloadShelf() = 0; |
| 264 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 265 | // Shows the confirmation dialog box warning that the browser is closing with |
| 266 | // in-progress downloads. |
[email protected] | edfca70 | 2013-08-16 08:58:14 | [diff] [blame] | 267 | // This method should call |callback| with the user's response. |
| 268 | virtual void ConfirmBrowserCloseWithPendingDownloads( |
| 269 | int download_count, |
| 270 | Browser::DownloadClosePreventionType dialog_type, |
| 271 | bool app_modal, |
| 272 | const base::Callback<void(bool)>& callback) = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 273 | |
[email protected] | a0ea76c | 2011-03-23 17:36:42 | [diff] [blame] | 274 | // ThemeService calls this when a user has changed his or her theme, |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 275 | // indicating that it's time to redraw everything. |
| 276 | virtual void UserChangedTheme() = 0; |
| 277 | |
| 278 | // Get extra vertical height that the render view should add to its requests |
| 279 | // to webkit. This can help prevent sending extraneous layout/repaint requests |
| 280 | // when the delegate is in the process of resizing the tab contents view (e.g. |
| 281 | // during infobar animations). |
| 282 | virtual int GetExtraRenderViewHeight() const = 0; |
| 283 | |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 284 | // Notification that |contents| got the focus through user action (click |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 285 | // on the page). |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 286 | virtual void WebContentsFocused(content::WebContents* contents) = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 287 | |
[email protected] | b8e681e8 | 2012-02-20 10:18:47 | [diff] [blame] | 288 | // Shows the website settings using the specified information. |url| is the |
| 289 | // url of the page/frame the info applies to, |ssl| is the SSL information for |
| 290 | // that page/frame. If |show_history| is true, a section showing how many |
| 291 | // times that URL has been visited is added to the page info. |
| 292 | virtual void ShowWebsiteSettings(Profile* profile, |
[email protected] | 36ad4aa8 | 2012-11-21 19:20:48 | [diff] [blame] | 293 | content::WebContents* web_contents, |
[email protected] | b8e681e8 | 2012-02-20 10:18:47 | [diff] [blame] | 294 | const GURL& url, |
[email protected] | 9fb47a8 | 2013-07-05 11:34:02 | [diff] [blame] | 295 | const content::SSLStatus& ssl) = 0; |
[email protected] | b8e681e8 | 2012-02-20 10:18:47 | [diff] [blame] | 296 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 297 | // Shows the app menu (for accessibility). |
| 298 | virtual void ShowAppMenu() = 0; |
| 299 | |
| 300 | // Allows the BrowserWindow object to handle the specified keyboard event |
| 301 | // before sending it to the renderer. |
| 302 | // Returns true if the |event| was handled. Otherwise, if the |event| would |
| 303 | // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut, |
| 304 | // |*is_keyboard_shortcut| should be set to true. |
[email protected] | b87ee52 | 2012-05-18 15:16:54 | [diff] [blame] | 305 | virtual bool PreHandleKeyboardEvent( |
| 306 | const content::NativeWebKeyboardEvent& event, |
| 307 | bool* is_keyboard_shortcut) = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 308 | |
| 309 | // Allows the BrowserWindow object to handle the specified keyboard event, |
| 310 | // if the renderer did not process it. |
[email protected] | b87ee52 | 2012-05-18 15:16:54 | [diff] [blame] | 311 | virtual void HandleKeyboardEvent( |
| 312 | const content::NativeWebKeyboardEvent& event) = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 313 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 314 | // Clipboard commands applied to the whole browser window. |
| 315 | virtual void Cut() = 0; |
| 316 | virtual void Copy() = 0; |
| 317 | virtual void Paste() = 0; |
| 318 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 319 | #if defined(OS_MACOSX) |
[email protected] | 34337d3 | 2013-01-29 20:29:01 | [diff] [blame] | 320 | // Enters Mac specific fullscreen mode with chrome displayed (e.g. omnibox) |
| 321 | // on OSX 10.7+, a.k.a. Lion Fullscreen mode. |
| 322 | // Invalid to call on OSX earlier than 10.7. |
| 323 | // Enters either from non fullscreen, or from fullscreen without chrome. |
| 324 | // Exit to normal fullscreen with EnterFullscreen(). |
| 325 | virtual void EnterFullscreenWithChrome() = 0; |
| 326 | virtual bool IsFullscreenWithChrome() = 0; |
| 327 | virtual bool IsFullscreenWithoutChrome() = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 328 | #endif |
| 329 | |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 330 | // Return the correct disposition for a popup window based on |bounds|. |
| 331 | virtual WindowOpenDisposition GetDispositionForPopupBounds( |
| 332 | const gfx::Rect& bounds) = 0; |
| 333 | |
[email protected] | 632983f | 2011-08-08 22:51:24 | [diff] [blame] | 334 | // Construct a FindBar implementation for the |browser|. |
| 335 | virtual FindBar* CreateFindBar() = 0; |
| 336 | |
[email protected] | 7519c52 | 2013-04-02 01:07:23 | [diff] [blame] | 337 | // Return the WebContentsModalDialogHost for use in positioning web contents |
[email protected] | 51e9149 | 2013-09-08 23:34:41 | [diff] [blame] | 338 | // modal dialogs within the browser window. This can sometimes be NULL (for |
| 339 | // instance during tab drag on Views/Win32). |
[email protected] | e41d008 | 2013-05-16 04:37:54 | [diff] [blame] | 340 | virtual web_modal::WebContentsModalDialogHost* |
| 341 | GetWebContentsModalDialogHost() = 0; |
[email protected] | 6a15176 | 2012-10-03 22:33:19 | [diff] [blame] | 342 | |
[email protected] | 0548c535 | 2011-09-07 00:33:33 | [diff] [blame] | 343 | // Invoked when the preferred size of the contents in current tab has been |
| 344 | // changed. We might choose to update the window size to accomodate this |
| 345 | // change. |
| 346 | // Note that this won't be fired if we change tabs. |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 347 | virtual void UpdatePreferredSize(content::WebContents* web_contents, |
[email protected] | 0548c535 | 2011-09-07 00:33:33 | [diff] [blame] | 348 | const gfx::Size& pref_size) {} |
| 349 | |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 350 | // Invoked when the contents auto-resized and the container should match it. |
| 351 | virtual void ResizeDueToAutoResize(content::WebContents* web_contents, |
| 352 | const gfx::Size& new_size) {} |
| 353 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 354 | // Construct a BrowserWindow implementation for the specified |browser|. |
| 355 | static BrowserWindow* CreateBrowserWindow(Browser* browser); |
| 356 | |
[email protected] | d5873769 | 2013-11-19 04:00:41 | [diff] [blame] | 357 | // Returns a HostDesktopType that is compatible with the current Chrome window |
| 358 | // configuration. On Windows with Ash, this is always HOST_DESKTOP_TYPE_ASH |
| 359 | // while Chrome is running in Metro mode. Otherwise returns |desktop_type|. |
| 360 | static chrome::HostDesktopType AdjustHostDesktopType( |
| 361 | chrome::HostDesktopType desktop_type); |
| 362 | |
[email protected] | 0ec4898e | 2011-12-30 21:09:24 | [diff] [blame] | 363 | // Shows the avatar bubble inside |web_contents|. The bubble is positioned |
| 364 | // relative to |rect|. |rect| should be in the |web_contents| coordinate |
[email protected] | 2f733a0 | 2011-10-06 15:17:34 | [diff] [blame] | 365 | // system. |
[email protected] | 0ec4898e | 2011-12-30 21:09:24 | [diff] [blame] | 366 | virtual void ShowAvatarBubble(content::WebContents* web_contents, |
[email protected] | 2f733a0 | 2011-10-06 15:17:34 | [diff] [blame] | 367 | const gfx::Rect& rect) = 0; |
| 368 | |
[email protected] | 7d2d0815 | 2011-10-25 22:58:47 | [diff] [blame] | 369 | // Shows the avatar bubble on the window frame off of the avatar button. |
| 370 | virtual void ShowAvatarBubbleFromAvatarButton() = 0; |
| 371 | |
[email protected] | e0f90fc | 2012-06-06 19:30:10 | [diff] [blame] | 372 | // Show bubble for password generation positioned relative to |rect|. The |
| 373 | // subclasses implementing this interface do not own the |password_generator| |
| 374 | // object which is passed to generate the password. |form| is the form that |
[email protected] | f5d230b3 | 2012-12-11 02:04:11 | [diff] [blame] | 375 | // contains the password field that the bubble will be associated with. |
[email protected] | 4d5ef869 | 2012-05-31 02:28:57 | [diff] [blame] | 376 | virtual void ShowPasswordGenerationBubble( |
| 377 | const gfx::Rect& rect, |
[email protected] | e620d36 | 2013-09-09 08:01:53 | [diff] [blame] | 378 | const autofill::PasswordForm& form, |
[email protected] | f5d230b3 | 2012-12-11 02:04:11 | [diff] [blame] | 379 | autofill::PasswordGenerator* password_generator) = 0; |
[email protected] | 90ee0923 | 2012-03-21 02:01:01 | [diff] [blame] | 380 | |
[email protected] | 888878e8 | 2013-07-24 22:49:40 | [diff] [blame] | 381 | // Invoked when the amount of vertical overscroll changes. |delta_y| is the |
| 382 | // amount of overscroll that has occured in the y-direction. |
| 383 | virtual void OverscrollUpdate(int delta_y) {} |
| 384 | |
[email protected] | dc0fd43 | 2013-08-27 15:29:21 | [diff] [blame] | 385 | // Returns the height inset for RenderView when detached bookmark bar is |
| 386 | // shown. Invoked when a new RenderHostView is created for a non-NTP |
| 387 | // navigation entry and the bookmark bar is detached. |
| 388 | virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() = 0; |
| 389 | |
[email protected] | ddc9239 | 2014-02-25 13:41:39 | [diff] [blame^] | 390 | // Shows the page action for the extension. |
| 391 | virtual void ShowPageActionPopup(const extensions::Extension* extension) = 0; |
| 392 | |
| 393 | // Shows the browser action for the extension. NOTE(wittman): This function |
| 394 | // grants tab permissions to the browser action popup, so it should only be |
| 395 | // invoked due to user action, not due to invocation from an extensions API. |
| 396 | virtual void ShowBrowserActionPopup( |
| 397 | const extensions::Extension* extension) = 0; |
| 398 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 399 | protected: |
[email protected] | 2e9d79f | 2013-08-16 05:45:56 | [diff] [blame] | 400 | friend class BrowserCloseManager; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 401 | friend class BrowserView; |
| 402 | virtual void DestroyBrowser() = 0; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 403 | }; |
| 404 | |
| 405 | #if defined(OS_WIN) || defined(TOOLKIT_VIEWS) |
| 406 | class BookmarkBarView; |
| 407 | class LocationBarView; |
| 408 | |
| 409 | namespace views { |
| 410 | class View; |
| 411 | } |
| 412 | #endif // defined(OS_WIN) |
| 413 | |
| 414 | // A BrowserWindow utility interface used for accessing elements of the browser |
| 415 | // UI used only by UI test automation. |
| 416 | class BrowserWindowTesting { |
| 417 | public: |
| 418 | #if defined(OS_WIN) || defined(TOOLKIT_VIEWS) |
| 419 | // Returns the BookmarkBarView. |
| 420 | virtual BookmarkBarView* GetBookmarkBarView() const = 0; |
| 421 | |
| 422 | // Returns the LocationBarView. |
| 423 | virtual LocationBarView* GetLocationBarView() const = 0; |
| 424 | |
| 425 | // Returns the TabContentsContainer. |
| 426 | virtual views::View* GetTabContentsContainerView() const = 0; |
| 427 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 428 | // Returns the ToolbarView. |
| 429 | virtual ToolbarView* GetToolbarView() const = 0; |
| 430 | #endif |
| 431 | |
| 432 | protected: |
| 433 | virtual ~BrowserWindowTesting() {} |
| 434 | }; |
| 435 | |
| 436 | #endif // CHROME_BROWSER_UI_BROWSER_WINDOW_H_ |