[email protected] | daa9e38 | 2012-01-06 00:30:34 | [diff] [blame] | 1 | // Copyright (c) 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_H_ |
| 6 | #define CHROME_BROWSER_UI_BROWSER_H_ |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 7 | |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 10 | #include <map> |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 11 | #include <memory> |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 12 | #include <set> |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
[email protected] | a0366a5 | 2011-02-04 20:04:21 | [diff] [blame] | 16 | #include "base/compiler_specific.h" |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 17 | #include "base/gtest_prod_util.h" |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 18 | #include "base/macros.h" |
[email protected] | 24f147753 | 2011-11-22 22:55:36 | [diff] [blame] | 19 | #include "base/memory/weak_ptr.h" |
jitendra.ks | a005553 | 2014-10-07 05:54:46 | [diff] [blame] | 20 | #include "base/scoped_observer.h" |
[email protected] | 1152118 | 2013-06-11 04:06:36 | [diff] [blame] | 21 | #include "base/strings/string16.h" |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 22 | #include "build/build_config.h" |
[email protected] | 7001915 | 2012-12-19 11:44:19 | [diff] [blame] | 23 | #include "chrome/browser/devtools/devtools_toggle_action.h" |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 24 | #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
[email protected] | 35699d57 | 2011-05-11 19:46:14 | [diff] [blame] | 25 | #include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h" |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 26 | #include "chrome/browser/ui/browser_navigator.h" |
hcarmona | aa431c0 | 2015-08-28 18:45:57 | [diff] [blame] | 27 | #include "chrome/browser/ui/chrome_bubble_manager.h" |
[email protected] | e41d008 | 2013-05-16 04:37:54 | [diff] [blame] | 28 | #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" |
sriramsr | a41db56 | 2015-01-26 22:45:04 | [diff] [blame] | 29 | #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
anthonyvd | e659ee9 | 2016-02-04 23:16:56 | [diff] [blame] | 30 | #include "chrome/browser/ui/profile_chooser_constants.h" |
[email protected] | 82808d0 | 2014-04-10 00:10:59 | [diff] [blame] | 31 | #include "chrome/browser/ui/search/search_tab_helper_delegate.h" |
anthonyvd | e659ee9 | 2016-02-04 23:16:56 | [diff] [blame] | 32 | #include "chrome/browser/ui/signin_view_controller.h" |
[email protected] | 51d83bdf | 2011-12-09 16:09:29 | [diff] [blame] | 33 | #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
[email protected] | b56e2e3 | 2012-05-11 21:18:04 | [diff] [blame] | 34 | #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
mukai | 077089f | 2014-09-11 18:41:52 | [diff] [blame] | 35 | #include "components/content_settings/core/common/content_settings.h" |
[email protected] | 08f7101 | 2014-07-25 10:27:54 | [diff] [blame] | 36 | #include "components/content_settings/core/common/content_settings_types.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 37 | #include "components/prefs/pref_change_registrar.h" |
| 38 | #include "components/prefs/pref_member.h" |
blundell | 47c6d8a | 2015-09-24 11:06:40 | [diff] [blame] | 39 | #include "components/sessions/core/session_id.h" |
blundell | 11d93bc | 2015-07-31 12:33:12 | [diff] [blame] | 40 | #include "components/toolbar/toolbar_model.h" |
pkasting | cc29d20e | 2015-02-25 06:05:53 | [diff] [blame] | 41 | #include "components/translate/content/browser/content_translate_driver.h" |
juncai | a64f769c2 | 2016-06-04 00:55:32 | [diff] [blame] | 42 | #include "components/zoom/zoom_observer.h" |
[email protected] | a6a7ced | 2012-11-01 17:24:18 | [diff] [blame] | 43 | #include "content/public/browser/notification_observer.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 44 | #include "content/public/browser/notification_registrar.h" |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 45 | #include "content/public/browser/page_navigator.h" |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 46 | #include "content/public/browser/web_contents_delegate.h" |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 47 | #include "content/public/common/page_zoom.h" |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 48 | #include "ui/base/page_transition_types.h" |
[email protected] | 400eaf8 | 2011-08-22 15:47:39 | [diff] [blame] | 49 | #include "ui/base/ui_base_types.h" |
[email protected] | 1867c74 | 2013-01-23 01:25:24 | [diff] [blame] | 50 | #include "ui/base/window_open_disposition.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 51 | #include "ui/gfx/geometry/rect.h" |
[email protected] | 4344a3c | 2013-01-17 23:49:20 | [diff] [blame] | 52 | #include "ui/shell_dialogs/select_file_dialog.h" |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 53 | |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 54 | #if defined(ENABLE_EXTENSIONS) |
| 55 | #include "extensions/browser/extension_registry_observer.h" |
| 56 | #endif |
| 57 | |
[email protected] | ef55702 | 2012-03-16 10:05:33 | [diff] [blame] | 58 | class BrowserContentSettingBubbleModelDelegate; |
[email protected] | 165fe42 | 2013-03-27 06:34:03 | [diff] [blame] | 59 | class BrowserInstantController; |
[email protected] | afefa74e | 2011-07-26 05:04:23 | [diff] [blame] | 60 | class BrowserSyncedWindowDelegate; |
[email protected] | ef55702 | 2012-03-16 10:05:33 | [diff] [blame] | 61 | class BrowserToolbarModelDelegate; |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 62 | class BrowserLiveTabContext; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 63 | class BrowserWindow; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 64 | class FindBarController; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 65 | class PrefService; |
| 66 | class Profile; |
dgn | fe075c8 | 2016-03-18 11:25:35 | [diff] [blame] | 67 | class ScopedKeepAlive; |
[email protected] | 165fe42 | 2013-03-27 06:34:03 | [diff] [blame] | 68 | class SearchDelegate; |
| 69 | class SearchModel; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 70 | class StatusBubble; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 71 | class TabStripModel; |
[email protected] | 85537005 | 2012-07-10 19:30:32 | [diff] [blame] | 72 | class TabStripModelDelegate; |
andresantoso | 49f9a7a | 2015-01-28 00:03:17 | [diff] [blame] | 73 | class ValidationMessageBubble; |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 74 | struct WebApplicationInfo; |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 75 | |
[email protected] | e3a5d5b | 2012-06-22 17:56:46 | [diff] [blame] | 76 | namespace chrome { |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 77 | class BrowserCommandController; |
[email protected] | 88c9201 | 2013-07-02 11:56:34 | [diff] [blame] | 78 | class FastUnloadController; |
[email protected] | f9b6c09 | 2012-07-09 19:32:28 | [diff] [blame] | 79 | class UnloadController; |
[email protected] | e3a5d5b | 2012-06-22 17:56:46 | [diff] [blame] | 80 | } |
| 81 | |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 82 | namespace content { |
| 83 | class NavigationController; |
[email protected] | 691aa2f | 2013-05-28 22:52:04 | [diff] [blame] | 84 | class PageState; |
[email protected] | adbfb8df | 2012-02-24 01:19:43 | [diff] [blame] | 85 | class SessionStorageNamespace; |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 86 | } |
| 87 | |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 88 | namespace extensions { |
benwells | 11bd6ed | 2015-06-05 04:20:41 | [diff] [blame] | 89 | class HostedAppBrowserController; |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 90 | class Extension; |
jitendra.ks | a005553 | 2014-10-07 05:54:46 | [diff] [blame] | 91 | class ExtensionRegistry; |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame] | 92 | class WindowController; |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 93 | } |
| 94 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 95 | namespace gfx { |
[email protected] | 9b125b73 | 2012-08-17 04:43:55 | [diff] [blame] | 96 | class Image; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 97 | class Point; |
| 98 | } |
| 99 | |
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 100 | namespace ui { |
[email protected] | 53f04c8 | 2012-07-26 02:31:09 | [diff] [blame] | 101 | struct SelectedFileInfo; |
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 102 | class WebDialogDelegate; |
| 103 | } |
| 104 | |
[email protected] | e41d008 | 2013-05-16 04:37:54 | [diff] [blame] | 105 | namespace web_modal { |
| 106 | class WebContentsModalDialogHost; |
| 107 | } |
| 108 | |
[email protected] | 85537005 | 2012-07-10 19:30:32 | [diff] [blame] | 109 | class Browser : public TabStripModelObserver, |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 110 | public content::WebContentsDelegate, |
[email protected] | 51d83bdf | 2011-12-09 16:09:29 | [diff] [blame] | 111 | public CoreTabHelperDelegate, |
[email protected] | 82808d0 | 2014-04-10 00:10:59 | [diff] [blame] | 112 | public SearchTabHelperDelegate, |
[email protected] | e41d008 | 2013-05-16 04:37:54 | [diff] [blame] | 113 | public ChromeWebModalDialogManagerDelegate, |
[email protected] | 35699d57 | 2011-05-11 19:46:14 | [diff] [blame] | 114 | public BookmarkTabHelperDelegate, |
juncai | a64f769c2 | 2016-06-04 00:55:32 | [diff] [blame] | 115 | public zoom::ZoomObserver, |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 116 | public content::PageNavigator, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 117 | public content::NotificationObserver, |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 118 | #if defined(ENABLE_EXTENSIONS) |
jitendra.ks | a005553 | 2014-10-07 05:54:46 | [diff] [blame] | 119 | public extensions::ExtensionRegistryObserver, |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 120 | #endif |
pkasting | cc29d20e | 2015-02-25 06:05:53 | [diff] [blame] | 121 | public translate::ContentTranslateDriver::Observer, |
[email protected] | 379329b3 | 2013-07-11 05:58:52 | [diff] [blame] | 122 | public ui::SelectFileDialog::Listener { |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 123 | public: |
[email protected] | 94ce725 | 2010-12-20 21:46:33 | [diff] [blame] | 124 | // SessionService::WindowType mirrors these values. If you add to this |
| 125 | // enum, look at SessionService::WindowType to see if it needs to be |
| 126 | // updated. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 127 | enum Type { |
[email protected] | de4943f | 2011-07-28 16:25:14 | [diff] [blame] | 128 | // If you add a new type, consider updating the test |
| 129 | // BrowserTest.StartMaximized. |
[email protected] | 2a3b5943 | 2011-07-26 18:38:38 | [diff] [blame] | 130 | TYPE_TABBED = 1, |
[email protected] | 7efaed36 | 2013-04-04 09:33:32 | [diff] [blame] | 131 | TYPE_POPUP = 2 |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | // Possible elements of the Browser window. |
| 135 | enum WindowFeature { |
| 136 | FEATURE_NONE = 0, |
| 137 | FEATURE_TITLEBAR = 1, |
| 138 | FEATURE_TABSTRIP = 2, |
| 139 | FEATURE_TOOLBAR = 4, |
| 140 | FEATURE_LOCATIONBAR = 8, |
| 141 | FEATURE_BOOKMARKBAR = 16, |
| 142 | FEATURE_INFOBAR = 32, |
benwells | 502df69 | 2014-12-02 20:41:45 | [diff] [blame] | 143 | FEATURE_DOWNLOADSHELF = 64, |
| 144 | FEATURE_WEBAPPFRAME = 128 |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 145 | }; |
| 146 | |
[email protected] | 5a17d49 | 2011-10-24 19:37:03 | [diff] [blame] | 147 | // The context for a download blocked notification from |
| 148 | // OkToCloseWithInProgressDownloads. |
| 149 | enum DownloadClosePreventionType { |
| 150 | // Browser close is not blocked by download state. |
| 151 | DOWNLOAD_CLOSE_OK, |
| 152 | |
| 153 | // The browser is shutting down and there are active downloads |
| 154 | // that would be cancelled. |
| 155 | DOWNLOAD_CLOSE_BROWSER_SHUTDOWN, |
| 156 | |
| 157 | // There are active downloads associated with this incognito profile |
| 158 | // that would be canceled. |
| 159 | DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE, |
| 160 | }; |
| 161 | |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 162 | struct CreateParams { |
scottmg | 85194900 | 2016-02-09 20:09:44 | [diff] [blame] | 163 | explicit CreateParams(Profile* profile); |
| 164 | CreateParams(Type type, Profile* profile); |
vmpstr | b8aacbe | 2016-02-26 02:00:48 | [diff] [blame] | 165 | CreateParams(const CreateParams& other); |
[email protected] | 9265536 | 2012-04-20 21:33:17 | [diff] [blame] | 166 | |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 167 | static CreateParams CreateForApp(const std::string& app_name, |
| 168 | bool trusted_source, |
[email protected] | da22aa6 | 2012-04-04 18:54:35 | [diff] [blame] | 169 | const gfx::Rect& window_bounds, |
scottmg | 85194900 | 2016-02-09 20:09:44 | [diff] [blame] | 170 | Profile* profile); |
[email protected] | da22aa6 | 2012-04-04 18:54:35 | [diff] [blame] | 171 | |
scottmg | 85194900 | 2016-02-09 20:09:44 | [diff] [blame] | 172 | static CreateParams CreateForDevTools(Profile* profile); |
[email protected] | da22aa6 | 2012-04-04 18:54:35 | [diff] [blame] | 173 | |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 174 | // The browser type. |
| 175 | Type type; |
| 176 | |
| 177 | // The associated profile. |
| 178 | Profile* profile; |
| 179 | |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 180 | // Specifies the browser is_trusted_source_ value. |
| 181 | bool trusted_source; |
[email protected] | 0da5829 | 2012-03-22 20:37:21 | [diff] [blame] | 182 | |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 183 | // The bounds of the window to open. |
| 184 | gfx::Rect initial_bounds; |
[email protected] | a636d8e5 | 2012-02-28 15:40:41 | [diff] [blame] | 185 | |
thomasanderson | 06405c5 | 2016-05-03 22:52:22 | [diff] [blame] | 186 | // The workspace the window should open in, if the platform supports it. |
| 187 | std::string initial_workspace; |
| 188 | |
[email protected] | a636d8e5 | 2012-02-28 15:40:41 | [diff] [blame] | 189 | ui::WindowShowState initial_show_state; |
| 190 | |
| 191 | bool is_session_restore; |
[email protected] | a4fe6701 | 2012-07-25 20:14:29 | [diff] [blame] | 192 | |
| 193 | // Supply a custom BrowserWindow implementation, to be used instead of the |
| 194 | // default. Intended for testing. |
| 195 | BrowserWindow* window; |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 196 | |
| 197 | private: |
| 198 | friend class Browser; |
| 199 | |
| 200 | // The application name that is also the name of the window to the shell. |
| 201 | // Do not set this value directly, use CreateForApp. |
| 202 | // This name will be set for: |
| 203 | // 1) v1 applications launched via an application shortcut or extension API. |
| 204 | // 2) undocked devtool windows. |
| 205 | // 3) popup windows spawned from v1 applications. |
| 206 | std::string app_name; |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 207 | }; |
| 208 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 209 | // Constructors, Creation, Showing ////////////////////////////////////////// |
| 210 | |
[email protected] | a4fe6701 | 2012-07-25 20:14:29 | [diff] [blame] | 211 | explicit Browser(const CreateParams& params); |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 212 | ~Browser() override; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 213 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 214 | // Set overrides for the initial window bounds and maximized state. |
| 215 | void set_override_bounds(const gfx::Rect& bounds) { |
| 216 | override_bounds_ = bounds; |
| 217 | } |
[email protected] | 1f0b50b | 2012-06-22 20:37:16 | [diff] [blame] | 218 | ui::WindowShowState initial_show_state() const { return initial_show_state_; } |
| 219 | void set_initial_show_state(ui::WindowShowState initial_show_state) { |
| 220 | initial_show_state_ = initial_show_state; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 221 | } |
| 222 | // Return true if the initial window bounds have been overridden. |
| 223 | bool bounds_overridden() const { |
| 224 | return !override_bounds_.IsEmpty(); |
| 225 | } |
[email protected] | 8bc061f | 2011-08-31 22:46:23 | [diff] [blame] | 226 | // Set indicator that this browser is being created via session restore. |
| 227 | // This is used on the Mac (only) to determine animation style when the |
| 228 | // browser window is shown. |
| 229 | void set_is_session_restore(bool is_session_restore) { |
| 230 | is_session_restore_ = is_session_restore; |
| 231 | } |
| 232 | bool is_session_restore() const { |
| 233 | return is_session_restore_; |
| 234 | } |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 235 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 236 | // Accessors //////////////////////////////////////////////////////////////// |
| 237 | |
| 238 | Type type() const { return type_; } |
[email protected] | b2e88d8 | 2011-03-09 19:11:53 | [diff] [blame] | 239 | const std::string& app_name() const { return app_name_; } |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 240 | bool is_trusted_source() const { return is_trusted_source_; } |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 241 | Profile* profile() const { return profile_; } |
[email protected] | fe90ca8e | 2011-04-08 20:40:43 | [diff] [blame] | 242 | gfx::Rect override_bounds() const { return override_bounds_; } |
thomasanderson | 06405c5 | 2016-05-03 22:52:22 | [diff] [blame] | 243 | const std::string& initial_workspace() const { return initial_workspace_; } |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 244 | |
[email protected] | eea624c | 2011-01-10 20:33:38 | [diff] [blame] | 245 | // |window()| will return NULL if called before |CreateBrowserWindow()| |
| 246 | // is done. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 247 | BrowserWindow* window() const { return window_; } |
[email protected] | ef55702 | 2012-03-16 10:05:33 | [diff] [blame] | 248 | ToolbarModel* toolbar_model() { return toolbar_model_.get(); } |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 249 | const ToolbarModel* toolbar_model() const { return toolbar_model_.get(); } |
[email protected] | a40be8b | 2013-08-22 20:12:14 | [diff] [blame] | 250 | #if defined(UNIT_TEST) |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 251 | void swap_toolbar_models(std::unique_ptr<ToolbarModel>* toolbar_model) { |
[email protected] | a40be8b | 2013-08-22 20:12:14 | [diff] [blame] | 252 | toolbar_model->swap(toolbar_model_); |
| 253 | } |
| 254 | #endif |
[email protected] | 04e3ead5 | 2013-01-14 01:09:20 | [diff] [blame] | 255 | TabStripModel* tab_strip_model() const { return tab_strip_model_.get(); } |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 256 | chrome::BrowserCommandController* command_controller() { |
| 257 | return command_controller_.get(); |
| 258 | } |
[email protected] | 165fe42 | 2013-03-27 06:34:03 | [diff] [blame] | 259 | SearchModel* search_model() { return search_model_.get(); } |
| 260 | const SearchModel* search_model() const { |
[email protected] | 43aafff | 2012-06-29 21:20:49 | [diff] [blame] | 261 | return search_model_.get(); |
| 262 | } |
[email protected] | 165fe42 | 2013-03-27 06:34:03 | [diff] [blame] | 263 | SearchDelegate* search_delegate() { |
[email protected] | 9331c3f | 2012-06-27 23:17:16 | [diff] [blame] | 264 | return search_delegate_.get(); |
| 265 | } |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 266 | const SessionID& session_id() const { return session_id_; } |
[email protected] | ef55702 | 2012-03-16 10:05:33 | [diff] [blame] | 267 | BrowserContentSettingBubbleModelDelegate* |
| 268 | content_setting_bubble_model_delegate() { |
| 269 | return content_setting_bubble_model_delegate_.get(); |
| 270 | } |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 271 | BrowserLiveTabContext* live_tab_context() { return live_tab_context_.get(); } |
[email protected] | afefa74e | 2011-07-26 05:04:23 | [diff] [blame] | 272 | BrowserSyncedWindowDelegate* synced_window_delegate() { |
| 273 | return synced_window_delegate_.get(); |
| 274 | } |
[email protected] | 165fe42 | 2013-03-27 06:34:03 | [diff] [blame] | 275 | BrowserInstantController* instant_controller() { |
[email protected] | 7acfaf9 | 2012-07-11 15:51:59 | [diff] [blame] | 276 | return instant_controller_.get(); |
| 277 | } |
benwells | 11bd6ed | 2015-06-05 04:20:41 | [diff] [blame] | 278 | extensions::HostedAppBrowserController* hosted_app_controller() { |
| 279 | return hosted_app_controller_.get(); |
benwells | a2a8a9f7 | 2015-04-07 07:09:54 | [diff] [blame] | 280 | } |
anthonyvd | 0ac524a | 2016-04-05 18:17:52 | [diff] [blame] | 281 | SigninViewController* signin_view_controller() { |
| 282 | return &signin_view_controller_; |
| 283 | } |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 284 | |
hcarmona | aa431c0 | 2015-08-28 18:45:57 | [diff] [blame] | 285 | // Will lazy create the bubble manager. |
| 286 | ChromeBubbleManager* GetBubbleManager(); |
| 287 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 288 | // Get the FindBarController for this browser, creating it if it does not |
| 289 | // yet exist. |
| 290 | FindBarController* GetFindBarController(); |
| 291 | |
| 292 | // Returns true if a FindBarController exists for this browser. |
| 293 | bool HasFindBarController() const; |
| 294 | |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 295 | // Returns the state of the bookmark bar. |
| 296 | BookmarkBar::State bookmark_bar_state() const { return bookmark_bar_state_; } |
| 297 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 298 | // State Storage and Retrieval for UI /////////////////////////////////////// |
| 299 | |
[email protected] | abc2f26 | 2011-03-15 21:15:44 | [diff] [blame] | 300 | // Gets the Favicon of the page in the selected tab. |
[email protected] | 9b125b73 | 2012-08-17 04:43:55 | [diff] [blame] | 301 | gfx::Image GetCurrentPageIcon() const; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 302 | |
| 303 | // Gets the title of the window based on the selected tab's title. |
varkha | 48f84c4b | 2016-06-27 18:10:33 | [diff] [blame] | 304 | // Disables additional formatting when |include_app_name| is false. |
| 305 | base::string16 GetWindowTitleForCurrentTab(bool include_app_name) const; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 306 | |
| 307 | // Prepares a title string for display (removes embedded newlines, etc). |
[email protected] | b959d7d4 | 2013-12-13 17:26:37 | [diff] [blame] | 308 | static void FormatTitleForDisplay(base::string16* title); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 309 | |
| 310 | // OnBeforeUnload handling ////////////////////////////////////////////////// |
| 311 | |
[email protected] | 2e9d79f | 2013-08-16 05:45:56 | [diff] [blame] | 312 | // Gives beforeunload handlers the chance to cancel the close. Returns whether |
| 313 | // to proceed with the close. If called while the process begun by |
| 314 | // CallBeforeUnloadHandlers is in progress, returns false without taking |
| 315 | // action. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 316 | bool ShouldCloseWindow(); |
| 317 | |
[email protected] | 2e9d79f | 2013-08-16 05:45:56 | [diff] [blame] | 318 | // Begins the process of confirming whether the associated browser can be |
| 319 | // closed. If there are no tabs with beforeunload handlers it will immediately |
| 320 | // return false. Otherwise, it starts prompting the user, returns true and |
| 321 | // will call |on_close_confirmed| with the result of the user's decision. |
| 322 | // After calling this function, if the window will not be closed, call |
| 323 | // ResetBeforeUnloadHandlers() to reset all beforeunload handlers; calling |
| 324 | // this function multiple times without an intervening call to |
| 325 | // ResetBeforeUnloadHandlers() will run only the beforeunload handlers |
| 326 | // registered since the previous call. |
| 327 | bool CallBeforeUnloadHandlers( |
| 328 | const base::Callback<void(bool)>& on_close_confirmed); |
| 329 | |
| 330 | // Clears the results of any beforeunload confirmation dialogs triggered by a |
| 331 | // CallBeforeUnloadHandlers call. |
| 332 | void ResetBeforeUnloadHandlers(); |
| 333 | |
[email protected] | 88c9201 | 2013-07-02 11:56:34 | [diff] [blame] | 334 | // Figure out if there are tabs that have beforeunload handlers. |
| 335 | // It starts beforeunload/unload processing as a side-effect. |
| 336 | bool TabsNeedBeforeUnloadFired(); |
| 337 | |
| 338 | // Returns true if all tabs' beforeunload/unload events have fired. |
| 339 | bool HasCompletedUnloadProcessing() const; |
| 340 | |
[email protected] | f9b6c09 | 2012-07-09 19:32:28 | [diff] [blame] | 341 | bool IsAttemptingToCloseBrowser() const; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 342 | |
| 343 | // Invoked when the window containing us is closing. Performs the necessary |
| 344 | // cleanup. |
| 345 | void OnWindowClosing(); |
| 346 | |
| 347 | // In-progress download termination handling ///////////////////////////////// |
| 348 | |
| 349 | // Called when the user has decided whether to proceed or not with the browser |
| 350 | // closure. |cancel_downloads| is true if the downloads should be canceled |
| 351 | // and the browser closed, false if the browser should stay open and the |
| 352 | // downloads running. |
| 353 | void InProgressDownloadResponse(bool cancel_downloads); |
| 354 | |
[email protected] | 5a17d49 | 2011-10-24 19:37:03 | [diff] [blame] | 355 | // Indicates whether or not this browser window can be closed, or |
| 356 | // would be blocked by in-progress downloads. |
| 357 | // If executing downloads would be cancelled by this window close, |
| 358 | // then |*num_downloads_blocking| is updated with how many downloads |
| 359 | // would be canceled if the close continued. |
| 360 | DownloadClosePreventionType OkToCloseWithInProgressDownloads( |
| 361 | int* num_downloads_blocking) const; |
| 362 | |
[email protected] | c2afee41 | 2013-08-12 05:11:58 | [diff] [blame] | 363 | // External state change handling //////////////////////////////////////////// |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 364 | |
[email protected] | 227393e | 2011-06-29 21:28:39 | [diff] [blame] | 365 | // Invoked when the fullscreen state of the window changes. |
[email protected] | 55c87fa | 2011-10-15 07:28:28 | [diff] [blame] | 366 | // BrowserWindow::EnterFullscreen invokes this after the window has become |
[email protected] | 227393e | 2011-06-29 21:28:39 | [diff] [blame] | 367 | // fullscreen. |
| 368 | void WindowFullscreenStateChanged(); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 369 | |
| 370 | // Assorted browser commands //////////////////////////////////////////////// |
| 371 | |
| 372 | // NOTE: Within each of the following sections, the IDs are ordered roughly by |
| 373 | // how they appear in the GUI/menus (left to right, top to bottom, etc.). |
| 374 | |
[email protected] | 184717d5 | 2012-02-22 04:46:16 | [diff] [blame] | 375 | // See the description of |
| 376 | // FullscreenController::ToggleFullscreenModeWithExtension. |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 377 | void ToggleFullscreenModeWithExtension(const GURL& extension_url); |
[email protected] | 8ee0654 | 2014-04-20 22:29:10 | [diff] [blame] | 378 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 379 | // Returns true if the Browser supports the specified feature. The value of |
| 380 | // this varies during the lifetime of the browser. For example, if the window |
| 381 | // is fullscreen this may return a different value. If you only care about |
| 382 | // whether or not it's possible for the browser to support a particular |
| 383 | // feature use |CanSupportWindowFeature|. |
| 384 | bool SupportsWindowFeature(WindowFeature feature) const; |
| 385 | |
| 386 | // Returns true if the Browser can support the specified feature. See comment |
| 387 | // in |SupportsWindowFeature| for details on this. |
| 388 | bool CanSupportWindowFeature(WindowFeature feature) const; |
| 389 | |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 390 | // TODO(port): port these, and re-merge the two function declaration lists. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 391 | // Page-related commands. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 392 | void ToggleEncodingAutoDetect(); |
| 393 | void OverrideEncoding(int encoding_id); |
| 394 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 395 | // Show various bits of UI |
| 396 | void OpenFile(); |
[email protected] | 3a8b69b8 | 2012-06-25 13:01:07 | [diff] [blame] | 397 | |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 398 | void UpdateDownloadShelfVisibility(bool visible); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 399 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 400 | ///////////////////////////////////////////////////////////////////////////// |
| 401 | |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 402 | // Called by chrome::Navigate() when a navigation has occurred in a tab in |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 403 | // this Browser. Updates the UI for the start of this navigation. |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 404 | void UpdateUIForNavigationInTab(content::WebContents* contents, |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 405 | ui::PageTransition transition, |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 406 | bool user_initiated); |
| 407 | |
anthonyvd | e659ee9 | 2016-02-04 23:16:56 | [diff] [blame] | 408 | // Shows the signin flow for |mode| in a tab-modal dialog. |
| 409 | // |access_point| indicates the access point used to open the Gaia sign in |
| 410 | // page. |
| 411 | void ShowModalSigninWindow(profiles::BubbleViewMode mode, |
| 412 | signin_metrics::AccessPoint access_point); |
| 413 | |
| 414 | // Closes the tab-modal signin flow opened with ShowModalSigninWindow, if it's |
| 415 | // open. Does nothing otherwise. |
| 416 | void CloseModalSigninWindow(); |
| 417 | |
| 418 | // Shows the tab modal sync confirmation dialog that informs the user about |
| 419 | // sync and gives them a chance to abort signin under the tab modal signin |
| 420 | // flow. |
| 421 | void ShowModalSyncConfirmationWindow(); |
| 422 | |
dgn | fe075c8 | 2016-03-18 11:25:35 | [diff] [blame] | 423 | // Used to register a KeepAlive to affect the Chrome lifetime. The KeepAlive |
| 424 | // is registered when the browser is added to the browser list, and unregisted |
| 425 | // when it is removed from it. |
| 426 | void RegisterKeepAlive(); |
| 427 | void UnregisterKeepAlive(); |
| 428 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 429 | // Interface implementations //////////////////////////////////////////////// |
| 430 | |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 431 | // Overridden from content::PageNavigator: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 432 | content::WebContents* OpenURL(const content::OpenURLParams& params) override; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 433 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 434 | // Overridden from TabStripModelObserver: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 435 | void TabInsertedAt(content::WebContents* contents, |
| 436 | int index, |
| 437 | bool foreground) override; |
| 438 | void TabClosingAt(TabStripModel* tab_strip_model, |
| 439 | content::WebContents* contents, |
| 440 | int index) override; |
| 441 | void TabDetachedAt(content::WebContents* contents, int index) override; |
| 442 | void TabDeactivated(content::WebContents* contents) override; |
| 443 | void ActiveTabChanged(content::WebContents* old_contents, |
| 444 | content::WebContents* new_contents, |
| 445 | int index, |
| 446 | int reason) override; |
| 447 | void TabMoved(content::WebContents* contents, |
| 448 | int from_index, |
| 449 | int to_index) override; |
| 450 | void TabReplacedAt(TabStripModel* tab_strip_model, |
| 451 | content::WebContents* old_contents, |
| 452 | content::WebContents* new_contents, |
| 453 | int index) override; |
| 454 | void TabPinnedStateChanged(content::WebContents* contents, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 455 | int index) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 456 | void TabStripEmpty() override; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 457 | |
[email protected] | fc76114 | 2012-06-08 04:49:20 | [diff] [blame] | 458 | // Overridden from content::WebContentsDelegate: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 459 | bool CanOverscrollContent() const override; |
| 460 | bool ShouldPreserveAbortedURLs(content::WebContents* source) override; |
calamity | 6160055c | 2015-04-30 06:45:26 | [diff] [blame] | 461 | void SetFocusToLocationBar(bool select_all) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 462 | bool PreHandleKeyboardEvent(content::WebContents* source, |
| 463 | const content::NativeWebKeyboardEvent& event, |
| 464 | bool* is_keyboard_shortcut) override; |
| 465 | void HandleKeyboardEvent( |
[email protected] | b3996ba | 2012-08-08 00:39:13 | [diff] [blame] | 466 | content::WebContents* source, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 467 | const content::NativeWebKeyboardEvent& event) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 468 | void ShowValidationMessage(content::WebContents* web_contents, |
| 469 | const gfx::Rect& anchor_in_root_view, |
| 470 | const base::string16& main_text, |
| 471 | const base::string16& sub_text) override; |
| 472 | void HideValidationMessage(content::WebContents* web_contents) override; |
| 473 | void MoveValidationMessage(content::WebContents* web_contents, |
| 474 | const gfx::Rect& anchor_in_root_view) override; |
| 475 | bool PreHandleGestureEvent(content::WebContents* source, |
| 476 | const blink::WebGestureEvent& event) override; |
| 477 | bool CanDragEnter(content::WebContents* source, |
| 478 | const content::DropData& data, |
| 479 | blink::WebDragOperationsMask operations_allowed) override; |
lgarron | 662dd52 | 2015-06-08 23:20:01 | [diff] [blame] | 480 | content::SecurityStyle GetSecurityStyle( |
estark | 5ea80e5 | 2015-06-19 18:43:12 | [diff] [blame] | 481 | content::WebContents* web_contents, |
| 482 | content::SecurityStyleExplanations* security_style_explanations) override; |
pfeldman | 61aa8a159 | 2015-09-03 22:08:18 | [diff] [blame] | 483 | void ShowCertificateViewerInDevTools( |
| 484 | content::WebContents* web_contents, |
| 485 | int cert_id) override; |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 486 | std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser( |
jyasskin | 93649a5 | 2016-02-17 19:57:02 | [diff] [blame] | 487 | content::RenderFrameHost* frame, |
| 488 | const content::BluetoothChooser::EventHandler& event_handler) override; |
pfeldman | 5f0773a4 | 2016-03-29 16:56:33 | [diff] [blame] | 489 | void RequestAppBannerFromDevTools( |
| 490 | content::WebContents* web_contents) override; |
| 491 | |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 492 | bool is_type_tabbed() const { return type_ == TYPE_TABBED; } |
| 493 | bool is_type_popup() const { return type_ == TYPE_POPUP; } |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 494 | |
| 495 | bool is_app() const; |
| 496 | bool is_devtools() const; |
| 497 | |
[email protected] | d013f14 | 2012-04-27 17:31:14 | [diff] [blame] | 498 | // True when the mouse cursor is locked. |
| 499 | bool IsMouseLocked() const; |
[email protected] | 5925dff8 | 2011-09-17 02:10:56 | [diff] [blame] | 500 | |
[email protected] | 2f516c79 | 2011-09-19 22:22:09 | [diff] [blame] | 501 | // Called each time the browser window is shown. |
| 502 | void OnWindowDidShow(); |
| 503 | |
[email protected] | 43b9517 | 2012-02-04 01:36:00 | [diff] [blame] | 504 | // Show the first run search engine bubble on the location bar. |
| 505 | void ShowFirstRunBubble(); |
| 506 | |
sriramsr | a41db56 | 2015-01-26 22:45:04 | [diff] [blame] | 507 | ExclusiveAccessManager* exclusive_access_manager() { |
| 508 | return exclusive_access_manager_.get(); |
[email protected] | 3f32b9b | 2012-07-09 16:59:28 | [diff] [blame] | 509 | } |
| 510 | |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame] | 511 | extensions::WindowController* extension_window_controller() const { |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 512 | return extension_window_controller_.get(); |
| 513 | } |
| 514 | |
changwan | 6ed4d43 | 2016-05-19 22:03:54 | [diff] [blame] | 515 | bool ShouldRunUnloadListenerBeforeClosing(content::WebContents* web_contents); |
| 516 | bool RunUnloadListenerBeforeClosing(content::WebContents* web_contents); |
| 517 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 518 | private: |
[email protected] | 199bba6e | 2012-04-04 16:19:38 | [diff] [blame] | 519 | friend class BrowserTest; |
[email protected] | 0cefa87ea | 2012-09-07 18:01:26 | [diff] [blame] | 520 | friend class FullscreenControllerInteractiveTest; |
[email protected] | 47ea3b4 | 2012-06-04 17:30:26 | [diff] [blame] | 521 | friend class FullscreenControllerTest; |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 522 | FRIEND_TEST_ALL_PREFIXES(AppModeTest, EnableAppModeTest); |
[email protected] | 557c4e2 | 2012-12-18 18:30:55 | [diff] [blame] | 523 | FRIEND_TEST_ALL_PREFIXES(BrowserCommandControllerTest, |
| 524 | IsReservedCommandOrKeyIsApp); |
| 525 | FRIEND_TEST_ALL_PREFIXES(BrowserCommandControllerTest, AppFullScreen); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 526 | FRIEND_TEST_ALL_PREFIXES(BrowserTest, NoTabsInPopups); |
[email protected] | 75aef12 | 2010-12-06 21:48:32 | [diff] [blame] | 527 | FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut); |
[email protected] | 2f1c09d | 2011-01-14 14:58:14 | [diff] [blame] | 528 | FRIEND_TEST_ALL_PREFIXES(BrowserTest, OpenAppWindowLikeNtp); |
| 529 | FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); |
[email protected] | 2fb3888 | 2014-04-23 09:02:09 | [diff] [blame] | 530 | FRIEND_TEST_ALL_PREFIXES(BrowserTest, ShouldShowLocationBar); |
sriramsr | 49dd49512 | 2014-12-13 02:53:42 | [diff] [blame] | 531 | FRIEND_TEST_ALL_PREFIXES(ExclusiveAccessBubbleWindowControllerTest, |
| 532 | DenyExitsFullscreen); |
[email protected] | 47ea3b4 | 2012-06-04 17:30:26 | [diff] [blame] | 533 | FRIEND_TEST_ALL_PREFIXES(FullscreenControllerTest, |
| 534 | TabEntersPresentationModeFromWindowed); |
[email protected] | fe7c487 | 2012-05-10 20:06:03 | [diff] [blame] | 535 | FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, OpenAppShortcutNoPref); |
| 536 | FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, |
| 537 | OpenAppShortcutWindowPref); |
| 538 | FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, OpenAppShortcutTabPref); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 539 | |
[email protected] | 20ca038 | 2013-02-28 19:50:07 | [diff] [blame] | 540 | class InterstitialObserver; |
| 541 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 542 | // Used to describe why a tab is being detached. This is used by |
| 543 | // TabDetachedAtImpl. |
| 544 | enum DetachType { |
| 545 | // Result of TabDetachedAt. |
| 546 | DETACH_TYPE_DETACH, |
| 547 | |
| 548 | // Result of TabReplacedAt. |
| 549 | DETACH_TYPE_REPLACE, |
| 550 | |
| 551 | // Result of the tab strip not having any significant tabs. |
| 552 | DETACH_TYPE_EMPTY |
| 553 | }; |
| 554 | |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 555 | // Describes where the bookmark bar state change originated from. |
| 556 | enum BookmarkBarStateChangeReason { |
| 557 | // From the constructor. |
| 558 | BOOKMARK_BAR_STATE_CHANGE_INIT, |
[email protected] | 93f230e0 | 2011-06-01 14:40:00 | [diff] [blame] | 559 | |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 560 | // Change is the result of the active tab changing. |
| 561 | BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH, |
| 562 | |
| 563 | // Change is the result of the bookmark bar pref changing. |
| 564 | BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE, |
| 565 | |
| 566 | // Change is the result of a state change in the active tab. |
| 567 | BOOKMARK_BAR_STATE_CHANGE_TAB_STATE, |
[email protected] | 227393e | 2011-06-29 21:28:39 | [diff] [blame] | 568 | |
| 569 | // Change is the result of window toggling in/out of fullscreen mode. |
| 570 | BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN, |
[email protected] | 93f230e0 | 2011-06-01 14:40:00 | [diff] [blame] | 571 | }; |
| 572 | |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 573 | // Overridden from content::WebContentsDelegate: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 574 | content::WebContents* OpenURLFromTab( |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 575 | content::WebContents* source, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 576 | const content::OpenURLParams& params) override; |
creis | cde28de | 2014-11-26 17:10:36 | [diff] [blame] | 577 | void NavigationStateChanged(content::WebContents* source, |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 578 | content::InvalidateTypes changed_flags) override; |
estark | 25f9af1 | 2015-09-09 19:37:04 | [diff] [blame] | 579 | void VisibleSSLStateChanged(const content::WebContents* source) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 580 | void AddNewContents(content::WebContents* source, |
| 581 | content::WebContents* new_contents, |
| 582 | WindowOpenDisposition disposition, |
bokan | 107a47f | 2015-02-03 23:23:39 | [diff] [blame] | 583 | const gfx::Rect& initial_rect, |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 584 | bool user_gesture, |
| 585 | bool* was_blocked) override; |
| 586 | void ActivateContents(content::WebContents* contents) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 587 | void LoadingStateChanged(content::WebContents* source, |
| 588 | bool to_different_document) override; |
| 589 | void CloseContents(content::WebContents* source) override; |
| 590 | void MoveContents(content::WebContents* source, |
| 591 | const gfx::Rect& pos) override; |
| 592 | bool IsPopupOrPanel(const content::WebContents* source) const override; |
| 593 | void UpdateTargetURL(content::WebContents* source, const GURL& url) override; |
| 594 | void ContentsMouseEvent(content::WebContents* source, |
| 595 | const gfx::Point& location, |
mgiuca | 1c92cab4 | 2016-01-07 03:18:27 | [diff] [blame] | 596 | bool motion, |
| 597 | bool exited) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 598 | void ContentsZoomChange(bool zoom_in) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 599 | bool TakeFocus(content::WebContents* source, bool reverse) override; |
| 600 | gfx::Rect GetRootWindowResizerRect() const override; |
| 601 | void BeforeUnloadFired(content::WebContents* source, |
| 602 | bool proceed, |
| 603 | bool* proceed_to_fire_unload) override; |
| 604 | bool ShouldFocusLocationBarByDefault(content::WebContents* source) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 605 | void ViewSourceForTab(content::WebContents* source, |
| 606 | const GURL& page_url) override; |
| 607 | void ViewSourceForFrame(content::WebContents* source, |
| 608 | const GURL& frame_url, |
| 609 | const content::PageState& frame_page_state) override; |
| 610 | void ShowRepostFormWarningDialog(content::WebContents* source) override; |
| 611 | bool ShouldCreateWebContents( |
[email protected] | 4fdf674 | 2012-01-10 20:14:36 | [diff] [blame] | 612 | content::WebContents* web_contents, |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 613 | int32_t route_id, |
| 614 | int32_t main_frame_route_id, |
| 615 | int32_t main_frame_widget_route_id, |
[email protected] | 4fdf674 | 2012-01-10 20:14:36 | [diff] [blame] | 616 | WindowContainerType window_container_type, |
nasko | 48321ca3 | 2015-07-02 20:44:12 | [diff] [blame] | 617 | const std::string& frame_name, |
[email protected] | 4543b67c | 2013-07-11 18:18:36 | [diff] [blame] | 618 | const GURL& target_url, |
[email protected] | dd673041 | 2013-08-14 15:03:37 | [diff] [blame] | 619 | const std::string& partition_id, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 620 | content::SessionStorageNamespace* session_storage_namespace) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 621 | void WebContentsCreated(content::WebContents* source_contents, |
| 622 | int opener_render_frame_id, |
nasko | 48321ca3 | 2015-07-02 20:44:12 | [diff] [blame] | 623 | const std::string& frame_name, |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 624 | const GURL& target_url, |
| 625 | content::WebContents* new_contents) override; |
| 626 | void RendererUnresponsive(content::WebContents* source) override; |
| 627 | void RendererResponsive(content::WebContents* source) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 628 | void DidNavigateMainFramePostCommit( |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 629 | content::WebContents* web_contents) override; |
mathiash | 72a5e46 | 2014-11-19 08:18:50 | [diff] [blame] | 630 | content::JavaScriptDialogManager* GetJavaScriptDialogManager( |
| 631 | content::WebContents* source) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 632 | content::ColorChooser* OpenColorChooser( |
[email protected] | 8bc5ff0 | 2013-11-29 06:34:03 | [diff] [blame] | 633 | content::WebContents* web_contents, |
| 634 | SkColor color, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 635 | const std::vector<content::ColorSuggestion>& suggestions) override; |
nasko | 35169af | 2016-06-10 18:47:13 | [diff] [blame] | 636 | void RunFileChooser(content::RenderFrameHost* render_frame_host, |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 637 | const content::FileChooserParams& params) override; |
| 638 | void EnumerateDirectory(content::WebContents* web_contents, |
| 639 | int request_id, |
| 640 | const base::FilePath& path) override; |
| 641 | bool EmbedsFullscreenWidget() const override; |
mlamouri | 7a78d6fd | 2015-01-17 13:23:53 | [diff] [blame] | 642 | void EnterFullscreenModeForTab(content::WebContents* web_contents, |
| 643 | const GURL& origin) override; |
| 644 | void ExitFullscreenModeForTab(content::WebContents* web_contents) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 645 | bool IsFullscreenForTabOrPending( |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 646 | const content::WebContents* web_contents) const override; |
mikhail.pozdnyakov | 76208cb | 2015-09-07 10:31:40 | [diff] [blame] | 647 | blink::WebDisplayMode GetDisplayMode( |
| 648 | const content::WebContents* web_contents) const override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 649 | void RegisterProtocolHandler(content::WebContents* web_contents, |
| 650 | const std::string& protocol, |
| 651 | const GURL& url, |
| 652 | bool user_gesture) override; |
| 653 | void UnregisterProtocolHandler(content::WebContents* web_contents, |
| 654 | const std::string& protocol, |
| 655 | const GURL& url, |
| 656 | bool user_gesture) override; |
| 657 | void UpdatePreferredSize(content::WebContents* source, |
| 658 | const gfx::Size& pref_size) override; |
| 659 | void ResizeDueToAutoResize(content::WebContents* source, |
| 660 | const gfx::Size& new_size) override; |
| 661 | void FindReply(content::WebContents* web_contents, |
| 662 | int request_id, |
| 663 | int number_of_matches, |
| 664 | const gfx::Rect& selection_rect, |
| 665 | int active_match_ordinal, |
| 666 | bool final_update) override; |
| 667 | void RequestToLockMouse(content::WebContents* web_contents, |
| 668 | bool user_gesture, |
| 669 | bool last_unlocked_by_target) override; |
| 670 | void LostMouseLock() override; |
| 671 | void RequestMediaAccessPermission( |
[email protected] | f13b420 | 2012-06-12 23:53:23 | [diff] [blame] | 672 | content::WebContents* web_contents, |
[email protected] | 33662e5 | 2013-01-07 21:31:09 | [diff] [blame] | 673 | const content::MediaStreamRequest& request, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 674 | const content::MediaResponseCallback& callback) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 675 | bool CheckMediaAccessPermission(content::WebContents* web_contents, |
| 676 | const GURL& security_origin, |
| 677 | content::MediaStreamType type) override; |
| 678 | bool RequestPpapiBrokerPermission( |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 679 | content::WebContents* web_contents, |
| 680 | const GURL& url, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 681 | const base::FilePath& plugin_path, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 682 | const base::Callback<void(bool)>& callback) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 683 | gfx::Size GetSizeForNewRenderView( |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 684 | content::WebContents* web_contents) const override; |
[email protected] | 5ef8e37 | 2011-10-18 04:25:55 | [diff] [blame] | 685 | |
[email protected] | 51d83bdf | 2011-12-09 16:09:29 | [diff] [blame] | 686 | // Overridden from CoreTabHelperDelegate: |
[email protected] | 371d64a | 2012-12-14 21:11:32 | [diff] [blame] | 687 | // Note that the caller is responsible for deleting |old_contents|. |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 688 | void SwapTabContents(content::WebContents* old_contents, |
| 689 | content::WebContents* new_contents, |
| 690 | bool did_start_load, |
| 691 | bool did_finish_load) override; |
| 692 | bool CanReloadContents(content::WebContents* web_contents) const override; |
| 693 | bool CanSaveContents(content::WebContents* web_contents) const override; |
[email protected] | 71b5d24 | 2011-04-30 02:27:20 | [diff] [blame] | 694 | |
[email protected] | 82808d0 | 2014-04-10 00:10:59 | [diff] [blame] | 695 | // Overridden from SearchTabHelperDelegate: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 696 | void OnWebContentsInstantSupportDisabled( |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 697 | const content::WebContents* web_contents) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 698 | OmniboxView* GetOmniboxView() override; |
| 699 | std::set<std::string> GetOpenUrls() override; |
[email protected] | 82808d0 | 2014-04-10 00:10:59 | [diff] [blame] | 700 | |
[email protected] | d2b1657 | 2013-01-03 00:41:58 | [diff] [blame] | 701 | // Overridden from WebContentsModalDialogManagerDelegate: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 702 | void SetWebContentsBlocked(content::WebContents* web_contents, |
| 703 | bool blocked) override; |
| 704 | web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() |
| 705 | override; |
[email protected] | 3114509 | 2011-09-30 01:49:44 | [diff] [blame] | 706 | |
[email protected] | 35699d57 | 2011-05-11 19:46:14 | [diff] [blame] | 707 | // Overridden from BookmarkTabHelperDelegate: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 708 | void URLStarredChanged(content::WebContents* web_contents, |
| 709 | bool starred) override; |
[email protected] | 52cc59b | 2011-05-06 14:42:38 | [diff] [blame] | 710 | |
[email protected] | 6f80e93 | 2012-06-04 19:00:07 | [diff] [blame] | 711 | // Overridden from ZoomObserver: |
wjmaclean | 7f63c6b | 2014-12-09 14:59:55 | [diff] [blame] | 712 | void OnZoomChanged( |
juncai | a64f769c2 | 2016-06-04 00:55:32 | [diff] [blame] | 713 | const zoom::ZoomController::ZoomChangedEventData& data) override; |
[email protected] | 6f80e93 | 2012-06-04 19:00:07 | [diff] [blame] | 714 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 715 | // Overridden from SelectFileDialog::Listener: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 716 | void FileSelected(const base::FilePath& path, |
| 717 | int index, |
| 718 | void* params) override; |
| 719 | void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file_info, |
| 720 | int index, |
| 721 | void* params) override; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 722 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 723 | // Overridden from content::NotificationObserver: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 724 | void Observe(int type, |
| 725 | const content::NotificationSource& source, |
| 726 | const content::NotificationDetails& details) override; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 727 | |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 728 | #if defined(ENABLE_EXTENSIONS) |
jitendra.ks | a005553 | 2014-10-07 05:54:46 | [diff] [blame] | 729 | // Overridden from extensions::ExtensionRegistryObserver: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 730 | void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 731 | const extensions::Extension* extension, |
| 732 | extensions::UninstallReason reason) override; |
| 733 | void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 734 | const extensions::Extension* extension) override; |
| 735 | void OnExtensionUnloaded( |
jitendra.ks | a005553 | 2014-10-07 05:54:46 | [diff] [blame] | 736 | content::BrowserContext* browser_context, |
| 737 | const extensions::Extension* extension, |
mostynb | f165e0a | 2014-10-13 19:25:05 | [diff] [blame] | 738 | extensions::UnloadedExtensionInfo::Reason reason) override; |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 739 | #endif |
jitendra.ks | a005553 | 2014-10-07 05:54:46 | [diff] [blame] | 740 | |
pkasting | cc29d20e | 2015-02-25 06:05:53 | [diff] [blame] | 741 | // Overridden from translate::ContentTranslateDriver::Observer: |
| 742 | void OnIsPageTranslatedChanged(content::WebContents* source) override; |
| 743 | void OnTranslateEnabledChanged(content::WebContents* source) override; |
| 744 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 745 | // Command and state updating /////////////////////////////////////////////// |
| 746 | |
[email protected] | c31813a | 2012-11-15 18:47:26 | [diff] [blame] | 747 | // Handle changes to kDevTools preference. |
| 748 | void OnDevToolsDisabledChanged(); |
| 749 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 750 | // UI update coalescing and handling //////////////////////////////////////// |
| 751 | |
| 752 | // Asks the toolbar (and as such the location bar) to update its state to |
| 753 | // reflect the current tab's current URL, security state, etc. |
| 754 | // If |should_restore_state| is true, we're switching (back?) to this tab and |
| 755 | // should restore any previous location bar state (such as user editing) as |
| 756 | // well. |
| 757 | void UpdateToolbar(bool should_restore_state); |
| 758 | |
| 759 | // Does one or both of the following for each bit in |changed_flags|: |
| 760 | // . If the update should be processed immediately, it is. |
| 761 | // . If the update should processed asynchronously (to avoid lots of ui |
| 762 | // updates), then scheduled_updates_ is updated for the |source| and update |
| 763 | // pair and a task is scheduled (assuming it isn't running already) |
| 764 | // that invokes ProcessPendingUIUpdates. |
creis | cde28de | 2014-11-26 17:10:36 | [diff] [blame] | 765 | void ScheduleUIUpdate(content::WebContents* source, |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 766 | unsigned changed_flags); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 767 | |
| 768 | // Processes all pending updates to the UI that have been scheduled by |
| 769 | // ScheduleUIUpdate in scheduled_updates_. |
| 770 | void ProcessPendingUIUpdates(); |
| 771 | |
| 772 | // Removes all entries from scheduled_updates_ whose source is contents. |
[email protected] | d908348 | 2012-01-06 00:38:46 | [diff] [blame] | 773 | void RemoveScheduledUpdatesFor(content::WebContents* contents); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 774 | |
| 775 | // Getters for UI /////////////////////////////////////////////////////////// |
| 776 | |
| 777 | // TODO(beng): remove, and provide AutomationProvider a better way to access |
| 778 | // the LocationBarView's edit. |
| 779 | friend class AutomationProvider; |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 780 | friend class BrowserProxy; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 781 | |
| 782 | // Returns the StatusBubble from the current toolbar. It is possible for |
| 783 | // this to return NULL if called before the toolbar has initialized. |
| 784 | // TODO(beng): remove this. |
| 785 | StatusBubble* GetStatusBubble(); |
| 786 | |
| 787 | // Session restore functions //////////////////////////////////////////////// |
| 788 | |
| 789 | // Notifies the history database of the index for all tabs whose index is |
| 790 | // >= index. |
| 791 | void SyncHistoryWithTabs(int index); |
| 792 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 793 | // In-progress download termination handling ///////////////////////////////// |
| 794 | |
| 795 | // Called when the window is closing to check if potential in-progress |
| 796 | // downloads should prevent it from closing. |
| 797 | // Returns true if the window can close, false otherwise. |
| 798 | bool CanCloseWithInProgressDownloads(); |
| 799 | |
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 800 | // Assorted utility functions /////////////////////////////////////////////// |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 801 | |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 802 | // Sets the specified browser as the delegate of the WebContents and all the |
[email protected] | 63d1f9b | 2014-07-05 19:09:03 | [diff] [blame] | 803 | // associated tab helpers that are needed. If |set_delegate| is true, this |
| 804 | // browser object is set as a delegate for |web_contents| components, else |
| 805 | // is is removed as a delegate. |
| 806 | void SetAsDelegate(content::WebContents* web_contents, bool set_delegate); |
[email protected] | 6451fe9 | 2012-08-30 18:37:26 | [diff] [blame] | 807 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 808 | // Shows the Find Bar, optionally selecting the next entry that matches the |
| 809 | // existing search string for that Tab. |forward_direction| controls the |
| 810 | // search direction. |
| 811 | void FindInPage(bool find_next, bool forward_direction); |
| 812 | |
| 813 | // Closes the frame. |
| 814 | // TODO(beng): figure out if we need this now that the frame itself closes |
| 815 | // after a return to the message loop. |
| 816 | void CloseFrame(); |
| 817 | |
[email protected] | e89cfcb | 2012-11-11 14:47:24 | [diff] [blame] | 818 | void TabDetachedAtImpl(content::WebContents* contents, |
| 819 | int index, |
| 820 | DetachType type); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 821 | |
toyoshim | 7dad4b118 | 2016-04-01 14:28:05 | [diff] [blame] | 822 | // Shared code between Reload() and ReloadBypassingCache(). |
toyoshim | 24a4c7ab | 2016-04-05 09:24:14 | [diff] [blame] | 823 | void ReloadInternal(WindowOpenDisposition disposition, bool bypass_cache); |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 824 | |
benwells | a2a8a9f7 | 2015-04-07 07:09:54 | [diff] [blame] | 825 | // Returns true if the Browser window supports a location bar. Having support |
| 826 | // for the location bar does not mean it will be visible. |
| 827 | bool SupportsLocationBar() const; |
| 828 | |
[email protected] | 8a585cb | 2014-03-21 17:13:52 | [diff] [blame] | 829 | // Returns true if the Browser window should show the location bar. |
| 830 | bool ShouldShowLocationBar() const; |
| 831 | |
benwells | 502df69 | 2014-12-02 20:41:45 | [diff] [blame] | 832 | // Returns true if the Browser window should use a web app style frame. |
| 833 | bool ShouldUseWebAppFrame() const; |
| 834 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 835 | // Implementation of SupportsWindowFeature and CanSupportWindowFeature. If |
| 836 | // |check_fullscreen| is true, the set of features reflect the actual state of |
| 837 | // the browser, otherwise the set of features reflect the possible state of |
| 838 | // the browser. |
| 839 | bool SupportsWindowFeatureImpl(WindowFeature feature, |
| 840 | bool check_fullscreen) const; |
| 841 | |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 842 | // Resets |bookmark_bar_state_| based on the active tab. Notifies the |
| 843 | // BrowserWindow if necessary. |
| 844 | void UpdateBookmarkBarState(BookmarkBarStateChangeReason reason); |
| 845 | |
[email protected] | c3e3294 | 2012-12-11 10:26:20 | [diff] [blame] | 846 | bool ShouldHideUIForFullscreen() const; |
| 847 | |
thestig | 02897869 | 2015-10-08 07:39:40 | [diff] [blame] | 848 | // Returns true if we can start the shutdown sequence for the browser, i.e. |
| 849 | // the last browser window is being closed. |
| 850 | bool ShouldStartShutdown() const; |
| 851 | |
[email protected] | 4fdf674 | 2012-01-10 20:14:36 | [diff] [blame] | 852 | // Creates a BackgroundContents if appropriate; return true if one was |
| 853 | // created. |
[email protected] | dd673041 | 2013-08-14 15:03:37 | [diff] [blame] | 854 | bool MaybeCreateBackgroundContents( |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 855 | int32_t route_id, |
| 856 | int32_t main_frame_route_id, |
| 857 | int32_t main_frame_widget_route_id, |
[email protected] | dd673041 | 2013-08-14 15:03:37 | [diff] [blame] | 858 | content::WebContents* opener_web_contents, |
nasko | 48321ca3 | 2015-07-02 20:44:12 | [diff] [blame] | 859 | const std::string& frame_name, |
[email protected] | dd673041 | 2013-08-14 15:03:37 | [diff] [blame] | 860 | const GURL& target_url, |
| 861 | const std::string& partition_id, |
| 862 | content::SessionStorageNamespace* session_storage_namespace); |
[email protected] | 4fdf674 | 2012-01-10 20:14:36 | [diff] [blame] | 863 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 864 | // Data members ///////////////////////////////////////////////////////////// |
| 865 | |
[email protected] | 20ca038 | 2013-02-28 19:50:07 | [diff] [blame] | 866 | std::vector<InterstitialObserver*> interstitial_observers_; |
| 867 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 868 | content::NotificationRegistrar registrar_; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 869 | |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 870 | #if defined(ENABLE_EXTENSIONS) |
jitendra.ks | a005553 | 2014-10-07 05:54:46 | [diff] [blame] | 871 | ScopedObserver<extensions::ExtensionRegistry, |
| 872 | extensions::ExtensionRegistryObserver> |
| 873 | extension_registry_observer_; |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 874 | #endif |
jitendra.ks | a005553 | 2014-10-07 05:54:46 | [diff] [blame] | 875 | |
[email protected] | 97b4638 | 2011-05-02 13:23:04 | [diff] [blame] | 876 | PrefChangeRegistrar profile_pref_registrar_; |
| 877 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 878 | // This Browser's type. |
| 879 | const Type type_; |
| 880 | |
| 881 | // This Browser's profile. |
| 882 | Profile* const profile_; |
| 883 | |
| 884 | // This Browser's window. |
| 885 | BrowserWindow* window_; |
| 886 | |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 887 | std::unique_ptr<TabStripModelDelegate> tab_strip_model_delegate_; |
| 888 | std::unique_ptr<TabStripModel> tab_strip_model_; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 889 | |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 890 | // The application name that is also the name of the window to the shell. |
| 891 | // This name should be set when: |
| 892 | // 1) we launch an application via an application shortcut or extension API. |
| 893 | // 2) we launch an undocked devtool window. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 894 | std::string app_name_; |
| 895 | |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 896 | // True if the source is trusted (i.e. we do not need to show the URL in a |
| 897 | // a popup window). Also used to determine which app windows to save and |
| 898 | // restore on Chrome OS. |
| 899 | bool is_trusted_source_; |
[email protected] | 0da5829 | 2012-03-22 20:37:21 | [diff] [blame] | 900 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 901 | // Unique identifier of this browser for session restore. This id is only |
| 902 | // unique within the current session, and is not guaranteed to be unique |
| 903 | // across sessions. |
| 904 | const SessionID session_id_; |
| 905 | |
| 906 | // The model for the toolbar view. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 907 | std::unique_ptr<ToolbarModel> toolbar_model_; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 908 | |
[email protected] | e3a5d5b | 2012-06-22 17:56:46 | [diff] [blame] | 909 | // The model for the "active" search state. There are per-tab search models |
| 910 | // as well. When a tab is active its model is kept in sync with this one. |
| 911 | // When a new tab is activated its model state is propagated to this active |
| 912 | // model. This way, observers only have to attach to this single model for |
| 913 | // updates, and don't have to worry about active tab changes directly. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 914 | std::unique_ptr<SearchModel> search_model_; |
[email protected] | e3a5d5b | 2012-06-22 17:56:46 | [diff] [blame] | 915 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 916 | // UI update coalescing and handling //////////////////////////////////////// |
| 917 | |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 918 | typedef std::map<const content::WebContents*, int> UpdateMap; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 919 | |
[email protected] | 075969d | 2012-04-17 20:05:55 | [diff] [blame] | 920 | // Maps from WebContents to pending UI updates that need to be processed. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 921 | // We don't update things like the URL or tab title right away to avoid |
| 922 | // flickering and extra painting. |
| 923 | // See ScheduleUIUpdate and ProcessPendingUIUpdates. |
| 924 | UpdateMap scheduled_updates_; |
| 925 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 926 | // In-progress download termination handling ///////////////////////////////// |
| 927 | |
| 928 | enum CancelDownloadConfirmationState { |
| 929 | NOT_PROMPTED, // We have not asked the user. |
| 930 | WAITING_FOR_RESPONSE, // We have asked the user and have not received a |
| 931 | // reponse yet. |
| 932 | RESPONSE_RECEIVED // The user was prompted and made a decision already. |
| 933 | }; |
| 934 | |
| 935 | // State used to figure-out whether we should prompt the user for confirmation |
| 936 | // when the browser is closed with in-progress downloads. |
| 937 | CancelDownloadConfirmationState cancel_download_confirmation_state_; |
| 938 | |
| 939 | ///////////////////////////////////////////////////////////////////////////// |
| 940 | |
[email protected] | 400eaf8 | 2011-08-22 15:47:39 | [diff] [blame] | 941 | // Override values for the bounds of the window and its maximized or minimized |
| 942 | // state. |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 943 | // These are supplied by callers that don't want to use the default values. |
| 944 | // The default values are typically loaded from local state (last session), |
| 945 | // obtained from the last window of the same type, or obtained from the |
| 946 | // shell shortcut's startup info. |
| 947 | gfx::Rect override_bounds_; |
[email protected] | 1f0b50b | 2012-06-22 20:37:16 | [diff] [blame] | 948 | ui::WindowShowState initial_show_state_; |
thomasanderson | 06405c5 | 2016-05-03 22:52:22 | [diff] [blame] | 949 | const std::string initial_workspace_; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 950 | |
[email protected] | 8bc061f | 2011-08-31 22:46:23 | [diff] [blame] | 951 | // Tracks when this browser is being created by session restore. |
| 952 | bool is_session_restore_; |
| 953 | |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 954 | std::unique_ptr<chrome::UnloadController> unload_controller_; |
| 955 | std::unique_ptr<chrome::FastUnloadController> fast_unload_controller_; |
[email protected] | f9b6c09 | 2012-07-09 19:32:28 | [diff] [blame] | 956 | |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 957 | std::unique_ptr<ChromeBubbleManager> bubble_manager_; |
hcarmona | aa431c0 | 2015-08-28 18:45:57 | [diff] [blame] | 958 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 959 | // The Find Bar. This may be NULL if there is no Find Bar, and if it is |
| 960 | // non-NULL, it may or may not be visible. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 961 | std::unique_ptr<FindBarController> find_bar_controller_; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 962 | |
| 963 | // Dialog box used for opening and saving files. |
[email protected] | 92f5408 | 2012-07-31 01:43:14 | [diff] [blame] | 964 | scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 965 | |
| 966 | // Keep track of the encoding auto detect pref. |
| 967 | BooleanPrefMember encoding_auto_detect_; |
| 968 | |
[email protected] | ef55702 | 2012-03-16 10:05:33 | [diff] [blame] | 969 | // Helper which implements the ContentSettingBubbleModel interface. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 970 | std::unique_ptr<BrowserContentSettingBubbleModelDelegate> |
[email protected] | ef55702 | 2012-03-16 10:05:33 | [diff] [blame] | 971 | content_setting_bubble_model_delegate_; |
| 972 | |
| 973 | // Helper which implements the ToolbarModelDelegate interface. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 974 | std::unique_ptr<BrowserToolbarModelDelegate> toolbar_model_delegate_; |
[email protected] | ef55702 | 2012-03-16 10:05:33 | [diff] [blame] | 975 | |
[email protected] | e3a5d5b | 2012-06-22 17:56:46 | [diff] [blame] | 976 | // A delegate that handles the details of updating the "active" |
| 977 | // |search_model_| state with the tab's state. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 978 | std::unique_ptr<SearchDelegate> search_delegate_; |
[email protected] | e3a5d5b | 2012-06-22 17:56:46 | [diff] [blame] | 979 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 980 | // Helper which implements the LiveTabContext interface. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 981 | std::unique_ptr<BrowserLiveTabContext> live_tab_context_; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 982 | |
[email protected] | afefa74e | 2011-07-26 05:04:23 | [diff] [blame] | 983 | // Helper which implements the SyncedWindowDelegate interface. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 984 | std::unique_ptr<BrowserSyncedWindowDelegate> synced_window_delegate_; |
[email protected] | afefa74e | 2011-07-26 05:04:23 | [diff] [blame] | 985 | |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 986 | std::unique_ptr<BrowserInstantController> instant_controller_; |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 987 | |
benwells | a2a8a9f7 | 2015-04-07 07:09:54 | [diff] [blame] | 988 | // Helper which handles bookmark app specific browser configuration. |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 989 | std::unique_ptr<extensions::HostedAppBrowserController> |
| 990 | hosted_app_controller_; |
benwells | a2a8a9f7 | 2015-04-07 07:09:54 | [diff] [blame] | 991 | |
[email protected] | 09b2934 | 2011-06-24 19:18:48 | [diff] [blame] | 992 | BookmarkBar::State bookmark_bar_state_; |
[email protected] | 65c8114 | 2012-07-31 19:44:43 | [diff] [blame] | 993 | |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 994 | std::unique_ptr<ExclusiveAccessManager> exclusive_access_manager_; |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 995 | |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 996 | std::unique_ptr<extensions::WindowController> extension_window_controller_; |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 997 | |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 998 | std::unique_ptr<chrome::BrowserCommandController> command_controller_; |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 999 | |
[email protected] | 2f516c79 | 2011-09-19 22:22:09 | [diff] [blame] | 1000 | // True if the browser window has been shown at least once. |
| 1001 | bool window_has_shown_; |
| 1002 | |
estade | 53f17391 | 2016-04-18 02:22:08 | [diff] [blame] | 1003 | base::WeakPtr<ValidationMessageBubble> validation_message_bubble_; |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1004 | |
anthonyvd | e659ee9 | 2016-02-04 23:16:56 | [diff] [blame] | 1005 | SigninViewController signin_view_controller_; |
| 1006 | |
dcheng | 9603ab9 | 2016-04-08 04:17:32 | [diff] [blame] | 1007 | std::unique_ptr<ScopedKeepAlive> keep_alive_; |
dgn | fe075c8 | 2016-03-18 11:25:35 | [diff] [blame] | 1008 | |
anujk.sharma | 62e915a | 2014-12-11 19:23:16 | [diff] [blame] | 1009 | // The following factory is used for chrome update coalescing. |
| 1010 | base::WeakPtrFactory<Browser> chrome_updater_factory_; |
| 1011 | |
mohan.reddy | 1f99439 | 2014-09-17 05:30:05 | [diff] [blame] | 1012 | // The following factory is used to close the frame at a later time. |
| 1013 | base::WeakPtrFactory<Browser> weak_factory_; |
| 1014 | |
[email protected] | 69b04b9 | 2010-11-08 22:12:18 | [diff] [blame] | 1015 | DISALLOW_COPY_AND_ASSIGN(Browser); |
| 1016 | }; |
| 1017 | |
| 1018 | #endif // CHROME_BROWSER_UI_BROWSER_H_ |