blob: 693e84d96148a486101ae1a1e7ed6401e516c791 [file] [log] [blame]
[email protected]daa9e382012-01-06 00:30:341// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]69b04b92010-11-08 22:12:182// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_BROWSER_H_
6#define CHROME_BROWSER_UI_BROWSER_H_
[email protected]69b04b92010-11-08 22:12:187
avi655876a2015-12-25 07:18:158#include <stdint.h>
9
[email protected]69b04b92010-11-08 22:12:1810#include <map>
dcheng9603ab92016-04-08 04:17:3211#include <memory>
[email protected]69b04b92010-11-08 22:12:1812#include <set>
13#include <string>
14#include <vector>
15
[email protected]a0366a52011-02-04 20:04:2116#include "base/compiler_specific.h"
[email protected]69b04b92010-11-08 22:12:1817#include "base/gtest_prod_util.h"
avi655876a2015-12-25 07:18:1518#include "base/macros.h"
[email protected]24f1477532011-11-22 22:55:3619#include "base/memory/weak_ptr.h"
jitendra.ksa0055532014-10-07 05:54:4620#include "base/scoped_observer.h"
[email protected]11521182013-06-11 04:06:3621#include "base/strings/string16.h"
avi655876a2015-12-25 07:18:1522#include "build/build_config.h"
[email protected]70019152012-12-19 11:44:1923#include "chrome/browser/devtools/devtools_toggle_action.h"
[email protected]09b29342011-06-24 19:18:4824#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
[email protected]35699d572011-05-11 19:46:1425#include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h"
[email protected]fee320542011-03-02 01:30:4926#include "chrome/browser/ui/browser_navigator.h"
hcarmonaaa431c02015-08-28 18:45:5727#include "chrome/browser/ui/chrome_bubble_manager.h"
[email protected]e41d0082013-05-16 04:37:5428#include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
sriramsra41db562015-01-26 22:45:0429#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
anthonyvde659ee92016-02-04 23:16:5630#include "chrome/browser/ui/profile_chooser_constants.h"
[email protected]82808d02014-04-10 00:10:5931#include "chrome/browser/ui/search/search_tab_helper_delegate.h"
anthonyvde659ee92016-02-04 23:16:5632#include "chrome/browser/ui/signin_view_controller.h"
[email protected]51d83bdf2011-12-09 16:09:2933#include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
[email protected]b56e2e32012-05-11 21:18:0434#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
mukai077089f2014-09-11 18:41:5235#include "components/content_settings/core/common/content_settings.h"
[email protected]08f71012014-07-25 10:27:5436#include "components/content_settings/core/common/content_settings_types.h"
brettwb1fc1b82016-02-02 00:19:0837#include "components/prefs/pref_change_registrar.h"
38#include "components/prefs/pref_member.h"
blundell47c6d8a2015-09-24 11:06:4039#include "components/sessions/core/session_id.h"
blundell11d93bc2015-07-31 12:33:1240#include "components/toolbar/toolbar_model.h"
pkastingcc29d20e2015-02-25 06:05:5341#include "components/translate/content/browser/content_translate_driver.h"
juncaia64f769c22016-06-04 00:55:3242#include "components/zoom/zoom_observer.h"
[email protected]a6a7ced2012-11-01 17:24:1843#include "content/public/browser/notification_observer.h"
[email protected]6c2381d2011-10-19 02:52:5344#include "content/public/browser/notification_registrar.h"
[email protected]e5d549d2011-12-28 01:29:2045#include "content/public/browser/page_navigator.h"
[email protected]674bc592011-12-20 23:00:4246#include "content/public/browser/web_contents_delegate.h"
[email protected]54087fe2011-10-28 22:02:4847#include "content/public/common/page_zoom.h"
Sylvain Defresnec6ccc77d2014-09-19 10:19:3548#include "ui/base/page_transition_types.h"
[email protected]400eaf82011-08-22 15:47:3949#include "ui/base/ui_base_types.h"
[email protected]1867c742013-01-23 01:25:2450#include "ui/base/window_open_disposition.h"
tfarina3b0452d2014-12-31 15:20:0951#include "ui/gfx/geometry/rect.h"
[email protected]4344a3c2013-01-17 23:49:2052#include "ui/shell_dialogs/select_file_dialog.h"
[email protected]69b04b92010-11-08 22:12:1853
thestiga84d8e62014-10-17 22:27:5554#if defined(ENABLE_EXTENSIONS)
55#include "extensions/browser/extension_registry_observer.h"
56#endif
57
[email protected]ef557022012-03-16 10:05:3358class BrowserContentSettingBubbleModelDelegate;
[email protected]165fe422013-03-27 06:34:0359class BrowserInstantController;
[email protected]afefa74e2011-07-26 05:04:2360class BrowserSyncedWindowDelegate;
[email protected]ef557022012-03-16 10:05:3361class BrowserToolbarModelDelegate;
blundellbde024d2015-09-30 13:47:0762class BrowserLiveTabContext;
[email protected]69b04b92010-11-08 22:12:1863class BrowserWindow;
[email protected]69b04b92010-11-08 22:12:1864class FindBarController;
[email protected]69b04b92010-11-08 22:12:1865class PrefService;
66class Profile;
dgnfe075c82016-03-18 11:25:3567class ScopedKeepAlive;
[email protected]165fe422013-03-27 06:34:0368class SearchDelegate;
69class SearchModel;
[email protected]69b04b92010-11-08 22:12:1870class StatusBubble;
[email protected]69b04b92010-11-08 22:12:1871class TabStripModel;
[email protected]855370052012-07-10 19:30:3272class TabStripModelDelegate;
andresantoso49f9a7a2015-01-28 00:03:1773class ValidationMessageBubble;
[email protected]bb461532010-11-26 21:50:2374struct WebApplicationInfo;
[email protected]cca0f1e2012-01-03 18:27:4675
[email protected]e3a5d5b2012-06-22 17:56:4676namespace chrome {
[email protected]5d98294912012-06-27 22:57:4077class BrowserCommandController;
[email protected]88c92012013-07-02 11:56:3478class FastUnloadController;
[email protected]f9b6c092012-07-09 19:32:2879class UnloadController;
[email protected]e3a5d5b2012-06-22 17:56:4680}
81
[email protected]cca0f1e2012-01-03 18:27:4682namespace content {
83class NavigationController;
[email protected]691aa2f2013-05-28 22:52:0484class PageState;
[email protected]adbfb8df2012-02-24 01:19:4385class SessionStorageNamespace;
[email protected]cca0f1e2012-01-03 18:27:4686}
87
[email protected]1c321ee52012-05-21 03:02:3488namespace extensions {
benwells11bd6ed2015-06-05 04:20:4189class HostedAppBrowserController;
[email protected]1c321ee52012-05-21 03:02:3490class Extension;
jitendra.ksa0055532014-10-07 05:54:4691class ExtensionRegistry;
[email protected]44f4b132012-07-17 20:36:5792class WindowController;
[email protected]1c321ee52012-05-21 03:02:3493}
94
[email protected]69b04b92010-11-08 22:12:1895namespace gfx {
[email protected]9b125b732012-08-17 04:43:5596class Image;
[email protected]69b04b92010-11-08 22:12:1897class Point;
98}
99
[email protected]20c07f8e2012-05-31 08:43:14100namespace ui {
[email protected]53f04c82012-07-26 02:31:09101struct SelectedFileInfo;
[email protected]20c07f8e2012-05-31 08:43:14102class WebDialogDelegate;
103}
104
[email protected]e41d0082013-05-16 04:37:54105namespace web_modal {
106class WebContentsModalDialogHost;
107}
108
[email protected]855370052012-07-10 19:30:32109class Browser : public TabStripModelObserver,
[email protected]674bc592011-12-20 23:00:42110 public content::WebContentsDelegate,
[email protected]51d83bdf2011-12-09 16:09:29111 public CoreTabHelperDelegate,
[email protected]82808d02014-04-10 00:10:59112 public SearchTabHelperDelegate,
[email protected]e41d0082013-05-16 04:37:54113 public ChromeWebModalDialogManagerDelegate,
[email protected]35699d572011-05-11 19:46:14114 public BookmarkTabHelperDelegate,
juncaia64f769c22016-06-04 00:55:32115 public zoom::ZoomObserver,
[email protected]e5d549d2011-12-28 01:29:20116 public content::PageNavigator,
[email protected]6c2381d2011-10-19 02:52:53117 public content::NotificationObserver,
thestiga84d8e62014-10-17 22:27:55118#if defined(ENABLE_EXTENSIONS)
jitendra.ksa0055532014-10-07 05:54:46119 public extensions::ExtensionRegistryObserver,
thestiga84d8e62014-10-17 22:27:55120#endif
pkastingcc29d20e2015-02-25 06:05:53121 public translate::ContentTranslateDriver::Observer,
[email protected]379329b32013-07-11 05:58:52122 public ui::SelectFileDialog::Listener {
[email protected]69b04b92010-11-08 22:12:18123 public:
[email protected]94ce7252010-12-20 21:46:33124 // 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]69b04b92010-11-08 22:12:18127 enum Type {
[email protected]de4943f2011-07-28 16:25:14128 // If you add a new type, consider updating the test
129 // BrowserTest.StartMaximized.
[email protected]2a3b59432011-07-26 18:38:38130 TYPE_TABBED = 1,
[email protected]7efaed362013-04-04 09:33:32131 TYPE_POPUP = 2
[email protected]69b04b92010-11-08 22:12:18132 };
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,
benwells502df692014-12-02 20:41:45143 FEATURE_DOWNLOADSHELF = 64,
144 FEATURE_WEBAPPFRAME = 128
[email protected]69b04b92010-11-08 22:12:18145 };
146
[email protected]5a17d492011-10-24 19:37:03147 // 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]b35b26b32011-05-05 20:35:14162 struct CreateParams {
scottmg851949002016-02-09 20:09:44163 explicit CreateParams(Profile* profile);
164 CreateParams(Type type, Profile* profile);
vmpstrb8aacbe2016-02-26 02:00:48165 CreateParams(const CreateParams& other);
[email protected]92655362012-04-20 21:33:17166
[email protected]d2202e22014-04-14 20:20:53167 static CreateParams CreateForApp(const std::string& app_name,
168 bool trusted_source,
[email protected]da22aa62012-04-04 18:54:35169 const gfx::Rect& window_bounds,
scottmg851949002016-02-09 20:09:44170 Profile* profile);
[email protected]da22aa62012-04-04 18:54:35171
scottmg851949002016-02-09 20:09:44172 static CreateParams CreateForDevTools(Profile* profile);
[email protected]da22aa62012-04-04 18:54:35173
[email protected]b35b26b32011-05-05 20:35:14174 // The browser type.
175 Type type;
176
177 // The associated profile.
178 Profile* profile;
179
[email protected]d2202e22014-04-14 20:20:53180 // Specifies the browser is_trusted_source_ value.
181 bool trusted_source;
[email protected]0da58292012-03-22 20:37:21182
[email protected]b35b26b32011-05-05 20:35:14183 // The bounds of the window to open.
184 gfx::Rect initial_bounds;
[email protected]a636d8e52012-02-28 15:40:41185
thomasanderson06405c52016-05-03 22:52:22186 // The workspace the window should open in, if the platform supports it.
187 std::string initial_workspace;
188
[email protected]a636d8e52012-02-28 15:40:41189 ui::WindowShowState initial_show_state;
190
191 bool is_session_restore;
[email protected]a4fe67012012-07-25 20:14:29192
193 // Supply a custom BrowserWindow implementation, to be used instead of the
194 // default. Intended for testing.
195 BrowserWindow* window;
[email protected]d2202e22014-04-14 20:20:53196
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]b35b26b32011-05-05 20:35:14207 };
208
[email protected]69b04b92010-11-08 22:12:18209 // Constructors, Creation, Showing //////////////////////////////////////////
210
[email protected]a4fe67012012-07-25 20:14:29211 explicit Browser(const CreateParams& params);
dcheng5dd5ff62014-10-21 12:42:38212 ~Browser() override;
[email protected]69b04b92010-11-08 22:12:18213
[email protected]69b04b92010-11-08 22:12:18214 // 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]1f0b50b2012-06-22 20:37:16218 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]69b04b92010-11-08 22:12:18221 }
222 // Return true if the initial window bounds have been overridden.
223 bool bounds_overridden() const {
224 return !override_bounds_.IsEmpty();
225 }
[email protected]8bc061f2011-08-31 22:46:23226 // 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]69b04b92010-11-08 22:12:18235
[email protected]69b04b92010-11-08 22:12:18236 // Accessors ////////////////////////////////////////////////////////////////
237
238 Type type() const { return type_; }
[email protected]b2e88d82011-03-09 19:11:53239 const std::string& app_name() const { return app_name_; }
[email protected]d2202e22014-04-14 20:20:53240 bool is_trusted_source() const { return is_trusted_source_; }
[email protected]69b04b92010-11-08 22:12:18241 Profile* profile() const { return profile_; }
[email protected]fe90ca8e2011-04-08 20:40:43242 gfx::Rect override_bounds() const { return override_bounds_; }
thomasanderson06405c52016-05-03 22:52:22243 const std::string& initial_workspace() const { return initial_workspace_; }
[email protected]69b04b92010-11-08 22:12:18244
[email protected]eea624c2011-01-10 20:33:38245 // |window()| will return NULL if called before |CreateBrowserWindow()|
246 // is done.
[email protected]69b04b92010-11-08 22:12:18247 BrowserWindow* window() const { return window_; }
[email protected]ef557022012-03-16 10:05:33248 ToolbarModel* toolbar_model() { return toolbar_model_.get(); }
[email protected]5d98294912012-06-27 22:57:40249 const ToolbarModel* toolbar_model() const { return toolbar_model_.get(); }
[email protected]a40be8b2013-08-22 20:12:14250#if defined(UNIT_TEST)
dcheng9603ab92016-04-08 04:17:32251 void swap_toolbar_models(std::unique_ptr<ToolbarModel>* toolbar_model) {
[email protected]a40be8b2013-08-22 20:12:14252 toolbar_model->swap(toolbar_model_);
253 }
254#endif
[email protected]04e3ead52013-01-14 01:09:20255 TabStripModel* tab_strip_model() const { return tab_strip_model_.get(); }
[email protected]5d98294912012-06-27 22:57:40256 chrome::BrowserCommandController* command_controller() {
257 return command_controller_.get();
258 }
[email protected]165fe422013-03-27 06:34:03259 SearchModel* search_model() { return search_model_.get(); }
260 const SearchModel* search_model() const {
[email protected]43aafff2012-06-29 21:20:49261 return search_model_.get();
262 }
[email protected]165fe422013-03-27 06:34:03263 SearchDelegate* search_delegate() {
[email protected]9331c3f2012-06-27 23:17:16264 return search_delegate_.get();
265 }
[email protected]69b04b92010-11-08 22:12:18266 const SessionID& session_id() const { return session_id_; }
[email protected]ef557022012-03-16 10:05:33267 BrowserContentSettingBubbleModelDelegate*
268 content_setting_bubble_model_delegate() {
269 return content_setting_bubble_model_delegate_.get();
270 }
blundellbde024d2015-09-30 13:47:07271 BrowserLiveTabContext* live_tab_context() { return live_tab_context_.get(); }
[email protected]afefa74e2011-07-26 05:04:23272 BrowserSyncedWindowDelegate* synced_window_delegate() {
273 return synced_window_delegate_.get();
274 }
[email protected]165fe422013-03-27 06:34:03275 BrowserInstantController* instant_controller() {
[email protected]7acfaf92012-07-11 15:51:59276 return instant_controller_.get();
277 }
benwells11bd6ed2015-06-05 04:20:41278 extensions::HostedAppBrowserController* hosted_app_controller() {
279 return hosted_app_controller_.get();
benwellsa2a8a9f72015-04-07 07:09:54280 }
anthonyvd0ac524a2016-04-05 18:17:52281 SigninViewController* signin_view_controller() {
282 return &signin_view_controller_;
283 }
[email protected]69b04b92010-11-08 22:12:18284
hcarmonaaa431c02015-08-28 18:45:57285 // Will lazy create the bubble manager.
286 ChromeBubbleManager* GetBubbleManager();
287
[email protected]69b04b92010-11-08 22:12:18288 // 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]09b29342011-06-24 19:18:48295 // Returns the state of the bookmark bar.
296 BookmarkBar::State bookmark_bar_state() const { return bookmark_bar_state_; }
297
[email protected]69b04b92010-11-08 22:12:18298 // State Storage and Retrieval for UI ///////////////////////////////////////
299
[email protected]abc2f262011-03-15 21:15:44300 // Gets the Favicon of the page in the selected tab.
[email protected]9b125b732012-08-17 04:43:55301 gfx::Image GetCurrentPageIcon() const;
[email protected]69b04b92010-11-08 22:12:18302
303 // Gets the title of the window based on the selected tab's title.
varkha48f84c4b2016-06-27 18:10:33304 // Disables additional formatting when |include_app_name| is false.
305 base::string16 GetWindowTitleForCurrentTab(bool include_app_name) const;
[email protected]69b04b92010-11-08 22:12:18306
307 // Prepares a title string for display (removes embedded newlines, etc).
[email protected]b959d7d42013-12-13 17:26:37308 static void FormatTitleForDisplay(base::string16* title);
[email protected]69b04b92010-11-08 22:12:18309
310 // OnBeforeUnload handling //////////////////////////////////////////////////
311
[email protected]2e9d79f2013-08-16 05:45:56312 // 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]69b04b92010-11-08 22:12:18316 bool ShouldCloseWindow();
317
[email protected]2e9d79f2013-08-16 05:45:56318 // 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]88c92012013-07-02 11:56:34334 // 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]f9b6c092012-07-09 19:32:28341 bool IsAttemptingToCloseBrowser() const;
[email protected]69b04b92010-11-08 22:12:18342
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]5a17d492011-10-24 19:37:03355 // 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]c2afee412013-08-12 05:11:58363 // External state change handling ////////////////////////////////////////////
[email protected]69b04b92010-11-08 22:12:18364
[email protected]227393e2011-06-29 21:28:39365 // Invoked when the fullscreen state of the window changes.
[email protected]55c87fa2011-10-15 07:28:28366 // BrowserWindow::EnterFullscreen invokes this after the window has become
[email protected]227393e2011-06-29 21:28:39367 // fullscreen.
368 void WindowFullscreenStateChanged();
[email protected]69b04b92010-11-08 22:12:18369
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]184717d52012-02-22 04:46:16375 // See the description of
376 // FullscreenController::ToggleFullscreenModeWithExtension.
[email protected]41d9faf2012-02-28 23:46:02377 void ToggleFullscreenModeWithExtension(const GURL& extension_url);
[email protected]8ee06542014-04-20 22:29:10378
[email protected]69b04b92010-11-08 22:12:18379 // 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]fee320542011-03-02 01:30:49390 // TODO(port): port these, and re-merge the two function declaration lists.
[email protected]69b04b92010-11-08 22:12:18391 // Page-related commands.
[email protected]69b04b92010-11-08 22:12:18392 void ToggleEncodingAutoDetect();
393 void OverrideEncoding(int encoding_id);
394
[email protected]69b04b92010-11-08 22:12:18395 // Show various bits of UI
396 void OpenFile();
[email protected]3a8b69b82012-06-25 13:01:07397
[email protected]a37d4b02012-06-25 21:56:10398 void UpdateDownloadShelfVisibility(bool visible);
[email protected]69b04b92010-11-08 22:12:18399
[email protected]69b04b92010-11-08 22:12:18400 /////////////////////////////////////////////////////////////////////////////
401
[email protected]78e2edc2012-07-01 23:32:28402 // Called by chrome::Navigate() when a navigation has occurred in a tab in
[email protected]69b04b92010-11-08 22:12:18403 // this Browser. Updates the UI for the start of this navigation.
[email protected]e232c992012-12-06 12:43:20404 void UpdateUIForNavigationInTab(content::WebContents* contents,
Sylvain Defresnec6ccc77d2014-09-19 10:19:35405 ui::PageTransition transition,
[email protected]69b04b92010-11-08 22:12:18406 bool user_initiated);
407
anthonyvde659ee92016-02-04 23:16:56408 // 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
dgnfe075c82016-03-18 11:25:35423 // 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]69b04b92010-11-08 22:12:18429 // Interface implementations ////////////////////////////////////////////////
430
[email protected]e5d549d2011-12-28 01:29:20431 // Overridden from content::PageNavigator:
dcheng5dd5ff62014-10-21 12:42:38432 content::WebContents* OpenURL(const content::OpenURLParams& params) override;
[email protected]69b04b92010-11-08 22:12:18433
[email protected]69b04b92010-11-08 22:12:18434 // Overridden from TabStripModelObserver:
dcheng5dd5ff62014-10-21 12:42:38435 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,
mostynb205d6252014-10-04 00:49:22455 int index) override;
dcheng5dd5ff62014-10-21 12:42:38456 void TabStripEmpty() override;
[email protected]69b04b92010-11-08 22:12:18457
[email protected]fc761142012-06-08 04:49:20458 // Overridden from content::WebContentsDelegate:
dcheng5dd5ff62014-10-21 12:42:38459 bool CanOverscrollContent() const override;
460 bool ShouldPreserveAbortedURLs(content::WebContents* source) override;
calamity6160055c2015-04-30 06:45:26461 void SetFocusToLocationBar(bool select_all) override;
dcheng5dd5ff62014-10-21 12:42:38462 bool PreHandleKeyboardEvent(content::WebContents* source,
463 const content::NativeWebKeyboardEvent& event,
464 bool* is_keyboard_shortcut) override;
465 void HandleKeyboardEvent(
[email protected]b3996ba2012-08-08 00:39:13466 content::WebContents* source,
mostynb205d6252014-10-04 00:49:22467 const content::NativeWebKeyboardEvent& event) override;
dcheng5dd5ff62014-10-21 12:42:38468 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;
lgarron662dd522015-06-08 23:20:01480 content::SecurityStyle GetSecurityStyle(
estark5ea80e52015-06-19 18:43:12481 content::WebContents* web_contents,
482 content::SecurityStyleExplanations* security_style_explanations) override;
pfeldman61aa8a1592015-09-03 22:08:18483 void ShowCertificateViewerInDevTools(
484 content::WebContents* web_contents,
485 int cert_id) override;
dcheng9603ab92016-04-08 04:17:32486 std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
jyasskin93649a52016-02-17 19:57:02487 content::RenderFrameHost* frame,
488 const content::BluetoothChooser::EventHandler& event_handler) override;
pfeldman5f0773a42016-03-29 16:56:33489 void RequestAppBannerFromDevTools(
490 content::WebContents* web_contents) override;
491
[email protected]b35b26b32011-05-05 20:35:14492 bool is_type_tabbed() const { return type_ == TYPE_TABBED; }
493 bool is_type_popup() const { return type_ == TYPE_POPUP; }
[email protected]b35b26b32011-05-05 20:35:14494
495 bool is_app() const;
496 bool is_devtools() const;
497
[email protected]d013f142012-04-27 17:31:14498 // True when the mouse cursor is locked.
499 bool IsMouseLocked() const;
[email protected]5925dff82011-09-17 02:10:56500
[email protected]2f516c792011-09-19 22:22:09501 // Called each time the browser window is shown.
502 void OnWindowDidShow();
503
[email protected]43b95172012-02-04 01:36:00504 // Show the first run search engine bubble on the location bar.
505 void ShowFirstRunBubble();
506
sriramsra41db562015-01-26 22:45:04507 ExclusiveAccessManager* exclusive_access_manager() {
508 return exclusive_access_manager_.get();
[email protected]3f32b9b2012-07-09 16:59:28509 }
510
[email protected]44f4b132012-07-17 20:36:57511 extensions::WindowController* extension_window_controller() const {
[email protected]41d9faf2012-02-28 23:46:02512 return extension_window_controller_.get();
513 }
514
changwan6ed4d432016-05-19 22:03:54515 bool ShouldRunUnloadListenerBeforeClosing(content::WebContents* web_contents);
516 bool RunUnloadListenerBeforeClosing(content::WebContents* web_contents);
517
[email protected]69b04b92010-11-08 22:12:18518 private:
[email protected]199bba6e2012-04-04 16:19:38519 friend class BrowserTest;
[email protected]0cefa87ea2012-09-07 18:01:26520 friend class FullscreenControllerInteractiveTest;
[email protected]47ea3b42012-06-04 17:30:26521 friend class FullscreenControllerTest;
[email protected]b35b26b32011-05-05 20:35:14522 FRIEND_TEST_ALL_PREFIXES(AppModeTest, EnableAppModeTest);
[email protected]557c4e22012-12-18 18:30:55523 FRIEND_TEST_ALL_PREFIXES(BrowserCommandControllerTest,
524 IsReservedCommandOrKeyIsApp);
525 FRIEND_TEST_ALL_PREFIXES(BrowserCommandControllerTest, AppFullScreen);
[email protected]69b04b92010-11-08 22:12:18526 FRIEND_TEST_ALL_PREFIXES(BrowserTest, NoTabsInPopups);
[email protected]75aef122010-12-06 21:48:32527 FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut);
[email protected]2f1c09d2011-01-14 14:58:14528 FRIEND_TEST_ALL_PREFIXES(BrowserTest, OpenAppWindowLikeNtp);
529 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch);
[email protected]2fb38882014-04-23 09:02:09530 FRIEND_TEST_ALL_PREFIXES(BrowserTest, ShouldShowLocationBar);
sriramsr49dd495122014-12-13 02:53:42531 FRIEND_TEST_ALL_PREFIXES(ExclusiveAccessBubbleWindowControllerTest,
532 DenyExitsFullscreen);
[email protected]47ea3b42012-06-04 17:30:26533 FRIEND_TEST_ALL_PREFIXES(FullscreenControllerTest,
534 TabEntersPresentationModeFromWindowed);
[email protected]fe7c4872012-05-10 20:06:03535 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, OpenAppShortcutNoPref);
536 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest,
537 OpenAppShortcutWindowPref);
538 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, OpenAppShortcutTabPref);
[email protected]69b04b92010-11-08 22:12:18539
[email protected]20ca0382013-02-28 19:50:07540 class InterstitialObserver;
541
[email protected]69b04b92010-11-08 22:12:18542 // 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]09b29342011-06-24 19:18:48555 // Describes where the bookmark bar state change originated from.
556 enum BookmarkBarStateChangeReason {
557 // From the constructor.
558 BOOKMARK_BAR_STATE_CHANGE_INIT,
[email protected]93f230e02011-06-01 14:40:00559
[email protected]09b29342011-06-24 19:18:48560 // 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]227393e2011-06-29 21:28:39568
569 // Change is the result of window toggling in/out of fullscreen mode.
570 BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN,
[email protected]93f230e02011-06-01 14:40:00571 };
572
[email protected]674bc592011-12-20 23:00:42573 // Overridden from content::WebContentsDelegate:
dcheng5dd5ff62014-10-21 12:42:38574 content::WebContents* OpenURLFromTab(
[email protected]e5d549d2011-12-28 01:29:20575 content::WebContents* source,
mostynb205d6252014-10-04 00:49:22576 const content::OpenURLParams& params) override;
creiscde28de2014-11-26 17:10:36577 void NavigationStateChanged(content::WebContents* source,
dcheng5dd5ff62014-10-21 12:42:38578 content::InvalidateTypes changed_flags) override;
estark25f9af12015-09-09 19:37:04579 void VisibleSSLStateChanged(const content::WebContents* source) override;
dcheng5dd5ff62014-10-21 12:42:38580 void AddNewContents(content::WebContents* source,
581 content::WebContents* new_contents,
582 WindowOpenDisposition disposition,
bokan107a47f2015-02-03 23:23:39583 const gfx::Rect& initial_rect,
dcheng5dd5ff62014-10-21 12:42:38584 bool user_gesture,
585 bool* was_blocked) override;
586 void ActivateContents(content::WebContents* contents) override;
dcheng5dd5ff62014-10-21 12:42:38587 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,
mgiuca1c92cab42016-01-07 03:18:27596 bool motion,
597 bool exited) override;
dcheng5dd5ff62014-10-21 12:42:38598 void ContentsZoomChange(bool zoom_in) override;
dcheng5dd5ff62014-10-21 12:42:38599 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;
dcheng5dd5ff62014-10-21 12:42:38605 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]4fdf6742012-01-10 20:14:36612 content::WebContents* web_contents,
dcheng3ce04b62015-10-26 23:30:55613 int32_t route_id,
614 int32_t main_frame_route_id,
615 int32_t main_frame_widget_route_id,
[email protected]4fdf6742012-01-10 20:14:36616 WindowContainerType window_container_type,
nasko48321ca32015-07-02 20:44:12617 const std::string& frame_name,
[email protected]4543b67c2013-07-11 18:18:36618 const GURL& target_url,
[email protected]dd6730412013-08-14 15:03:37619 const std::string& partition_id,
mostynb205d6252014-10-04 00:49:22620 content::SessionStorageNamespace* session_storage_namespace) override;
dcheng5dd5ff62014-10-21 12:42:38621 void WebContentsCreated(content::WebContents* source_contents,
622 int opener_render_frame_id,
nasko48321ca32015-07-02 20:44:12623 const std::string& frame_name,
dcheng5dd5ff62014-10-21 12:42:38624 const GURL& target_url,
625 content::WebContents* new_contents) override;
626 void RendererUnresponsive(content::WebContents* source) override;
627 void RendererResponsive(content::WebContents* source) override;
dcheng5dd5ff62014-10-21 12:42:38628 void DidNavigateMainFramePostCommit(
mostynb205d6252014-10-04 00:49:22629 content::WebContents* web_contents) override;
mathiash72a5e462014-11-19 08:18:50630 content::JavaScriptDialogManager* GetJavaScriptDialogManager(
631 content::WebContents* source) override;
dcheng5dd5ff62014-10-21 12:42:38632 content::ColorChooser* OpenColorChooser(
[email protected]8bc5ff02013-11-29 06:34:03633 content::WebContents* web_contents,
634 SkColor color,
mostynb205d6252014-10-04 00:49:22635 const std::vector<content::ColorSuggestion>& suggestions) override;
nasko35169af2016-06-10 18:47:13636 void RunFileChooser(content::RenderFrameHost* render_frame_host,
dcheng5dd5ff62014-10-21 12:42:38637 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;
mlamouri7a78d6fd2015-01-17 13:23:53642 void EnterFullscreenModeForTab(content::WebContents* web_contents,
643 const GURL& origin) override;
644 void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
dcheng5dd5ff62014-10-21 12:42:38645 bool IsFullscreenForTabOrPending(
mostynb205d6252014-10-04 00:49:22646 const content::WebContents* web_contents) const override;
mikhail.pozdnyakov76208cb2015-09-07 10:31:40647 blink::WebDisplayMode GetDisplayMode(
648 const content::WebContents* web_contents) const override;
dcheng5dd5ff62014-10-21 12:42:38649 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]f13b4202012-06-12 23:53:23672 content::WebContents* web_contents,
[email protected]33662e52013-01-07 21:31:09673 const content::MediaStreamRequest& request,
mostynb205d6252014-10-04 00:49:22674 const content::MediaResponseCallback& callback) override;
dcheng5dd5ff62014-10-21 12:42:38675 bool CheckMediaAccessPermission(content::WebContents* web_contents,
676 const GURL& security_origin,
677 content::MediaStreamType type) override;
678 bool RequestPpapiBrokerPermission(
[email protected]8c8fc292012-11-23 18:57:16679 content::WebContents* web_contents,
680 const GURL& url,
[email protected]650b2d52013-02-10 03:41:45681 const base::FilePath& plugin_path,
mostynb205d6252014-10-04 00:49:22682 const base::Callback<void(bool)>& callback) override;
dcheng5dd5ff62014-10-21 12:42:38683 gfx::Size GetSizeForNewRenderView(
mostynb205d6252014-10-04 00:49:22684 content::WebContents* web_contents) const override;
[email protected]5ef8e372011-10-18 04:25:55685
[email protected]51d83bdf2011-12-09 16:09:29686 // Overridden from CoreTabHelperDelegate:
[email protected]371d64a2012-12-14 21:11:32687 // Note that the caller is responsible for deleting |old_contents|.
dcheng5dd5ff62014-10-21 12:42:38688 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]71b5d242011-04-30 02:27:20694
[email protected]82808d02014-04-10 00:10:59695 // Overridden from SearchTabHelperDelegate:
dcheng5dd5ff62014-10-21 12:42:38696 void OnWebContentsInstantSupportDisabled(
mostynb205d6252014-10-04 00:49:22697 const content::WebContents* web_contents) override;
dcheng5dd5ff62014-10-21 12:42:38698 OmniboxView* GetOmniboxView() override;
699 std::set<std::string> GetOpenUrls() override;
[email protected]82808d02014-04-10 00:10:59700
[email protected]d2b16572013-01-03 00:41:58701 // Overridden from WebContentsModalDialogManagerDelegate:
dcheng5dd5ff62014-10-21 12:42:38702 void SetWebContentsBlocked(content::WebContents* web_contents,
703 bool blocked) override;
704 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
705 override;
[email protected]31145092011-09-30 01:49:44706
[email protected]35699d572011-05-11 19:46:14707 // Overridden from BookmarkTabHelperDelegate:
dcheng5dd5ff62014-10-21 12:42:38708 void URLStarredChanged(content::WebContents* web_contents,
709 bool starred) override;
[email protected]52cc59b2011-05-06 14:42:38710
[email protected]6f80e932012-06-04 19:00:07711 // Overridden from ZoomObserver:
wjmaclean7f63c6b2014-12-09 14:59:55712 void OnZoomChanged(
juncaia64f769c22016-06-04 00:55:32713 const zoom::ZoomController::ZoomChangedEventData& data) override;
[email protected]6f80e932012-06-04 19:00:07714
[email protected]69b04b92010-11-08 22:12:18715 // Overridden from SelectFileDialog::Listener:
dcheng5dd5ff62014-10-21 12:42:38716 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]69b04b92010-11-08 22:12:18722
[email protected]6c2381d2011-10-19 02:52:53723 // Overridden from content::NotificationObserver:
dcheng5dd5ff62014-10-21 12:42:38724 void Observe(int type,
725 const content::NotificationSource& source,
726 const content::NotificationDetails& details) override;
[email protected]69b04b92010-11-08 22:12:18727
thestiga84d8e62014-10-17 22:27:55728#if defined(ENABLE_EXTENSIONS)
jitendra.ksa0055532014-10-07 05:54:46729 // Overridden from extensions::ExtensionRegistryObserver:
dcheng5dd5ff62014-10-21 12:42:38730 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.ksa0055532014-10-07 05:54:46736 content::BrowserContext* browser_context,
737 const extensions::Extension* extension,
mostynbf165e0a2014-10-13 19:25:05738 extensions::UnloadedExtensionInfo::Reason reason) override;
thestiga84d8e62014-10-17 22:27:55739#endif
jitendra.ksa0055532014-10-07 05:54:46740
pkastingcc29d20e2015-02-25 06:05:53741 // Overridden from translate::ContentTranslateDriver::Observer:
742 void OnIsPageTranslatedChanged(content::WebContents* source) override;
743 void OnTranslateEnabledChanged(content::WebContents* source) override;
744
[email protected]69b04b92010-11-08 22:12:18745 // Command and state updating ///////////////////////////////////////////////
746
[email protected]c31813a2012-11-15 18:47:26747 // Handle changes to kDevTools preference.
748 void OnDevToolsDisabledChanged();
749
[email protected]69b04b92010-11-08 22:12:18750 // 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.
creiscde28de2014-11-26 17:10:36765 void ScheduleUIUpdate(content::WebContents* source,
[email protected]2a6bc3e2011-12-28 23:51:33766 unsigned changed_flags);
[email protected]69b04b92010-11-08 22:12:18767
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]d9083482012-01-06 00:38:46773 void RemoveScheduledUpdatesFor(content::WebContents* contents);
[email protected]69b04b92010-11-08 22:12:18774
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]b35b26b32011-05-05 20:35:14780 friend class BrowserProxy;
[email protected]69b04b92010-11-08 22:12:18781
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]69b04b92010-11-08 22:12:18793 // 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]27e5b3912012-12-16 00:45:37800 // Assorted utility functions ///////////////////////////////////////////////
[email protected]69b04b92010-11-08 22:12:18801
[email protected]e232c992012-12-06 12:43:20802 // Sets the specified browser as the delegate of the WebContents and all the
[email protected]63d1f9b2014-07-05 19:09:03803 // 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]6451fe92012-08-30 18:37:26807
[email protected]69b04b92010-11-08 22:12:18808 // 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]e89cfcb2012-11-11 14:47:24818 void TabDetachedAtImpl(content::WebContents* contents,
819 int index,
820 DetachType type);
[email protected]69b04b92010-11-08 22:12:18821
toyoshim7dad4b1182016-04-01 14:28:05822 // Shared code between Reload() and ReloadBypassingCache().
toyoshim24a4c7ab2016-04-05 09:24:14823 void ReloadInternal(WindowOpenDisposition disposition, bool bypass_cache);
[email protected]69b04b92010-11-08 22:12:18824
benwellsa2a8a9f72015-04-07 07:09:54825 // 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]8a585cb2014-03-21 17:13:52829 // Returns true if the Browser window should show the location bar.
830 bool ShouldShowLocationBar() const;
831
benwells502df692014-12-02 20:41:45832 // Returns true if the Browser window should use a web app style frame.
833 bool ShouldUseWebAppFrame() const;
834
[email protected]69b04b92010-11-08 22:12:18835 // 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]09b29342011-06-24 19:18:48842 // Resets |bookmark_bar_state_| based on the active tab. Notifies the
843 // BrowserWindow if necessary.
844 void UpdateBookmarkBarState(BookmarkBarStateChangeReason reason);
845
[email protected]c3e32942012-12-11 10:26:20846 bool ShouldHideUIForFullscreen() const;
847
thestig028978692015-10-08 07:39:40848 // 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]4fdf6742012-01-10 20:14:36852 // Creates a BackgroundContents if appropriate; return true if one was
853 // created.
[email protected]dd6730412013-08-14 15:03:37854 bool MaybeCreateBackgroundContents(
dcheng3ce04b62015-10-26 23:30:55855 int32_t route_id,
856 int32_t main_frame_route_id,
857 int32_t main_frame_widget_route_id,
[email protected]dd6730412013-08-14 15:03:37858 content::WebContents* opener_web_contents,
nasko48321ca32015-07-02 20:44:12859 const std::string& frame_name,
[email protected]dd6730412013-08-14 15:03:37860 const GURL& target_url,
861 const std::string& partition_id,
862 content::SessionStorageNamespace* session_storage_namespace);
[email protected]4fdf6742012-01-10 20:14:36863
[email protected]69b04b92010-11-08 22:12:18864 // Data members /////////////////////////////////////////////////////////////
865
[email protected]20ca0382013-02-28 19:50:07866 std::vector<InterstitialObserver*> interstitial_observers_;
867
[email protected]6c2381d2011-10-19 02:52:53868 content::NotificationRegistrar registrar_;
[email protected]69b04b92010-11-08 22:12:18869
thestiga84d8e62014-10-17 22:27:55870#if defined(ENABLE_EXTENSIONS)
jitendra.ksa0055532014-10-07 05:54:46871 ScopedObserver<extensions::ExtensionRegistry,
872 extensions::ExtensionRegistryObserver>
873 extension_registry_observer_;
thestiga84d8e62014-10-17 22:27:55874#endif
jitendra.ksa0055532014-10-07 05:54:46875
[email protected]97b46382011-05-02 13:23:04876 PrefChangeRegistrar profile_pref_registrar_;
877
[email protected]69b04b92010-11-08 22:12:18878 // 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
dcheng9603ab92016-04-08 04:17:32887 std::unique_ptr<TabStripModelDelegate> tab_strip_model_delegate_;
888 std::unique_ptr<TabStripModel> tab_strip_model_;
[email protected]69b04b92010-11-08 22:12:18889
[email protected]b35b26b32011-05-05 20:35:14890 // 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]69b04b92010-11-08 22:12:18894 std::string app_name_;
895
[email protected]d2202e22014-04-14 20:20:53896 // 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]0da58292012-03-22 20:37:21900
[email protected]69b04b92010-11-08 22:12:18901 // 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.
dcheng9603ab92016-04-08 04:17:32907 std::unique_ptr<ToolbarModel> toolbar_model_;
[email protected]69b04b92010-11-08 22:12:18908
[email protected]e3a5d5b2012-06-22 17:56:46909 // 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.
dcheng9603ab92016-04-08 04:17:32914 std::unique_ptr<SearchModel> search_model_;
[email protected]e3a5d5b2012-06-22 17:56:46915
[email protected]69b04b92010-11-08 22:12:18916 // UI update coalescing and handling ////////////////////////////////////////
917
[email protected]2a6bc3e2011-12-28 23:51:33918 typedef std::map<const content::WebContents*, int> UpdateMap;
[email protected]69b04b92010-11-08 22:12:18919
[email protected]075969d2012-04-17 20:05:55920 // Maps from WebContents to pending UI updates that need to be processed.
[email protected]69b04b92010-11-08 22:12:18921 // 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]69b04b92010-11-08 22:12:18926 // 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]400eaf82011-08-22 15:47:39941 // Override values for the bounds of the window and its maximized or minimized
942 // state.
[email protected]69b04b92010-11-08 22:12:18943 // 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]1f0b50b2012-06-22 20:37:16948 ui::WindowShowState initial_show_state_;
thomasanderson06405c52016-05-03 22:52:22949 const std::string initial_workspace_;
[email protected]69b04b92010-11-08 22:12:18950
[email protected]8bc061f2011-08-31 22:46:23951 // Tracks when this browser is being created by session restore.
952 bool is_session_restore_;
953
dcheng9603ab92016-04-08 04:17:32954 std::unique_ptr<chrome::UnloadController> unload_controller_;
955 std::unique_ptr<chrome::FastUnloadController> fast_unload_controller_;
[email protected]f9b6c092012-07-09 19:32:28956
dcheng9603ab92016-04-08 04:17:32957 std::unique_ptr<ChromeBubbleManager> bubble_manager_;
hcarmonaaa431c02015-08-28 18:45:57958
[email protected]69b04b92010-11-08 22:12:18959 // 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.
dcheng9603ab92016-04-08 04:17:32961 std::unique_ptr<FindBarController> find_bar_controller_;
[email protected]69b04b92010-11-08 22:12:18962
963 // Dialog box used for opening and saving files.
[email protected]92f54082012-07-31 01:43:14964 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
[email protected]69b04b92010-11-08 22:12:18965
966 // Keep track of the encoding auto detect pref.
967 BooleanPrefMember encoding_auto_detect_;
968
[email protected]ef557022012-03-16 10:05:33969 // Helper which implements the ContentSettingBubbleModel interface.
dcheng9603ab92016-04-08 04:17:32970 std::unique_ptr<BrowserContentSettingBubbleModelDelegate>
[email protected]ef557022012-03-16 10:05:33971 content_setting_bubble_model_delegate_;
972
973 // Helper which implements the ToolbarModelDelegate interface.
dcheng9603ab92016-04-08 04:17:32974 std::unique_ptr<BrowserToolbarModelDelegate> toolbar_model_delegate_;
[email protected]ef557022012-03-16 10:05:33975
[email protected]e3a5d5b2012-06-22 17:56:46976 // A delegate that handles the details of updating the "active"
977 // |search_model_| state with the tab's state.
dcheng9603ab92016-04-08 04:17:32978 std::unique_ptr<SearchDelegate> search_delegate_;
[email protected]e3a5d5b2012-06-22 17:56:46979
blundellbde024d2015-09-30 13:47:07980 // Helper which implements the LiveTabContext interface.
dcheng9603ab92016-04-08 04:17:32981 std::unique_ptr<BrowserLiveTabContext> live_tab_context_;
[email protected]fb7da4132011-03-15 15:51:00982
[email protected]afefa74e2011-07-26 05:04:23983 // Helper which implements the SyncedWindowDelegate interface.
dcheng9603ab92016-04-08 04:17:32984 std::unique_ptr<BrowserSyncedWindowDelegate> synced_window_delegate_;
[email protected]afefa74e2011-07-26 05:04:23985
dcheng9603ab92016-04-08 04:17:32986 std::unique_ptr<BrowserInstantController> instant_controller_;
[email protected]69b04b92010-11-08 22:12:18987
benwellsa2a8a9f72015-04-07 07:09:54988 // Helper which handles bookmark app specific browser configuration.
dcheng9603ab92016-04-08 04:17:32989 std::unique_ptr<extensions::HostedAppBrowserController>
990 hosted_app_controller_;
benwellsa2a8a9f72015-04-07 07:09:54991
[email protected]09b29342011-06-24 19:18:48992 BookmarkBar::State bookmark_bar_state_;
[email protected]65c81142012-07-31 19:44:43993
dcheng9603ab92016-04-08 04:17:32994 std::unique_ptr<ExclusiveAccessManager> exclusive_access_manager_;
[email protected]8a5e0ca2011-08-25 06:30:47995
dcheng9603ab92016-04-08 04:17:32996 std::unique_ptr<extensions::WindowController> extension_window_controller_;
[email protected]41d9faf2012-02-28 23:46:02997
dcheng9603ab92016-04-08 04:17:32998 std::unique_ptr<chrome::BrowserCommandController> command_controller_;
[email protected]5d98294912012-06-27 22:57:40999
[email protected]2f516c792011-09-19 22:22:091000 // True if the browser window has been shown at least once.
1001 bool window_has_shown_;
1002
estade53f173912016-04-18 02:22:081003 base::WeakPtr<ValidationMessageBubble> validation_message_bubble_;
[email protected]edc3af82013-12-12 21:24:071004
anthonyvde659ee92016-02-04 23:16:561005 SigninViewController signin_view_controller_;
1006
dcheng9603ab92016-04-08 04:17:321007 std::unique_ptr<ScopedKeepAlive> keep_alive_;
dgnfe075c82016-03-18 11:25:351008
anujk.sharma62e915a2014-12-11 19:23:161009 // The following factory is used for chrome update coalescing.
1010 base::WeakPtrFactory<Browser> chrome_updater_factory_;
1011
mohan.reddy1f994392014-09-17 05:30:051012 // The following factory is used to close the frame at a later time.
1013 base::WeakPtrFactory<Browser> weak_factory_;
1014
[email protected]69b04b92010-11-08 22:12:181015 DISALLOW_COPY_AND_ASSIGN(Browser);
1016};
1017
1018#endif // CHROME_BROWSER_UI_BROWSER_H_