| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/ui/browser_command_controller.h" |
| 6 | |
| avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | |
| pmonette | 9c1457f | 2015-11-19 20:29:31 | [diff] [blame] | 9 | #include <string> |
| 10 | |
| Sebastien Marchand | f1349f5 | 2019-01-25 03:16:41 | [diff] [blame] | 11 | #include "base/bind.h" |
| [email protected] | 488e395 | 2013-11-18 05:29:14 | [diff] [blame] | 12 | #include "base/command_line.h" |
| Scott Violet | 4416579 | 2018-02-22 02:08:08 | [diff] [blame] | 13 | #include "base/debug/debugging_buildflags.h" |
| primiano | d3a81ab | 2016-01-25 22:21:15 | [diff] [blame] | 14 | #include "base/debug/profiler.h" |
| avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 15 | #include "base/macros.h" |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 16 | #include "base/metrics/user_metrics.h" |
| Haeun Kim | 3f612350 | 2018-08-26 18:03:04 | [diff] [blame] | 17 | #include "base/stl_util.h" |
| avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 18 | #include "build/build_config.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 19 | #include "chrome/app/chrome_command_ids.h" |
| 20 | #include "chrome/browser/browser_process.h" |
| [email protected] | dcc8fbc | 2013-07-12 00:54:09 | [diff] [blame] | 21 | #include "chrome/browser/chrome_notification_types.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 22 | #include "chrome/browser/defaults.h" |
| Pavol Marko | 56df027 | 2018-07-04 17:55:04 | [diff] [blame] | 23 | #include "chrome/browser/devtools/devtools_window.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 24 | #include "chrome/browser/extensions/extension_service.h" |
| benwells | 39f23ae | 2014-08-27 08:01:52 | [diff] [blame] | 25 | #include "chrome/browser/extensions/extension_util.h" |
| [email protected] | 2e9d79f | 2013-08-16 05:45:56 | [diff] [blame] | 26 | #include "chrome/browser/lifetime/application_lifetime.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 27 | #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 28 | #include "chrome/browser/profiles/profile.h" |
| mlerman | e01e6de | 2014-09-29 19:26:47 | [diff] [blame] | 29 | #include "chrome/browser/profiles/profile_manager.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 30 | #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| [email protected] | 0b32f9b6 | 2012-09-17 19:08:03 | [diff] [blame] | 31 | #include "chrome/browser/shell_integration.h" |
| [email protected] | 3d27d27 | 2013-07-31 03:15:16 | [diff] [blame] | 32 | #include "chrome/browser/signin/signin_promo.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 33 | #include "chrome/browser/sync/profile_sync_service_factory.h" |
| Christopher Lam | 86b5271 | 2017-12-04 01:58:33 | [diff] [blame] | 34 | #include "chrome/browser/ui/apps/app_info_dialog.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 35 | #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 36 | #include "chrome/browser/ui/browser.h" |
| 37 | #include "chrome/browser/ui/browser_commands.h" |
| 38 | #include "chrome/browser/ui/browser_window.h" |
| 39 | #include "chrome/browser/ui/chrome_pages.h" |
| Alan Cutter | 0996580 | 2018-03-27 07:25:29 | [diff] [blame] | 40 | #include "chrome/browser/ui/extensions/application_launch.h" |
| Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 41 | #include "chrome/browser/ui/extensions/hosted_app_browser_controller.h" |
| Alan Cutter | 0c313230 | 2018-02-21 05:09:02 | [diff] [blame] | 42 | #include "chrome/browser/ui/page_info/page_info_dialog.h" |
| Nicolas Ouellet-payeur | 82eb65b | 2018-11-05 16:49:27 | [diff] [blame] | 43 | #include "chrome/browser/ui/singleton_tabs.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 44 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| [email protected] | 2056c319 | 2013-10-21 22:40:51 | [diff] [blame] | 45 | #include "chrome/browser/ui/webui/inspect_ui.h" |
| [email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 46 | #include "chrome/common/content_restriction.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 47 | #include "chrome/common/pref_names.h" |
| Nicolas Ouellet-payeur | 82eb65b | 2018-11-05 16:49:27 | [diff] [blame] | 48 | #include "chrome/common/url_constants.h" |
| brettw | e1f0af8b | 2015-10-09 21:30:46 | [diff] [blame] | 49 | #include "components/bookmarks/common/bookmark_pref_names.h" |
| sdefresne | 0f2ef35 | 2015-07-27 19:18:00 | [diff] [blame] | 50 | #include "components/dom_distiller/core/dom_distiller_switches.h" |
| Scott Violet | 9ae8289 | 2018-03-01 18:38:12 | [diff] [blame] | 51 | #include "components/feature_engagement/buildflags.h" |
| brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 52 | #include "components/prefs/pref_service.h" |
| blundell | a08c5dd | 2015-09-18 06:14:16 | [diff] [blame] | 53 | #include "components/sessions/core/tab_restore_service.h" |
| David Roger | a6c8812 | 2017-10-25 13:02:46 | [diff] [blame] | 54 | #include "components/signin/core/browser/signin_pref_names.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 55 | #include "content/public/browser/native_web_keyboard_event.h" |
| 56 | #include "content/public/browser/navigation_controller.h" |
| 57 | #include "content/public/browser/navigation_entry.h" |
| Lukasz Anforowicz | e1b954d9 | 2017-10-30 21:28:06 | [diff] [blame] | 58 | #include "content/public/browser/render_frame_host.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 59 | #include "content/public/browser/web_contents.h" |
| [email protected] | 20ca038 | 2013-02-28 19:50:07 | [diff] [blame] | 60 | #include "content/public/browser/web_contents_observer.h" |
| Bryce Thomas | 96b0777 | 2018-11-07 03:04:15 | [diff] [blame] | 61 | #include "content/public/common/profiling.h" |
| ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 62 | #include "content/public/common/service_manager_connection.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 63 | #include "content/public/common/url_constants.h" |
| [email protected] | 03d2581 | 2014-06-22 19:41:55 | [diff] [blame] | 64 | #include "extensions/browser/extension_system.h" |
| Scott Violet | 318a55f | 2018-03-30 19:08:19 | [diff] [blame] | 65 | #include "printing/buildflags/buildflags.h" |
| [email protected] | 7e9acd08 | 2013-09-17 23:31:16 | [diff] [blame] | 66 | #include "ui/events/keycodes/keyboard_codes.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 67 | |
| [email protected] | 9c4d6833 | 2013-01-30 13:34:41 | [diff] [blame] | 68 | #if defined(OS_MACOSX) |
| 69 | #include "chrome/browser/ui/browser_commands_mac.h" |
| 70 | #endif |
| 71 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 72 | #if defined(OS_WIN) |
| [email protected] | a43ed00 | 2013-02-05 19:47:54 | [diff] [blame] | 73 | #include "base/win/windows_version.h" |
| [email protected] | 2d0f80f | 2013-11-01 22:47:18 | [diff] [blame] | 74 | #include "content/public/browser/gpu_data_manager.h" |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 75 | #endif |
| 76 | |
| [email protected] | d12cc5e | 2013-10-19 18:25:06 | [diff] [blame] | 77 | #if defined(OS_CHROMEOS) |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 78 | #include "ash/public/cpp/window_pin_type.h" |
| [email protected] | 0c93081 | 2014-01-30 18:01:47 | [diff] [blame] | 79 | #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" |
| caelyn | 4e4e08a | 2015-02-04 21:27:49 | [diff] [blame] | 80 | #include "chrome/browser/ui/browser_commands_chromeos.h" |
| [email protected] | d12cc5e | 2013-10-19 18:25:06 | [diff] [blame] | 81 | #endif |
| 82 | |
| [email protected] | d5bedb6d | 2014-04-08 10:49:32 | [diff] [blame] | 83 | #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| karandeepb | e620033 | 2016-06-21 12:26:10 | [diff] [blame] | 84 | #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" |
| [email protected] | 1e2172f | 2014-04-01 17:32:34 | [diff] [blame] | 85 | #endif |
| 86 | |
| Bettina Dea | f3dac20 | 2017-09-16 20:53:22 | [diff] [blame] | 87 | #if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP) |
| Bettina Dea | 48125dc | 2017-09-06 03:23:14 | [diff] [blame] | 88 | #include "chrome/browser/feature_engagement/bookmark/bookmark_tracker.h" |
| 89 | #include "chrome/browser/feature_engagement/bookmark/bookmark_tracker_factory.h" |
| Catherine Chung | beb88422 | 2017-08-01 15:47:55 | [diff] [blame] | 90 | #include "chrome/browser/feature_engagement/new_tab/new_tab_tracker.h" |
| 91 | #include "chrome/browser/feature_engagement/new_tab/new_tab_tracker_factory.h" |
| 92 | #endif |
| 93 | |
| Maksim Sisov | ac76759 | 2018-08-10 08:00:15 | [diff] [blame] | 94 | #if defined(USE_OZONE) |
| 95 | #include "ui/ozone/public/ozone_platform.h" |
| 96 | #endif |
| 97 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 98 | using content::NavigationEntry; |
| 99 | using content::NavigationController; |
| 100 | using content::WebContents; |
| 101 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 102 | namespace chrome { |
| 103 | |
| 104 | /////////////////////////////////////////////////////////////////////////////// |
| 105 | // BrowserCommandController, public: |
| 106 | |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 107 | BrowserCommandController::BrowserCommandController(Browser* browser) |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 108 | : browser_(browser), |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 109 | command_updater_(nullptr) { |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 110 | browser_->tab_strip_model()->AddObserver(this); |
| 111 | PrefService* local_state = g_browser_process->local_state(); |
| 112 | if (local_state) { |
| 113 | local_pref_registrar_.Init(local_state); |
| [email protected] | 9ec3ea5b | 2012-12-03 18:14:30 | [diff] [blame] | 114 | local_pref_registrar_.Add( |
| 115 | prefs::kAllowFileSelectionDialogs, |
| 116 | base::Bind( |
| 117 | &BrowserCommandController::UpdateCommandsForFileSelectionDialogs, |
| 118 | base::Unretained(this))); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | profile_pref_registrar_.Init(profile()->GetPrefs()); |
| [email protected] | 9ec3ea5b | 2012-12-03 18:14:30 | [diff] [blame] | 122 | profile_pref_registrar_.Add( |
| Pavol Marko | debb0ff | 2018-05-07 18:35:41 | [diff] [blame] | 123 | prefs::kDevToolsAvailability, |
| [email protected] | 9ec3ea5b | 2012-12-03 18:14:30 | [diff] [blame] | 124 | base::Bind(&BrowserCommandController::UpdateCommandsForDevTools, |
| 125 | base::Unretained(this))); |
| 126 | profile_pref_registrar_.Add( |
| tfarina | 3bddbe11 | 2014-08-28 05:29:32 | [diff] [blame] | 127 | bookmarks::prefs::kEditBookmarksEnabled, |
| [email protected] | 9ec3ea5b | 2012-12-03 18:14:30 | [diff] [blame] | 128 | base::Bind(&BrowserCommandController::UpdateCommandsForBookmarkEditing, |
| 129 | base::Unretained(this))); |
| 130 | profile_pref_registrar_.Add( |
| tfarina | 3bddbe11 | 2014-08-28 05:29:32 | [diff] [blame] | 131 | bookmarks::prefs::kShowBookmarkBar, |
| [email protected] | 9ec3ea5b | 2012-12-03 18:14:30 | [diff] [blame] | 132 | base::Bind(&BrowserCommandController::UpdateCommandsForBookmarkBar, |
| 133 | base::Unretained(this))); |
| 134 | profile_pref_registrar_.Add( |
| 135 | prefs::kIncognitoModeAvailability, |
| 136 | base::Bind( |
| 137 | &BrowserCommandController::UpdateCommandsForIncognitoAvailability, |
| 138 | base::Unretained(this))); |
| 139 | profile_pref_registrar_.Add( |
| 140 | prefs::kPrintingEnabled, |
| 141 | base::Bind(&BrowserCommandController::UpdatePrintingState, |
| 142 | base::Unretained(this))); |
| [email protected] | 32dfede | 2013-08-25 15:48:25 | [diff] [blame] | 143 | #if !defined(OS_MACOSX) |
| 144 | profile_pref_registrar_.Add( |
| 145 | prefs::kFullscreenAllowed, |
| 146 | base::Bind(&BrowserCommandController::UpdateCommandsForFullscreenMode, |
| 147 | base::Unretained(this))); |
| 148 | #endif |
| Mihai Sardarescu | f87ccc1 | 2018-09-26 10:37:45 | [diff] [blame] | 149 | pref_signin_allowed_.Init( |
| 150 | prefs::kSigninAllowed, |
| 151 | profile()->GetOriginalProfile()->GetPrefs(), |
| 152 | base::Bind(&BrowserCommandController::OnSigninAllowedPrefChange, |
| 153 | base::Unretained(this))); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 154 | |
| 155 | InitCommandState(); |
| 156 | |
| blundell | 74001adc | 2015-09-18 11:04:25 | [diff] [blame] | 157 | sessions::TabRestoreService* tab_restore_service = |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 158 | TabRestoreServiceFactory::GetForProfile(profile()); |
| 159 | if (tab_restore_service) { |
| 160 | tab_restore_service->AddObserver(this); |
| 161 | TabRestoreServiceChanged(tab_restore_service); |
| 162 | } |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | BrowserCommandController::~BrowserCommandController() { |
| [email protected] | 95e3947 | 2012-10-05 23:37:36 | [diff] [blame] | 166 | // TabRestoreService may have been shutdown by the time we get here. Don't |
| 167 | // trigger creating it. |
| blundell | 74001adc | 2015-09-18 11:04:25 | [diff] [blame] | 168 | sessions::TabRestoreService* tab_restore_service = |
| [email protected] | 95e3947 | 2012-10-05 23:37:36 | [diff] [blame] | 169 | TabRestoreServiceFactory::GetForProfileIfExisting(profile()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 170 | if (tab_restore_service) |
| 171 | tab_restore_service->RemoveObserver(this); |
| 172 | profile_pref_registrar_.RemoveAll(); |
| 173 | local_pref_registrar_.RemoveAll(); |
| 174 | browser_->tab_strip_model()->RemoveObserver(this); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | bool BrowserCommandController::IsReservedCommandOrKey( |
| 178 | int command_id, |
| 179 | const content::NativeWebKeyboardEvent& event) { |
| 180 | // In Apps mode, no keys are reserved. |
| 181 | if (browser_->is_app()) |
| 182 | return false; |
| 183 | |
| 184 | #if defined(OS_CHROMEOS) |
| [email protected] | 397abd3 | 2013-08-21 05:44:19 | [diff] [blame] | 185 | // On Chrome OS, the top row of keys are mapped to browser actions like |
| 186 | // back/forward or refresh. We don't want web pages to be able to change the |
| 187 | // behavior of these keys. Ash handles F4 and up; this leaves us needing to |
| 188 | // reserve browser back/forward and refresh here. |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 189 | ui::KeyboardCode key_code = |
| Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 190 | static_cast<ui::KeyboardCode>(event.windows_key_code); |
| [email protected] | 397abd3 | 2013-08-21 05:44:19 | [diff] [blame] | 191 | if ((key_code == ui::VKEY_BROWSER_BACK && command_id == IDC_BACK) || |
| 192 | (key_code == ui::VKEY_BROWSER_FORWARD && command_id == IDC_FORWARD) || |
| 193 | (key_code == ui::VKEY_BROWSER_REFRESH && command_id == IDC_RELOAD)) { |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 194 | return true; |
| 195 | } |
| 196 | #endif |
| 197 | |
| zijiehe | 68cd3dc2 | 2017-04-07 18:50:29 | [diff] [blame] | 198 | if (window()->IsFullscreen()) { |
| 199 | // In fullscreen, all commands except for IDC_FULLSCREEN and IDC_EXIT should |
| 200 | // be delivered to the web page. The intent to implement and ship can be |
| 201 | // found in http://crbug.com/680809. |
| 202 | const bool is_exit_fullscreen = |
| 203 | (command_id == IDC_EXIT || command_id == IDC_FULLSCREEN); |
| 204 | #if defined(OS_MACOSX) |
| 205 | // This behavior is different on Mac OS, which has a unique user-initiated |
| 206 | // full-screen mode. According to the discussion in http://crbug.com/702251, |
| 207 | // the commands should be reserved for browser-side handling if the browser |
| 208 | // window's toolbar is visible. |
| 209 | if (window()->IsToolbarShowing()) { |
| 210 | if (command_id == IDC_FULLSCREEN) |
| 211 | return true; |
| 212 | } else { |
| 213 | return is_exit_fullscreen; |
| 214 | } |
| 215 | #else |
| 216 | return is_exit_fullscreen; |
| 217 | #endif |
| 218 | } |
| [email protected] | 1e2172f | 2014-04-01 17:32:34 | [diff] [blame] | 219 | |
| [email protected] | 893124a2 | 2014-04-15 00:45:28 | [diff] [blame] | 220 | #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| [email protected] | 1e2172f | 2014-04-01 17:32:34 | [diff] [blame] | 221 | // If this key was registered by the user as a content editing hotkey, then |
| 222 | // it is not reserved. |
| [email protected] | d5bedb6d | 2014-04-08 10:49:32 | [diff] [blame] | 223 | ui::TextEditKeyBindingsDelegateAuraLinux* delegate = |
| [email protected] | 1e2172f | 2014-04-01 17:32:34 | [diff] [blame] | 224 | ui::GetTextEditKeyBindingsDelegate(); |
| [email protected] | 47e8e754 | 2014-04-03 07:52:42 | [diff] [blame] | 225 | if (delegate && event.os_event && delegate->MatchEvent(*event.os_event, NULL)) |
| [email protected] | 1e2172f | 2014-04-01 17:32:34 | [diff] [blame] | 226 | return false; |
| 227 | #endif |
| 228 | |
| zijiehe | 1320780 | 2017-02-16 08:06:10 | [diff] [blame] | 229 | return command_id == IDC_CLOSE_TAB || |
| 230 | command_id == IDC_CLOSE_WINDOW || |
| 231 | command_id == IDC_NEW_INCOGNITO_WINDOW || |
| 232 | command_id == IDC_NEW_TAB || |
| 233 | command_id == IDC_NEW_WINDOW || |
| 234 | command_id == IDC_RESTORE_TAB || |
| 235 | command_id == IDC_SELECT_NEXT_TAB || |
| 236 | command_id == IDC_SELECT_PREVIOUS_TAB || |
| 237 | command_id == IDC_EXIT; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 238 | } |
| 239 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 240 | void BrowserCommandController::TabStateChanged() { |
| 241 | UpdateCommandsForTabState(); |
| 242 | } |
| 243 | |
| [email protected] | d93dbd1 | 2014-08-04 23:42:53 | [diff] [blame] | 244 | void BrowserCommandController::ZoomStateChanged() { |
| 245 | UpdateCommandsForZoomState(); |
| 246 | } |
| 247 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 248 | void BrowserCommandController::ContentRestrictionsChanged() { |
| 249 | UpdateCommandsForContentRestrictionState(); |
| 250 | } |
| 251 | |
| 252 | void BrowserCommandController::FullscreenStateChanged() { |
| [email protected] | 32dfede | 2013-08-25 15:48:25 | [diff] [blame] | 253 | UpdateCommandsForFullscreenMode(); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 254 | } |
| 255 | |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 256 | #if defined(OS_CHROMEOS) |
| 257 | void BrowserCommandController::LockedFullscreenStateChanged() { |
| 258 | UpdateCommandsForLockedFullscreenMode(); |
| 259 | } |
| 260 | #endif |
| 261 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 262 | void BrowserCommandController::PrintingStateChanged() { |
| 263 | UpdatePrintingState(); |
| 264 | } |
| 265 | |
| 266 | void BrowserCommandController::LoadingStateChanged(bool is_loading, |
| 267 | bool force) { |
| 268 | UpdateReloadStopState(is_loading, force); |
| 269 | } |
| 270 | |
| wittman | 76df71db3 | 2014-12-18 23:26:58 | [diff] [blame] | 271 | void BrowserCommandController::ExtensionStateChanged() { |
| 272 | // Extensions may disable the bookmark editing commands. |
| 273 | UpdateCommandsForBookmarkEditing(); |
| 274 | } |
| 275 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 276 | //////////////////////////////////////////////////////////////////////////////// |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 277 | // BrowserCommandController, CommandUpdater implementation: |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 278 | |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 279 | bool BrowserCommandController::SupportsCommand(int id) const { |
| 280 | return command_updater_.SupportsCommand(id); |
| 281 | } |
| 282 | |
| 283 | bool BrowserCommandController::IsCommandEnabled(int id) const { |
| 284 | return command_updater_.IsCommandEnabled(id); |
| 285 | } |
| 286 | |
| 287 | bool BrowserCommandController::ExecuteCommand(int id) { |
| 288 | return ExecuteCommandWithDisposition(id, WindowOpenDisposition::CURRENT_TAB); |
| 289 | } |
| 290 | |
| 291 | bool BrowserCommandController::ExecuteCommandWithDisposition( |
| 292 | int id, WindowOpenDisposition disposition) { |
| 293 | // Doesn't go through the command_updater_ to avoid dealing with having a |
| 294 | // naming collision for ExecuteCommandWithDisposition (both |
| 295 | // CommandUpdaterDelegate and CommandUpdater declare this function so we |
| 296 | // choose to not implement CommandUpdaterDelegate inside this class and |
| 297 | // therefore command_updater_ doesn't have the delegate set). |
| 298 | if (!SupportsCommand(id) || !IsCommandEnabled(id)) |
| 299 | return false; |
| 300 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 301 | // No commands are enabled if there is not yet any selected tab. |
| 302 | // TODO(pkasting): It seems like we should not need this, because either |
| 303 | // most/all commands should not have been enabled yet anyway or the ones that |
| 304 | // are enabled should be global, or safe themselves against having no selected |
| 305 | // tab. However, Ben says he tried removing this before and got lots of |
| 306 | // crashes, e.g. from Windows sending WM_COMMANDs at random times during |
| 307 | // window construction. This probably could use closer examination someday. |
| [email protected] | 59253a65 | 2012-11-20 00:17:26 | [diff] [blame] | 308 | if (browser_->tab_strip_model()->active_index() == TabStripModel::kNoTab) |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 309 | return true; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 310 | |
| 311 | DCHECK(command_updater_.IsCommandEnabled(id)) << "Invalid/disabled command " |
| 312 | << id; |
| 313 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 314 | // The order of commands in this switch statement must match the function |
| 315 | // declaration order in browser.h! |
| 316 | switch (id) { |
| 317 | // Navigation commands |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 318 | case IDC_BACK: |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 319 | GoBack(browser_, disposition); |
| 320 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 321 | case IDC_FORWARD: |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 322 | GoForward(browser_, disposition); |
| 323 | break; |
| 324 | case IDC_RELOAD: |
| 325 | Reload(browser_, disposition); |
| 326 | break; |
| [email protected] | 58e2903 | 2012-08-06 20:19:57 | [diff] [blame] | 327 | case IDC_RELOAD_CLEARING_CACHE: |
| 328 | ClearCache(browser_); |
| Nico Weber | a745ef7 | 2018-01-29 23:45:57 | [diff] [blame] | 329 | FALLTHROUGH; |
| toyoshim | 7dad4b118 | 2016-04-01 14:28:05 | [diff] [blame] | 330 | case IDC_RELOAD_BYPASSING_CACHE: |
| 331 | ReloadBypassingCache(browser_, disposition); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 332 | break; |
| 333 | case IDC_HOME: |
| 334 | Home(browser_, disposition); |
| 335 | break; |
| 336 | case IDC_OPEN_CURRENT_URL: |
| 337 | OpenCurrentURL(browser_); |
| 338 | break; |
| 339 | case IDC_STOP: |
| 340 | Stop(browser_); |
| 341 | break; |
| 342 | |
| 343 | // Window management commands |
| 344 | case IDC_NEW_WINDOW: |
| 345 | NewWindow(browser_); |
| 346 | break; |
| 347 | case IDC_NEW_INCOGNITO_WINDOW: |
| Orin Jaworski | 5e4bcd0c | 2018-10-16 19:35:05 | [diff] [blame] | 348 | NewIncognitoWindow(profile()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 349 | break; |
| 350 | case IDC_CLOSE_WINDOW: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 351 | base::RecordAction(base::UserMetricsAction("CloseWindowByKey")); |
| [email protected] | 04b9e69 | 2012-08-24 14:49:09 | [diff] [blame] | 352 | CloseWindow(browser_); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 353 | break; |
| Bettina Dea | 0a450592 | 2017-09-28 00:53:32 | [diff] [blame] | 354 | case IDC_NEW_TAB: { |
| 355 | NewTab(browser_); |
| 356 | #if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP) |
| Catherine Chung | beb88422 | 2017-08-01 15:47:55 | [diff] [blame] | 357 | // This is not in NewTab() to avoid tracking programmatic creation of new |
| 358 | // tabs by extensions. |
| Bettina Dea | 0a450592 | 2017-09-28 00:53:32 | [diff] [blame] | 359 | auto* new_tab_tracker = |
| 360 | feature_engagement::NewTabTrackerFactory::GetInstance() |
| 361 | ->GetForProfile(profile()); |
| 362 | |
| 363 | new_tab_tracker->OnNewTabOpened(); |
| 364 | new_tab_tracker->CloseBubble(); |
| Catherine Chung | beb88422 | 2017-08-01 15:47:55 | [diff] [blame] | 365 | #endif |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 366 | break; |
| Bettina Dea | 0a450592 | 2017-09-28 00:53:32 | [diff] [blame] | 367 | } |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 368 | case IDC_CLOSE_TAB: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 369 | base::RecordAction(base::UserMetricsAction("CloseTabByKey")); |
| [email protected] | 04b9e69 | 2012-08-24 14:49:09 | [diff] [blame] | 370 | CloseTab(browser_); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 371 | break; |
| 372 | case IDC_SELECT_NEXT_TAB: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 373 | base::RecordAction(base::UserMetricsAction("Accel_SelectNextTab")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 374 | SelectNextTab(browser_); |
| 375 | break; |
| 376 | case IDC_SELECT_PREVIOUS_TAB: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 377 | base::RecordAction(base::UserMetricsAction("Accel_SelectPreviousTab")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 378 | SelectPreviousTab(browser_); |
| 379 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 380 | case IDC_MOVE_TAB_NEXT: |
| 381 | MoveTabNext(browser_); |
| 382 | break; |
| 383 | case IDC_MOVE_TAB_PREVIOUS: |
| 384 | MoveTabPrevious(browser_); |
| 385 | break; |
| 386 | case IDC_SELECT_TAB_0: |
| 387 | case IDC_SELECT_TAB_1: |
| 388 | case IDC_SELECT_TAB_2: |
| 389 | case IDC_SELECT_TAB_3: |
| 390 | case IDC_SELECT_TAB_4: |
| 391 | case IDC_SELECT_TAB_5: |
| 392 | case IDC_SELECT_TAB_6: |
| 393 | case IDC_SELECT_TAB_7: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 394 | base::RecordAction(base::UserMetricsAction("Accel_SelectNumberedTab")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 395 | SelectNumberedTab(browser_, id - IDC_SELECT_TAB_0); |
| 396 | break; |
| 397 | case IDC_SELECT_LAST_TAB: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 398 | base::RecordAction(base::UserMetricsAction("Accel_SelectNumberedTab")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 399 | SelectLastTab(browser_); |
| 400 | break; |
| 401 | case IDC_DUPLICATE_TAB: |
| 402 | DuplicateTab(browser_); |
| 403 | break; |
| 404 | case IDC_RESTORE_TAB: |
| 405 | RestoreTab(browser_); |
| 406 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 407 | case IDC_SHOW_AS_TAB: |
| 408 | ConvertPopupToTabbedBrowser(browser_); |
| 409 | break; |
| 410 | case IDC_FULLSCREEN: |
| [email protected] | 3f32b9b | 2012-07-09 16:59:28 | [diff] [blame] | 411 | chrome::ToggleFullscreenMode(browser_); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 412 | break; |
| Alan Cutter | 0996580 | 2018-03-27 07:25:29 | [diff] [blame] | 413 | case IDC_OPEN_IN_PWA_WINDOW: |
| 414 | base::RecordAction(base::UserMetricsAction("OpenActiveTabInPwaWindow")); |
| 415 | ReparentSecureActiveTabIntoPwaWindow(browser_); |
| 416 | break; |
| [email protected] | 770c6d8 | 2012-09-06 22:21:32 | [diff] [blame] | 417 | |
| [email protected] | d12cc5e | 2013-10-19 18:25:06 | [diff] [blame] | 418 | #if defined(OS_CHROMEOS) |
| 419 | case IDC_VISIT_DESKTOP_OF_LRU_USER_2: |
| [email protected] | 0c93081 | 2014-01-30 18:01:47 | [diff] [blame] | 420 | case IDC_VISIT_DESKTOP_OF_LRU_USER_3: |
| zijiehe | 4dde807 | 2017-02-13 20:38:35 | [diff] [blame] | 421 | ExecuteVisitDesktopCommand(id, window()->GetNativeWindow()); |
| [email protected] | 0c93081 | 2014-01-30 18:01:47 | [diff] [blame] | 422 | break; |
| [email protected] | d12cc5e | 2013-10-19 18:25:06 | [diff] [blame] | 423 | #endif |
| 424 | |
| [email protected] | 893124a2 | 2014-04-15 00:45:28 | [diff] [blame] | 425 | #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| Tom Anderson | f15ede50 | 2017-11-10 03:17:15 | [diff] [blame] | 426 | case IDC_MINIMIZE_WINDOW: |
| 427 | browser_->window()->Minimize(); |
| 428 | break; |
| 429 | case IDC_MAXIMIZE_WINDOW: |
| 430 | browser_->window()->Maximize(); |
| 431 | break; |
| 432 | case IDC_RESTORE_WINDOW: |
| 433 | browser_->window()->Restore(); |
| 434 | break; |
| [email protected] | af97be4c6 | 2014-02-13 14:43:34 | [diff] [blame] | 435 | case IDC_USE_SYSTEM_TITLE_BAR: { |
| zijiehe | 4dde807 | 2017-02-13 20:38:35 | [diff] [blame] | 436 | PrefService* prefs = profile()->GetPrefs(); |
| [email protected] | af97be4c6 | 2014-02-13 14:43:34 | [diff] [blame] | 437 | prefs->SetBoolean(prefs::kUseCustomChromeFrame, |
| 438 | !prefs->GetBoolean(prefs::kUseCustomChromeFrame)); |
| 439 | break; |
| 440 | } |
| 441 | #endif |
| 442 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 443 | #if defined(OS_MACOSX) |
| spqchan | b8ffc7d | 2015-11-17 01:17:21 | [diff] [blame] | 444 | case IDC_TOGGLE_FULLSCREEN_TOOLBAR: |
| 445 | chrome::ToggleFullscreenToolbar(browser_); |
| 446 | break; |
| spqchan | 2c5d541e | 2017-10-25 07:07:11 | [diff] [blame] | 447 | case IDC_TOGGLE_JAVASCRIPT_APPLE_EVENTS: { |
| Robert Sesek | 0328261 | 2018-10-31 15:48:06 | [diff] [blame] | 448 | chrome::ToggleJavaScriptFromAppleEventsAllowed(browser_); |
| spqchan | 2c5d541e | 2017-10-25 07:07:11 | [diff] [blame] | 449 | break; |
| 450 | } |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 451 | #endif |
| 452 | case IDC_EXIT: |
| 453 | Exit(); |
| 454 | break; |
| 455 | |
| 456 | // Page-related commands |
| 457 | case IDC_SAVE_PAGE: |
| 458 | SavePage(browser_); |
| 459 | break; |
| 460 | case IDC_BOOKMARK_PAGE: |
| Anatoly Pilikov | ee72092 | 2017-11-01 09:43:17 | [diff] [blame] | 461 | #if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP) |
| Bettina Dea | 48125dc | 2017-09-06 03:23:14 | [diff] [blame] | 462 | feature_engagement::BookmarkTrackerFactory::GetInstance() |
| 463 | ->GetForProfile(profile()) |
| 464 | ->OnBookmarkAdded(); |
| 465 | #endif |
| deepak.m1 | 54a7f39 | 2014-12-15 04:41:43 | [diff] [blame] | 466 | BookmarkCurrentPageAllowingExtensionOverrides(browser_); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 467 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 468 | case IDC_BOOKMARK_ALL_TABS: |
| Anatoly Pilikov | ee72092 | 2017-11-01 09:43:17 | [diff] [blame] | 469 | #if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP) |
| Bettina Dea | 48125dc | 2017-09-06 03:23:14 | [diff] [blame] | 470 | feature_engagement::BookmarkTrackerFactory::GetInstance() |
| 471 | ->GetForProfile(profile()) |
| 472 | ->OnBookmarkAdded(); |
| 473 | #endif |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 474 | BookmarkAllTabs(browser_); |
| 475 | break; |
| 476 | case IDC_VIEW_SOURCE: |
| Lukasz Anforowicz | e1b954d9 | 2017-10-30 21:28:06 | [diff] [blame] | 477 | browser_->tab_strip_model() |
| 478 | ->GetActiveWebContents() |
| 479 | ->GetMainFrame() |
| 480 | ->ViewSource(); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 481 | break; |
| 482 | case IDC_EMAIL_PAGE_LOCATION: |
| 483 | EmailPageLocation(browser_); |
| 484 | break; |
| 485 | case IDC_PRINT: |
| 486 | Print(browser_); |
| 487 | break; |
| bondd | 052b5f8 | 2015-10-28 22:39:32 | [diff] [blame] | 488 | |
| Lei Zhang | 48a4a526 | 2018-04-17 20:18:44 | [diff] [blame] | 489 | #if BUILDFLAG(ENABLE_PRINTING) |
| vitalybuka | f9433e4 | 2014-09-08 10:04:55 | [diff] [blame] | 490 | case IDC_BASIC_PRINT: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 491 | base::RecordAction(base::UserMetricsAction("Accel_Advanced_Print")); |
| vitalybuka | f9433e4 | 2014-09-08 10:04:55 | [diff] [blame] | 492 | BasicPrint(browser_); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 493 | break; |
| Lei Zhang | 48a4a526 | 2018-04-17 20:18:44 | [diff] [blame] | 494 | #endif // ENABLE_PRINTING |
| bondd | 052b5f8 | 2015-10-28 22:39:32 | [diff] [blame] | 495 | |
| bondd | 052b5f8 | 2015-10-28 22:39:32 | [diff] [blame] | 496 | case IDC_SAVE_CREDIT_CARD_FOR_PAGE: |
| 497 | SaveCreditCard(browser_); |
| 498 | break; |
| siyua | 3e599eaa | 2018-07-13 00:23:06 | [diff] [blame] | 499 | case IDC_MIGRATE_LOCAL_CREDIT_CARD_FOR_PAGE: |
| 500 | MigrateLocalCards(browser_); |
| 501 | break; |
| [email protected] | e625b760 | 2013-10-28 09:24:56 | [diff] [blame] | 502 | case IDC_TRANSLATE_PAGE: |
| 503 | Translate(browser_); |
| 504 | break; |
| [email protected] | 4bee443 | 2014-05-05 13:11:41 | [diff] [blame] | 505 | case IDC_MANAGE_PASSWORDS_FOR_PAGE: |
| 506 | ManagePasswordsForPage(browser_); |
| 507 | break; |
| Tina Wang | 788aac2 | 2018-12-21 20:25:46 | [diff] [blame] | 508 | case IDC_SEND_TO_MY_DEVICES: |
| 509 | SendToMyDevices(browser_); |
| 510 | break; |
| [email protected] | 4bee443 | 2014-05-05 13:11:41 | [diff] [blame] | 511 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 512 | // Clipboard commands |
| 513 | case IDC_CUT: |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 514 | case IDC_COPY: |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 515 | case IDC_PASTE: |
| pkasting | cd3f08bce | 2015-04-18 13:37:12 | [diff] [blame] | 516 | CutCopyPaste(browser_, id); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 517 | break; |
| 518 | |
| 519 | // Find-in-page |
| 520 | case IDC_FIND: |
| 521 | Find(browser_); |
| 522 | break; |
| 523 | case IDC_FIND_NEXT: |
| 524 | FindNext(browser_); |
| 525 | break; |
| 526 | case IDC_FIND_PREVIOUS: |
| 527 | FindPrevious(browser_); |
| 528 | break; |
| 529 | |
| 530 | // Zoom |
| 531 | case IDC_ZOOM_PLUS: |
| 532 | Zoom(browser_, content::PAGE_ZOOM_IN); |
| 533 | break; |
| 534 | case IDC_ZOOM_NORMAL: |
| 535 | Zoom(browser_, content::PAGE_ZOOM_RESET); |
| 536 | break; |
| 537 | case IDC_ZOOM_MINUS: |
| 538 | Zoom(browser_, content::PAGE_ZOOM_OUT); |
| 539 | break; |
| 540 | |
| 541 | // Focus various bits of UI |
| 542 | case IDC_FOCUS_TOOLBAR: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 543 | base::RecordAction(base::UserMetricsAction("Accel_Focus_Toolbar")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 544 | FocusToolbar(browser_); |
| 545 | break; |
| 546 | case IDC_FOCUS_LOCATION: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 547 | base::RecordAction(base::UserMetricsAction("Accel_Focus_Location")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 548 | FocusLocationBar(browser_); |
| 549 | break; |
| 550 | case IDC_FOCUS_SEARCH: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 551 | base::RecordAction(base::UserMetricsAction("Accel_Focus_Search")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 552 | FocusSearch(browser_); |
| 553 | break; |
| 554 | case IDC_FOCUS_MENU_BAR: |
| 555 | FocusAppMenu(browser_); |
| 556 | break; |
| 557 | case IDC_FOCUS_BOOKMARKS: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 558 | base::RecordAction(base::UserMetricsAction("Accel_Focus_Bookmarks")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 559 | FocusBookmarksToolbar(browser_); |
| 560 | break; |
| David Tseng | c0b1b64 | 2018-01-24 07:12:27 | [diff] [blame] | 561 | case IDC_FOCUS_INACTIVE_POPUP_FOR_ACCESSIBILITY: |
| 562 | FocusInactivePopupForAccessibility(browser_); |
| [email protected] | 822ca8c6 | 2013-04-19 00:49:15 | [diff] [blame] | 563 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 564 | case IDC_FOCUS_NEXT_PANE: |
| 565 | FocusNextPane(browser_); |
| 566 | break; |
| 567 | case IDC_FOCUS_PREVIOUS_PANE: |
| 568 | FocusPreviousPane(browser_); |
| 569 | break; |
| 570 | |
| 571 | // Show various bits of UI |
| 572 | case IDC_OPEN_FILE: |
| 573 | browser_->OpenFile(); |
| 574 | break; |
| Alan Cutter | 81ac72668 | 2018-09-25 00:18:36 | [diff] [blame] | 575 | case IDC_CREATE_SHORTCUT: |
| 576 | CreateBookmarkAppFromCurrentWebContents(browser_, |
| 577 | true /* force_shortcut_app */); |
| 578 | break; |
| 579 | case IDC_INSTALL_PWA: |
| 580 | CreateBookmarkAppFromCurrentWebContents(browser_, |
| 581 | false /* force_shortcut_app */); |
| [email protected] | 488e395 | 2013-11-18 05:29:14 | [diff] [blame] | 582 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 583 | case IDC_DEV_TOOLS: |
| [email protected] | c934c38 | 2013-11-01 00:36:01 | [diff] [blame] | 584 | ToggleDevToolsWindow(browser_, DevToolsToggleAction::Show()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 585 | break; |
| 586 | case IDC_DEV_TOOLS_CONSOLE: |
| einbinder | dfa567b | 2016-12-16 01:15:52 | [diff] [blame] | 587 | ToggleDevToolsWindow(browser_, DevToolsToggleAction::ShowConsolePanel()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 588 | break; |
| [email protected] | 2056c319 | 2013-10-21 22:40:51 | [diff] [blame] | 589 | case IDC_DEV_TOOLS_DEVICES: |
| 590 | InspectUI::InspectDevices(browser_); |
| 591 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 592 | case IDC_DEV_TOOLS_INSPECT: |
| [email protected] | c934c38 | 2013-11-01 00:36:01 | [diff] [blame] | 593 | ToggleDevToolsWindow(browser_, DevToolsToggleAction::Inspect()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 594 | break; |
| [email protected] | d16657c | 2012-09-03 14:25:10 | [diff] [blame] | 595 | case IDC_DEV_TOOLS_TOGGLE: |
| [email protected] | c934c38 | 2013-11-01 00:36:01 | [diff] [blame] | 596 | ToggleDevToolsWindow(browser_, DevToolsToggleAction::Toggle()); |
| [email protected] | d16657c | 2012-09-03 14:25:10 | [diff] [blame] | 597 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 598 | case IDC_TASK_MANAGER: |
| [email protected] | 29c262de | 2013-06-22 15:39:38 | [diff] [blame] | 599 | OpenTaskManager(browser_); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 600 | break; |
| caelyn | 4e4e08a | 2015-02-04 21:27:49 | [diff] [blame] | 601 | #if defined(OS_CHROMEOS) |
| 602 | case IDC_TAKE_SCREENSHOT: |
| 603 | TakeScreenshot(); |
| 604 | break; |
| 605 | #endif |
| [email protected] | 236ad302 | 2013-09-04 03:27:43 | [diff] [blame] | 606 | #if defined(GOOGLE_CHROME_BUILD) |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 607 | case IDC_FEEDBACK: |
| afakhry | f4575bd | 2017-04-28 02:21:04 | [diff] [blame] | 608 | OpenFeedbackDialog(browser_, kFeedbackSourceBrowserCommand); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 609 | break; |
| [email protected] | 236ad302 | 2013-09-04 03:27:43 | [diff] [blame] | 610 | #endif |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 611 | case IDC_SHOW_BOOKMARK_BAR: |
| 612 | ToggleBookmarkBar(browser_); |
| 613 | break; |
| 614 | case IDC_PROFILING_ENABLED: |
| Bryce Thomas | 96b0777 | 2018-11-07 03:04:15 | [diff] [blame] | 615 | content::Profiling::Toggle(); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 616 | break; |
| 617 | |
| 618 | case IDC_SHOW_BOOKMARK_MANAGER: |
| 619 | ShowBookmarkManager(browser_); |
| 620 | break; |
| 621 | case IDC_SHOW_APP_MENU: |
| bratell | 0a7406f | 2017-03-28 07:46:37 | [diff] [blame] | 622 | base::RecordAction(base::UserMetricsAction("Accel_Show_App_Menu")); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 623 | ShowAppMenu(browser_); |
| 624 | break; |
| 625 | case IDC_SHOW_AVATAR_MENU: |
| 626 | ShowAvatarMenu(browser_); |
| 627 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 628 | case IDC_SHOW_HISTORY: |
| 629 | ShowHistory(browser_); |
| 630 | break; |
| 631 | case IDC_SHOW_DOWNLOADS: |
| 632 | ShowDownloads(browser_); |
| 633 | break; |
| 634 | case IDC_MANAGE_EXTENSIONS: |
| [email protected] | bc9833c3 | 2013-02-28 04:05:08 | [diff] [blame] | 635 | ShowExtensions(browser_, std::string()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 636 | break; |
| 637 | case IDC_OPTIONS: |
| 638 | ShowSettings(browser_); |
| 639 | break; |
| 640 | case IDC_EDIT_SEARCH_ENGINES: |
| 641 | ShowSearchEngineSettings(browser_); |
| 642 | break; |
| 643 | case IDC_VIEW_PASSWORDS: |
| 644 | ShowPasswordManager(browser_); |
| 645 | break; |
| 646 | case IDC_CLEAR_BROWSING_DATA: |
| 647 | ShowClearBrowsingDataDialog(browser_); |
| 648 | break; |
| 649 | case IDC_IMPORT_SETTINGS: |
| 650 | ShowImportDialog(browser_); |
| 651 | break; |
| [email protected] | 9b7ab88 | 2012-09-10 23:46:36 | [diff] [blame] | 652 | case IDC_TOGGLE_REQUEST_TABLET_SITE: |
| 653 | ToggleRequestTabletSite(browser_); |
| 654 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 655 | case IDC_ABOUT: |
| 656 | ShowAboutChrome(browser_); |
| 657 | break; |
| 658 | case IDC_UPGRADE_DIALOG: |
| 659 | OpenUpdateChromeDialog(browser_); |
| 660 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 661 | case IDC_HELP_PAGE_VIA_KEYBOARD: |
| 662 | ShowHelp(browser_, HELP_SOURCE_KEYBOARD); |
| 663 | break; |
| 664 | case IDC_HELP_PAGE_VIA_MENU: |
| 665 | ShowHelp(browser_, HELP_SOURCE_MENU); |
| 666 | break; |
| Bret Sepulveda | 2d01866 | 2017-05-18 21:31:48 | [diff] [blame] | 667 | case IDC_SHOW_BETA_FORUM: |
| 668 | ShowBetaForum(browser_); |
| 669 | break; |
| David Roger | 7e25dff | 2019-02-07 09:03:17 | [diff] [blame^] | 670 | #if !defined(OS_CHROMEOS) |
| estade | 8c0780f | 2015-08-21 23:36:41 | [diff] [blame] | 671 | case IDC_SHOW_SIGNIN: |
| gogerald | 71bf6c90 | 2015-12-08 00:49:37 | [diff] [blame] | 672 | ShowBrowserSigninOrSettings( |
| 673 | browser_, signin_metrics::AccessPoint::ACCESS_POINT_MENU); |
| estade | 8c0780f | 2015-08-21 23:36:41 | [diff] [blame] | 674 | break; |
| David Roger | 7e25dff | 2019-02-07 09:03:17 | [diff] [blame^] | 675 | #endif |
| [email protected] | 6bd370b | 2014-05-28 14:19:47 | [diff] [blame] | 676 | case IDC_DISTILL_PAGE: |
| 677 | DistillCurrentPage(browser_); |
| 678 | break; |
| apacible | 45cbfc9 | 2015-09-28 22:45:41 | [diff] [blame] | 679 | case IDC_ROUTE_MEDIA: |
| 680 | RouteMedia(browser_); |
| 681 | break; |
| Tommy Steimel | c447798 | 2017-11-29 18:07:18 | [diff] [blame] | 682 | case IDC_WINDOW_MUTE_SITE: |
| 683 | MuteSite(browser_); |
| ellyjones | 0101ba0 | 2017-05-19 15:50:26 | [diff] [blame] | 684 | break; |
| 685 | case IDC_WINDOW_PIN_TAB: |
| 686 | PinTab(browser_); |
| 687 | break; |
| Nicolas Ouellet-payeur | 82eb65b | 2018-11-05 16:49:27 | [diff] [blame] | 688 | case IDC_MANAGED_UI_HELP: |
| 689 | ShowSingletonTab(browser_, GURL(kManagedUiLearnMoreUrl)); |
| 690 | break; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 691 | |
| Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 692 | // Hosted App commands |
| 693 | case IDC_COPY_URL: |
| 694 | CopyURL(browser_); |
| 695 | break; |
| 696 | case IDC_OPEN_IN_CHROME: |
| 697 | OpenInChrome(browser_); |
| 698 | break; |
| 699 | case IDC_SITE_SETTINGS: |
| 700 | ShowSiteSettings( |
| 701 | browser_, |
| 702 | browser_->tab_strip_model()->GetActiveWebContents()->GetVisibleURL()); |
| 703 | break; |
| Alan Cutter | 0c313230 | 2018-02-21 05:09:02 | [diff] [blame] | 704 | case IDC_HOSTED_APP_MENU_APP_INFO: |
| 705 | ShowPageInfoDialog(browser_->tab_strip_model()->GetActiveWebContents(), |
| Alan Cutter | 689f89a | 2018-03-08 05:09:54 | [diff] [blame] | 706 | bubble_anchor_util::kAppMenuButton); |
| Christopher Lam | 86b5271 | 2017-12-04 01:58:33 | [diff] [blame] | 707 | break; |
| Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 708 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 709 | default: |
| 710 | LOG(WARNING) << "Received Unimplemented Command: " << id; |
| 711 | break; |
| 712 | } |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 713 | |
| 714 | return true; |
| 715 | } |
| 716 | |
| 717 | void BrowserCommandController::AddCommandObserver(int id, |
| 718 | CommandObserver* observer) { |
| 719 | command_updater_.AddCommandObserver(id, observer); |
| 720 | } |
| 721 | |
| 722 | void BrowserCommandController::RemoveCommandObserver( |
| 723 | int id, CommandObserver* observer) { |
| 724 | command_updater_.RemoveCommandObserver(id, observer); |
| 725 | } |
| 726 | |
| 727 | void BrowserCommandController::RemoveCommandObserver( |
| 728 | CommandObserver* observer) { |
| 729 | command_updater_.RemoveCommandObserver(observer); |
| 730 | } |
| 731 | |
| 732 | bool BrowserCommandController::UpdateCommandEnabled(int id, bool state) { |
| 733 | if (is_locked_fullscreen_) |
| 734 | return false; |
| 735 | |
| 736 | return command_updater_.UpdateCommandEnabled(id, state); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 737 | } |
| 738 | |
| Mihai Sardarescu | f87ccc1 | 2018-09-26 10:37:45 | [diff] [blame] | 739 | //////////////////////////////////////////////////////////////////////////////// |
| 740 | // BrowserCommandController, SigninPrefObserver implementation: |
| 741 | |
| 742 | void BrowserCommandController::OnSigninAllowedPrefChange() { |
| 743 | // For unit tests, we don't have a window. |
| 744 | if (!window()) |
| 745 | return; |
| 746 | UpdateShowSyncState(IsShowingMainUI()); |
| 747 | } |
| 748 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 749 | // BrowserCommandController, TabStripModelObserver implementation: |
| 750 | |
| sangwoo.ko | 1ae265f1 | 2018-10-18 08:30:28 | [diff] [blame] | 751 | void BrowserCommandController::OnTabStripModelChanged( |
| 752 | TabStripModel* tab_strip_model, |
| 753 | const TabStripModelChange& change, |
| 754 | const TabStripSelectionChange& selection) { |
| 755 | if (change.type() != TabStripModelChange::kInserted && |
| 756 | change.type() != TabStripModelChange::kReplaced && |
| 757 | change.type() != TabStripModelChange::kRemoved) |
| 758 | return; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 759 | |
| sangwoo.ko | 1ae265f1 | 2018-10-18 08:30:28 | [diff] [blame] | 760 | for (const auto& delta : change.deltas()) { |
| 761 | content::WebContents* new_contents = nullptr; |
| 762 | content::WebContents* old_contents = nullptr; |
| 763 | if (change.type() == TabStripModelChange::kInserted) { |
| 764 | new_contents = delta.insert.contents; |
| 765 | } else if (change.type() == TabStripModelChange::kReplaced) { |
| 766 | new_contents = delta.replace.new_contents; |
| 767 | old_contents = delta.replace.old_contents; |
| 768 | } else { |
| 769 | old_contents = delta.remove.contents; |
| 770 | } |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 771 | |
| sangwoo.ko | 1ae265f1 | 2018-10-18 08:30:28 | [diff] [blame] | 772 | if (old_contents) |
| 773 | RemoveInterstitialObservers(old_contents); |
| 774 | if (new_contents) |
| 775 | AddInterstitialObservers(new_contents); |
| 776 | } |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 777 | } |
| 778 | |
| [email protected] | 3cac8723 | 2012-11-20 01:48:27 | [diff] [blame] | 779 | void BrowserCommandController::TabBlockedStateChanged( |
| 780 | content::WebContents* contents, |
| 781 | int index) { |
| 782 | PrintingStateChanged(); |
| 783 | FullscreenStateChanged(); |
| 784 | UpdateCommandsForFind(); |
| apacible | 45cbfc9 | 2015-09-28 22:45:41 | [diff] [blame] | 785 | UpdateCommandsForMediaRouter(); |
| [email protected] | 3cac8723 | 2012-11-20 01:48:27 | [diff] [blame] | 786 | } |
| 787 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 788 | //////////////////////////////////////////////////////////////////////////////// |
| 789 | // BrowserCommandController, TabRestoreServiceObserver implementation: |
| 790 | |
| 791 | void BrowserCommandController::TabRestoreServiceChanged( |
| blundell | 74001adc | 2015-09-18 11:04:25 | [diff] [blame] | 792 | sessions::TabRestoreService* service) { |
| [email protected] | 2e9369e | 2014-08-15 09:12:53 | [diff] [blame] | 793 | UpdateTabRestoreCommandState(); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | void BrowserCommandController::TabRestoreServiceDestroyed( |
| blundell | 74001adc | 2015-09-18 11:04:25 | [diff] [blame] | 797 | sessions::TabRestoreService* service) { |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 798 | service->RemoveObserver(this); |
| 799 | } |
| 800 | |
| [email protected] | 2e9369e | 2014-08-15 09:12:53 | [diff] [blame] | 801 | void BrowserCommandController::TabRestoreServiceLoaded( |
| blundell | 74001adc | 2015-09-18 11:04:25 | [diff] [blame] | 802 | sessions::TabRestoreService* service) { |
| [email protected] | 2e9369e | 2014-08-15 09:12:53 | [diff] [blame] | 803 | UpdateTabRestoreCommandState(); |
| 804 | } |
| 805 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 806 | //////////////////////////////////////////////////////////////////////////////// |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 807 | // BrowserCommandController, private: |
| 808 | |
| [email protected] | 20ca038 | 2013-02-28 19:50:07 | [diff] [blame] | 809 | class BrowserCommandController::InterstitialObserver |
| 810 | : public content::WebContentsObserver { |
| 811 | public: |
| 812 | InterstitialObserver(BrowserCommandController* controller, |
| 813 | content::WebContents* web_contents) |
| 814 | : WebContentsObserver(web_contents), |
| 815 | controller_(controller) { |
| 816 | } |
| 817 | |
| dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 818 | void DidAttachInterstitialPage() override { |
| [email protected] | 20ca038 | 2013-02-28 19:50:07 | [diff] [blame] | 819 | controller_->UpdateCommandsForTabState(); |
| 820 | } |
| 821 | |
| dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 822 | void DidDetachInterstitialPage() override { |
| [email protected] | 20ca038 | 2013-02-28 19:50:07 | [diff] [blame] | 823 | controller_->UpdateCommandsForTabState(); |
| 824 | } |
| 825 | |
| 826 | private: |
| 827 | BrowserCommandController* controller_; |
| 828 | |
| 829 | DISALLOW_COPY_AND_ASSIGN(InterstitialObserver); |
| 830 | }; |
| 831 | |
| [email protected] | 6a414ff | 2013-02-27 08:22:54 | [diff] [blame] | 832 | bool BrowserCommandController::IsShowingMainUI() { |
| manuk | f1a11639 | 2018-10-25 16:28:24 | [diff] [blame] | 833 | return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); |
| 834 | } |
| 835 | |
| 836 | bool BrowserCommandController::IsShowingLocationBar() { |
| 837 | return browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | void BrowserCommandController::InitCommandState() { |
| 841 | // All browser commands whose state isn't set automagically some other way |
| 842 | // (like Back & Forward with initial page load) must have their state |
| 843 | // initialized here, otherwise they will be forever disabled. |
| 844 | |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 845 | if (is_locked_fullscreen_) |
| 846 | return; |
| 847 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 848 | // Navigation commands |
| 849 | command_updater_.UpdateCommandEnabled(IDC_RELOAD, true); |
| toyoshim | 7dad4b118 | 2016-04-01 14:28:05 | [diff] [blame] | 850 | command_updater_.UpdateCommandEnabled(IDC_RELOAD_BYPASSING_CACHE, true); |
| [email protected] | 58e2903 | 2012-08-06 20:19:57 | [diff] [blame] | 851 | command_updater_.UpdateCommandEnabled(IDC_RELOAD_CLEARING_CACHE, true); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 852 | |
| 853 | // Window management commands |
| 854 | command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true); |
| 855 | command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true); |
| 856 | command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true); |
| 857 | command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, true); |
| [email protected] | 2e9369e | 2014-08-15 09:12:53 | [diff] [blame] | 858 | UpdateTabRestoreCommandState(); |
| [email protected] | d28d378 | 2013-02-26 16:31:55 | [diff] [blame] | 859 | command_updater_.UpdateCommandEnabled(IDC_EXIT, true); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 860 | command_updater_.UpdateCommandEnabled(IDC_DEBUG_FRAME_TOGGLE, true); |
| [email protected] | d12cc5e | 2013-10-19 18:25:06 | [diff] [blame] | 861 | #if defined(OS_CHROMEOS) |
| James Cook | 934abaf | 2017-09-19 22:21:58 | [diff] [blame] | 862 | command_updater_.UpdateCommandEnabled(IDC_MINIMIZE_WINDOW, true); |
| [email protected] | d12cc5e | 2013-10-19 18:25:06 | [diff] [blame] | 863 | command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_2, true); |
| 864 | command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_3, true); |
| 865 | #endif |
| [email protected] | 893124a2 | 2014-04-15 00:45:28 | [diff] [blame] | 866 | #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| Tom Anderson | f15ede50 | 2017-11-10 03:17:15 | [diff] [blame] | 867 | command_updater_.UpdateCommandEnabled(IDC_MINIMIZE_WINDOW, true); |
| 868 | command_updater_.UpdateCommandEnabled(IDC_MAXIMIZE_WINDOW, true); |
| 869 | command_updater_.UpdateCommandEnabled(IDC_RESTORE_WINDOW, true); |
| Maksim Sisov | ac76759 | 2018-08-10 08:00:15 | [diff] [blame] | 870 | bool use_system_title_bar = true; |
| 871 | #if defined(USE_OZONE) |
| 872 | use_system_title_bar = ui::OzonePlatform::GetInstance() |
| 873 | ->GetPlatformProperties() |
| 874 | .use_system_title_bar; |
| 875 | #endif |
| 876 | command_updater_.UpdateCommandEnabled(IDC_USE_SYSTEM_TITLE_BAR, |
| 877 | use_system_title_bar); |
| [email protected] | af97be4c6 | 2014-02-13 14:43:34 | [diff] [blame] | 878 | #endif |
| Alan Cutter | 0996580 | 2018-03-27 07:25:29 | [diff] [blame] | 879 | command_updater_.UpdateCommandEnabled(IDC_OPEN_IN_PWA_WINDOW, true); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 880 | |
| 881 | // Page-related commands |
| 882 | command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true); |
| [email protected] | 4bee443 | 2014-05-05 13:11:41 | [diff] [blame] | 883 | command_updater_.UpdateCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE, true); |
| Tina Wang | 788aac2 | 2018-12-21 20:25:46 | [diff] [blame] | 884 | command_updater_.UpdateCommandEnabled(IDC_SEND_TO_MY_DEVICES, true); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 885 | |
| 886 | // Zoom |
| 887 | command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true); |
| 888 | command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true); |
| [email protected] | d93dbd1 | 2014-08-04 23:42:53 | [diff] [blame] | 889 | command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, false); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 890 | command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true); |
| 891 | |
| 892 | // Show various bits of UI |
| mlerman | 7831f57d | 2015-05-25 11:40:15 | [diff] [blame] | 893 | const bool guest_session = profile()->IsGuestSession() || |
| 894 | profile()->IsSystemProfile(); |
| 895 | DCHECK(!profile()->IsSystemProfile()) |
| 896 | << "Ought to never have browser for the system profile."; |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 897 | const bool normal_window = browser_->is_type_tabbed(); |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 898 | UpdateOpenFileState(&command_updater_); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 899 | UpdateCommandsForDevTools(); |
| 900 | command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, CanOpenTaskManager()); |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 901 | command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, !guest_session); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 902 | command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); |
| [email protected] | 674b6567 | 2014-06-02 23:21:56 | [diff] [blame] | 903 | command_updater_.UpdateCommandEnabled(IDC_HELP_MENU, true); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 904 | command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE_VIA_KEYBOARD, true); |
| 905 | command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE_VIA_MENU, true); |
| Bret Sepulveda | 2d01866 | 2017-05-18 21:31:48 | [diff] [blame] | 906 | command_updater_.UpdateCommandEnabled(IDC_SHOW_BETA_FORUM, true); |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 907 | command_updater_.UpdateCommandEnabled(IDC_BOOKMARKS_MENU, !guest_session); |
| [email protected] | 2f1acc21 | 2012-11-13 10:43:51 | [diff] [blame] | 908 | command_updater_.UpdateCommandEnabled(IDC_RECENT_TABS_MENU, |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 909 | !guest_session && |
| [email protected] | 2f1acc21 | 2012-11-13 10:43:51 | [diff] [blame] | 910 | !profile()->IsOffTheRecord()); |
| tsergeant | 341a827 | 2017-04-18 03:54:33 | [diff] [blame] | 911 | command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, |
| 912 | !guest_session); |
| [email protected] | 39d4759 | 2014-01-10 21:42:45 | [diff] [blame] | 913 | #if defined(OS_CHROMEOS) |
| caelyn | 4e4e08a | 2015-02-04 21:27:49 | [diff] [blame] | 914 | command_updater_.UpdateCommandEnabled(IDC_TAKE_SCREENSHOT, true); |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 915 | #else |
| 916 | // Chrome OS uses the system tray menu to handle multi-profiles. |
| anthonyvd | 7dc985da | 2015-03-23 16:53:19 | [diff] [blame] | 917 | if (normal_window && (guest_session || !profile()->IsOffTheRecord())) { |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 918 | command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, true); |
| anthonyvd | 7dc985da | 2015-03-23 16:53:19 | [diff] [blame] | 919 | } |
| [email protected] | 39d4759 | 2014-01-10 21:42:45 | [diff] [blame] | 920 | #endif |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 921 | |
| Mihai Sardarescu | 2ec520568 | 2018-09-26 09:20:05 | [diff] [blame] | 922 | UpdateShowSyncState(true); |
| 923 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 924 | // Navigation commands |
| [email protected] | c9f983d | 2014-02-05 09:00:24 | [diff] [blame] | 925 | command_updater_.UpdateCommandEnabled( |
| 926 | IDC_HOME, |
| benwells | c431c0ae | 2015-01-27 22:04:06 | [diff] [blame] | 927 | normal_window || |
| 928 | (extensions::util::IsNewBookmarkAppsEnabled() && browser_->is_app())); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 929 | |
| Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 930 | const bool is_experimental_hosted_app = |
| 931 | extensions::HostedAppBrowserController::IsForExperimentalHostedAppBrowser( |
| 932 | browser_); |
| 933 | // Hosted app browser commands. |
| 934 | command_updater_.UpdateCommandEnabled(IDC_COPY_URL, |
| 935 | is_experimental_hosted_app); |
| 936 | command_updater_.UpdateCommandEnabled(IDC_OPEN_IN_CHROME, |
| 937 | is_experimental_hosted_app); |
| 938 | command_updater_.UpdateCommandEnabled(IDC_SITE_SETTINGS, |
| 939 | is_experimental_hosted_app); |
| Alan Cutter | 0c313230 | 2018-02-21 05:09:02 | [diff] [blame] | 940 | command_updater_.UpdateCommandEnabled(IDC_HOSTED_APP_MENU_APP_INFO, |
| Christopher Lam | 86b5271 | 2017-12-04 01:58:33 | [diff] [blame] | 941 | is_experimental_hosted_app); |
| Christopher Lam | 0dbac2b | 2017-11-14 07:12:10 | [diff] [blame] | 942 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 943 | // Window management commands |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 944 | command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window); |
| 945 | command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB, |
| 946 | normal_window); |
| 947 | command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_NEXT, normal_window); |
| 948 | command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window); |
| 949 | command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window); |
| 950 | command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window); |
| 951 | command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window); |
| 952 | command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window); |
| 953 | command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window); |
| 954 | command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window); |
| 955 | command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window); |
| 956 | command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window); |
| 957 | command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 958 | |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 959 | // These are always enabled; the menu determines their menu item visibility. |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 960 | command_updater_.UpdateCommandEnabled(IDC_UPGRADE_DIALOG, true); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 961 | |
| [email protected] | 6bd370b | 2014-05-28 14:19:47 | [diff] [blame] | 962 | // Distill current page. |
| 963 | command_updater_.UpdateCommandEnabled( |
| avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 964 | IDC_DISTILL_PAGE, base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 965 | switches::kEnableDomDistiller)); |
| [email protected] | 6bd370b | 2014-05-28 14:19:47 | [diff] [blame] | 966 | |
| Tommy Steimel | c447798 | 2017-11-29 18:07:18 | [diff] [blame] | 967 | command_updater_.UpdateCommandEnabled(IDC_WINDOW_MUTE_SITE, normal_window); |
| ellyjones | 0101ba0 | 2017-05-19 15:50:26 | [diff] [blame] | 968 | command_updater_.UpdateCommandEnabled(IDC_WINDOW_PIN_TAB, normal_window); |
| 969 | |
| [email protected] | 338416c0 | 2014-05-13 16:47:06 | [diff] [blame] | 970 | // Initialize other commands whose state changes based on various conditions. |
| [email protected] | 32dfede | 2013-08-25 15:48:25 | [diff] [blame] | 971 | UpdateCommandsForFullscreenMode(); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 972 | UpdateCommandsForContentRestrictionState(); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 973 | UpdateCommandsForBookmarkEditing(); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 974 | UpdateCommandsForIncognitoAvailability(); |
| 975 | } |
| 976 | |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 977 | // static |
| 978 | void BrowserCommandController::UpdateSharedCommandsForIncognitoAvailability( |
| 979 | CommandUpdater* command_updater, |
| 980 | Profile* profile) { |
| mlerman | e01e6de | 2014-09-29 19:26:47 | [diff] [blame] | 981 | const bool guest_session = profile->IsGuestSession(); |
| 982 | // TODO(mlerman): Make GetAvailability account for profile->IsGuestSession(). |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 983 | IncognitoModePrefs::Availability incognito_availability = |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 984 | IncognitoModePrefs::GetAvailability(profile->GetPrefs()); |
| 985 | command_updater->UpdateCommandEnabled( |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 986 | IDC_NEW_WINDOW, |
| 987 | incognito_availability != IncognitoModePrefs::FORCED); |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 988 | command_updater->UpdateCommandEnabled( |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 989 | IDC_NEW_INCOGNITO_WINDOW, |
| mlerman | e01e6de | 2014-09-29 19:26:47 | [diff] [blame] | 990 | incognito_availability != IncognitoModePrefs::DISABLED && !guest_session); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 991 | |
| [email protected] | 57b2529 | 2014-05-01 16:31:06 | [diff] [blame] | 992 | const bool forced_incognito = |
| 993 | incognito_availability == IncognitoModePrefs::FORCED || |
| 994 | guest_session; // Guest always runs in Incognito mode. |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 995 | command_updater->UpdateCommandEnabled( |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 996 | IDC_SHOW_BOOKMARK_MANAGER, |
| [email protected] | 57b2529 | 2014-05-01 16:31:06 | [diff] [blame] | 997 | browser_defaults::bookmarks_enabled && !forced_incognito); |
| Devlin Cronin | 21dba42 | 2018-05-30 15:45:16 | [diff] [blame] | 998 | extensions::ExtensionService* extension_service = |
| [email protected] | 03d2581 | 2014-06-22 19:41:55 | [diff] [blame] | 999 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
| [email protected] | 57b2529 | 2014-05-01 16:31:06 | [diff] [blame] | 1000 | const bool enable_extensions = |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1001 | extension_service && extension_service->extensions_enabled(); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1002 | |
| [email protected] | 57b2529 | 2014-05-01 16:31:06 | [diff] [blame] | 1003 | // Bookmark manager and settings page/subpages are forced to open in normal |
| 1004 | // mode. For this reason we disable these commands when incognito is forced. |
| 1005 | command_updater->UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS, |
| 1006 | enable_extensions && !forced_incognito); |
| 1007 | |
| 1008 | command_updater->UpdateCommandEnabled(IDC_IMPORT_SETTINGS, !forced_incognito); |
| 1009 | command_updater->UpdateCommandEnabled(IDC_OPTIONS, |
| 1010 | !forced_incognito || guest_session); |
| estade | 8c0780f | 2015-08-21 23:36:41 | [diff] [blame] | 1011 | command_updater->UpdateCommandEnabled(IDC_SHOW_SIGNIN, !forced_incognito); |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | void BrowserCommandController::UpdateCommandsForIncognitoAvailability() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1015 | if (is_locked_fullscreen_) |
| 1016 | return; |
| 1017 | |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 1018 | UpdateSharedCommandsForIncognitoAvailability(&command_updater_, profile()); |
| 1019 | |
| [email protected] | 6a414ff | 2013-02-27 08:22:54 | [diff] [blame] | 1020 | if (!IsShowingMainUI()) { |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 1021 | command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, false); |
| 1022 | command_updater_.UpdateCommandEnabled(IDC_OPTIONS, false); |
| 1023 | } |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | void BrowserCommandController::UpdateCommandsForTabState() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1027 | if (is_locked_fullscreen_) |
| 1028 | return; |
| 1029 | |
| [email protected] | 617ee96 | 2013-01-29 20:49:12 | [diff] [blame] | 1030 | WebContents* current_web_contents = |
| 1031 | browser_->tab_strip_model()->GetActiveWebContents(); |
| [email protected] | 1c5119c | 2012-09-19 00:08:57 | [diff] [blame] | 1032 | if (!current_web_contents) // May be NULL during tab restore. |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1033 | return; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1034 | |
| 1035 | // Navigation commands |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1036 | command_updater_.UpdateCommandEnabled(IDC_BACK, CanGoBack(browser_)); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1037 | command_updater_.UpdateCommandEnabled(IDC_FORWARD, CanGoForward(browser_)); |
| 1038 | command_updater_.UpdateCommandEnabled(IDC_RELOAD, CanReload(browser_)); |
| toyoshim | 7dad4b118 | 2016-04-01 14:28:05 | [diff] [blame] | 1039 | command_updater_.UpdateCommandEnabled(IDC_RELOAD_BYPASSING_CACHE, |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1040 | CanReload(browser_)); |
| [email protected] | 58e2903 | 2012-08-06 20:19:57 | [diff] [blame] | 1041 | command_updater_.UpdateCommandEnabled(IDC_RELOAD_CLEARING_CACHE, |
| 1042 | CanReload(browser_)); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1043 | |
| 1044 | // Window management commands |
| 1045 | command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, |
| 1046 | !browser_->is_app() && CanDuplicateTab(browser_)); |
| Tommy Steimel | c447798 | 2017-11-29 18:07:18 | [diff] [blame] | 1047 | command_updater_.UpdateCommandEnabled(IDC_WINDOW_MUTE_SITE, |
| ellyjones | 0101ba0 | 2017-05-19 15:50:26 | [diff] [blame] | 1048 | !browser_->is_app()); |
| 1049 | command_updater_.UpdateCommandEnabled(IDC_WINDOW_PIN_TAB, |
| 1050 | !browser_->is_app()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1051 | |
| 1052 | // Page-related commands |
| 1053 | window()->SetStarredState( |
| [email protected] | 1c5119c | 2012-09-19 00:08:57 | [diff] [blame] | 1054 | BookmarkTabHelper::FromWebContents(current_web_contents)->is_starred()); |
| [email protected] | 5423c37 | 2012-08-22 05:50:16 | [diff] [blame] | 1055 | window()->ZoomChangedForActiveTab(false); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1056 | command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, |
| 1057 | CanViewSource(browser_)); |
| 1058 | command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, |
| 1059 | CanEmailPageLocation(browser_)); |
| 1060 | if (browser_->is_devtools()) |
| 1061 | command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); |
| 1062 | |
| Alan Cutter | 81ac72668 | 2018-09-25 00:18:36 | [diff] [blame] | 1063 | bool can_create_bookmark_app = CanCreateBookmarkApp(browser_); |
| 1064 | command_updater_.UpdateCommandEnabled(IDC_INSTALL_PWA, |
| 1065 | can_create_bookmark_app); |
| 1066 | command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUT, |
| 1067 | can_create_bookmark_app); |
| Alan Cutter | 403cebb | 2018-05-17 05:22:45 | [diff] [blame] | 1068 | command_updater_.UpdateCommandEnabled(IDC_OPEN_IN_PWA_WINDOW, |
| Alan Cutter | 81ac72668 | 2018-09-25 00:18:36 | [diff] [blame] | 1069 | can_create_bookmark_app); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1070 | |
| [email protected] | 9b7ab88 | 2012-09-10 23:46:36 | [diff] [blame] | 1071 | command_updater_.UpdateCommandEnabled( |
| 1072 | IDC_TOGGLE_REQUEST_TABLET_SITE, |
| 1073 | CanRequestTabletSite(current_web_contents)); |
| 1074 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1075 | UpdateCommandsForContentRestrictionState(); |
| 1076 | UpdateCommandsForBookmarkEditing(); |
| [email protected] | 3cac8723 | 2012-11-20 01:48:27 | [diff] [blame] | 1077 | UpdateCommandsForFind(); |
| apacible | 45cbfc9 | 2015-09-28 22:45:41 | [diff] [blame] | 1078 | UpdateCommandsForMediaRouter(); |
| [email protected] | d93dbd1 | 2014-08-04 23:42:53 | [diff] [blame] | 1079 | // Update the zoom commands when an active tab is selected. |
| 1080 | UpdateCommandsForZoomState(); |
| 1081 | } |
| 1082 | |
| 1083 | void BrowserCommandController::UpdateCommandsForZoomState() { |
| 1084 | WebContents* contents = |
| 1085 | browser_->tab_strip_model()->GetActiveWebContents(); |
| 1086 | if (!contents) |
| 1087 | return; |
| a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 1088 | command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, |
| 1089 | CanZoomIn(contents)); |
| 1090 | command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, |
| ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 1091 | CanResetZoom(contents)); |
| a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 1092 | command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, |
| 1093 | CanZoomOut(contents)); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1094 | } |
| 1095 | |
| 1096 | void BrowserCommandController::UpdateCommandsForContentRestrictionState() { |
| 1097 | int restrictions = GetContentRestrictions(browser_); |
| 1098 | |
| 1099 | command_updater_.UpdateCommandEnabled( |
| [email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 1100 | IDC_COPY, !(restrictions & CONTENT_RESTRICTION_COPY)); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1101 | command_updater_.UpdateCommandEnabled( |
| [email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 1102 | IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1103 | command_updater_.UpdateCommandEnabled( |
| [email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 1104 | IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1105 | UpdateSaveAsState(); |
| 1106 | UpdatePrintingState(); |
| 1107 | } |
| 1108 | |
| 1109 | void BrowserCommandController::UpdateCommandsForDevTools() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1110 | if (is_locked_fullscreen_) |
| 1111 | return; |
| 1112 | |
| Pavol Marko | 56df027 | 2018-07-04 17:55:04 | [diff] [blame] | 1113 | bool dev_tools_enabled = DevToolsWindow::AllowDevToolsFor( |
| 1114 | profile(), browser_->tab_strip_model()->GetActiveWebContents()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1115 | command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, |
| 1116 | dev_tools_enabled); |
| 1117 | command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_CONSOLE, |
| 1118 | dev_tools_enabled); |
| [email protected] | 2056c319 | 2013-10-21 22:40:51 | [diff] [blame] | 1119 | command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_DEVICES, |
| 1120 | dev_tools_enabled); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1121 | command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_INSPECT, |
| 1122 | dev_tools_enabled); |
| [email protected] | d16657c | 2012-09-03 14:25:10 | [diff] [blame] | 1123 | command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_TOGGLE, |
| 1124 | dev_tools_enabled); |
| spqchan | 2c5d541e | 2017-10-25 07:07:11 | [diff] [blame] | 1125 | #if defined(OS_MACOSX) |
| 1126 | command_updater_.UpdateCommandEnabled(IDC_TOGGLE_JAVASCRIPT_APPLE_EVENTS, |
| 1127 | dev_tools_enabled); |
| 1128 | #endif |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1129 | } |
| 1130 | |
| 1131 | void BrowserCommandController::UpdateCommandsForBookmarkEditing() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1132 | if (is_locked_fullscreen_) |
| 1133 | return; |
| 1134 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1135 | command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_PAGE, |
| 1136 | CanBookmarkCurrentPage(browser_)); |
| 1137 | command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_ALL_TABS, |
| 1138 | CanBookmarkAllTabs(browser_)); |
| thestig | 5149d27 | 2014-10-30 07:25:29 | [diff] [blame] | 1139 | #if defined(OS_WIN) |
| 1140 | command_updater_.UpdateCommandEnabled(IDC_PIN_TO_START_SCREEN, true); |
| 1141 | #endif |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | void BrowserCommandController::UpdateCommandsForBookmarkBar() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1145 | if (is_locked_fullscreen_) |
| 1146 | return; |
| 1147 | |
| tfarina | 3bddbe11 | 2014-08-28 05:29:32 | [diff] [blame] | 1148 | command_updater_.UpdateCommandEnabled( |
| 1149 | IDC_SHOW_BOOKMARK_BAR, |
| 1150 | browser_defaults::bookmarks_enabled && !profile()->IsGuestSession() && |
| mlerman | 7831f57d | 2015-05-25 11:40:15 | [diff] [blame] | 1151 | !profile()->IsSystemProfile() && |
| tfarina | 3bddbe11 | 2014-08-28 05:29:32 | [diff] [blame] | 1152 | !profile()->GetPrefs()->IsManagedPreference( |
| 1153 | bookmarks::prefs::kShowBookmarkBar) && |
| 1154 | IsShowingMainUI()); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1155 | } |
| 1156 | |
| [email protected] | 9ec3ea5b | 2012-12-03 18:14:30 | [diff] [blame] | 1157 | void BrowserCommandController::UpdateCommandsForFileSelectionDialogs() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1158 | if (is_locked_fullscreen_) |
| 1159 | return; |
| 1160 | |
| [email protected] | 9ec3ea5b | 2012-12-03 18:14:30 | [diff] [blame] | 1161 | UpdateSaveAsState(); |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 1162 | UpdateOpenFileState(&command_updater_); |
| [email protected] | 9ec3ea5b | 2012-12-03 18:14:30 | [diff] [blame] | 1163 | } |
| 1164 | |
| [email protected] | 32dfede | 2013-08-25 15:48:25 | [diff] [blame] | 1165 | void BrowserCommandController::UpdateCommandsForFullscreenMode() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1166 | if (is_locked_fullscreen_) |
| 1167 | return; |
| 1168 | |
| zijiehe | 3c7af99 | 2017-02-12 20:59:40 | [diff] [blame] | 1169 | const bool is_fullscreen = window() && window()->IsFullscreen(); |
| 1170 | const bool show_main_ui = IsShowingMainUI(); |
| manuk | f1a11639 | 2018-10-25 16:28:24 | [diff] [blame] | 1171 | const bool show_location_bar = IsShowingLocationBar(); |
| 1172 | |
| zijiehe | 3c7af99 | 2017-02-12 20:59:40 | [diff] [blame] | 1173 | const bool main_not_fullscreen = show_main_ui && !is_fullscreen; |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1174 | |
| 1175 | // Navigation commands |
| 1176 | command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui); |
| 1177 | |
| 1178 | // Window management commands |
| 1179 | command_updater_.UpdateCommandEnabled( |
| 1180 | IDC_SHOW_AS_TAB, |
| zijiehe | 3c7af99 | 2017-02-12 20:59:40 | [diff] [blame] | 1181 | !browser_->is_type_tabbed() && !is_fullscreen); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1182 | |
| 1183 | // Focus various bits of UI |
| 1184 | command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); |
| manuk | f1a11639 | 2018-10-25 16:28:24 | [diff] [blame] | 1185 | command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_location_bar); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1186 | command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); |
| 1187 | command_updater_.UpdateCommandEnabled( |
| 1188 | IDC_FOCUS_MENU_BAR, main_not_fullscreen); |
| 1189 | command_updater_.UpdateCommandEnabled( |
| 1190 | IDC_FOCUS_NEXT_PANE, main_not_fullscreen); |
| 1191 | command_updater_.UpdateCommandEnabled( |
| 1192 | IDC_FOCUS_PREVIOUS_PANE, main_not_fullscreen); |
| 1193 | command_updater_.UpdateCommandEnabled( |
| 1194 | IDC_FOCUS_BOOKMARKS, main_not_fullscreen); |
| [email protected] | 822ca8c6 | 2013-04-19 00:49:15 | [diff] [blame] | 1195 | command_updater_.UpdateCommandEnabled( |
| David Tseng | c0b1b64 | 2018-01-24 07:12:27 | [diff] [blame] | 1196 | IDC_FOCUS_INACTIVE_POPUP_FOR_ACCESSIBILITY, main_not_fullscreen); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1197 | |
| 1198 | // Show various bits of UI |
| 1199 | command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); |
| [email protected] | 236ad302 | 2013-09-04 03:27:43 | [diff] [blame] | 1200 | #if defined(GOOGLE_CHROME_BUILD) |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1201 | command_updater_.UpdateCommandEnabled(IDC_FEEDBACK, show_main_ui); |
| [email protected] | 236ad302 | 2013-09-04 03:27:43 | [diff] [blame] | 1202 | #endif |
| Mihai Sardarescu | 2ec520568 | 2018-09-26 09:20:05 | [diff] [blame] | 1203 | UpdateShowSyncState(show_main_ui); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1204 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1205 | command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); |
| 1206 | command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); |
| 1207 | command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); |
| 1208 | command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); |
| Nicolas Ouellet-payeur | 82eb65b | 2018-11-05 16:49:27 | [diff] [blame] | 1209 | command_updater_.UpdateCommandEnabled(IDC_MANAGED_UI_HELP, true); |
| primiano | d3a81ab | 2016-01-25 22:21:15 | [diff] [blame] | 1210 | |
| 1211 | if (base::debug::IsProfilingSupported()) |
| 1212 | command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1213 | |
| [email protected] | aeafc385 | 2014-04-29 16:51:29 | [diff] [blame] | 1214 | #if !defined(OS_MACOSX) |
| zijiehe | 3c7af99 | 2017-02-12 20:59:40 | [diff] [blame] | 1215 | // Disable toggling into fullscreen mode if disallowed by pref. |
| 1216 | const bool fullscreen_enabled = is_fullscreen || |
| 1217 | profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed); |
| 1218 | #else |
| 1219 | const bool fullscreen_enabled = true; |
| [email protected] | 00a1cc5b | 2012-11-07 13:44:51 | [diff] [blame] | 1220 | #endif |
| 1221 | |
| 1222 | command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, fullscreen_enabled); |
| spqchan | b8ffc7d | 2015-11-17 01:17:21 | [diff] [blame] | 1223 | command_updater_.UpdateCommandEnabled(IDC_TOGGLE_FULLSCREEN_TOOLBAR, |
| 1224 | fullscreen_enabled); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1225 | |
| 1226 | UpdateCommandsForBookmarkBar(); |
| zijiehe | db473d55 | 2017-02-24 01:13:41 | [diff] [blame] | 1227 | UpdateCommandsForIncognitoAvailability(); |
| Alan Cutter | 167dfe8 | 2018-04-11 09:06:00 | [diff] [blame] | 1228 | UpdateCommandsForHostedAppAvailability(); |
| 1229 | } |
| 1230 | |
| 1231 | void BrowserCommandController::UpdateCommandsForHostedAppAvailability() { |
| 1232 | bool has_toolbar = |
| 1233 | browser_->is_type_tabbed() || |
| 1234 | extensions::HostedAppBrowserController::IsForExperimentalHostedAppBrowser( |
| 1235 | browser_); |
| 1236 | if (window() && window()->ShouldHideUIForFullscreen()) |
| 1237 | has_toolbar = false; |
| 1238 | command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, has_toolbar); |
| 1239 | command_updater_.UpdateCommandEnabled(IDC_FOCUS_NEXT_PANE, has_toolbar); |
| 1240 | command_updater_.UpdateCommandEnabled(IDC_FOCUS_PREVIOUS_PANE, has_toolbar); |
| 1241 | command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, has_toolbar); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1242 | } |
| 1243 | |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1244 | #if defined(OS_CHROMEOS) |
| 1245 | namespace { |
| 1246 | |
| 1247 | #if DCHECK_IS_ON() |
| 1248 | // Makes sure that all commands that are not whitelisted are disabled. DCHECKs |
| 1249 | // otherwise. Compiled only in debug mode. |
| 1250 | void NonWhitelistedCommandsAreDisabled(CommandUpdaterImpl* command_updater) { |
| Ivan Sandrk | 6ac9c9a | 2018-12-14 14:15:07 | [diff] [blame] | 1251 | constexpr int kWhitelistedIds[] = {IDC_CUT, IDC_COPY, IDC_PASTE}; |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1252 | |
| 1253 | // Go through all the command ids, skip the whitelisted ones. |
| 1254 | for (int id : command_updater->GetAllIds()) { |
| Haeun Kim | 3f612350 | 2018-08-26 18:03:04 | [diff] [blame] | 1255 | if (base::ContainsValue(kWhitelistedIds, id)) { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1256 | continue; |
| 1257 | } |
| 1258 | DCHECK(!command_updater->IsCommandEnabled(id)); |
| 1259 | } |
| 1260 | } |
| 1261 | #endif |
| 1262 | |
| 1263 | } // namespace |
| 1264 | |
| 1265 | void BrowserCommandController::UpdateCommandsForLockedFullscreenMode() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1266 | bool is_locked_fullscreen = ash::IsWindowTrustedPinned(browser_->window()); |
| 1267 | // Sanity check to make sure this function is called only on state change. |
| 1268 | DCHECK_NE(is_locked_fullscreen, is_locked_fullscreen_); |
| 1269 | if (is_locked_fullscreen == is_locked_fullscreen_) |
| 1270 | return; |
| 1271 | is_locked_fullscreen_ = is_locked_fullscreen; |
| 1272 | |
| 1273 | if (is_locked_fullscreen_) { |
| 1274 | command_updater_.DisableAllCommands(); |
| 1275 | // Update the state of whitelisted commands: |
| 1276 | // IDC_CUT/IDC_COPY/IDC_PASTE, |
| 1277 | UpdateCommandsForContentRestrictionState(); |
| Ivan Sandrk | 6ac9c9a | 2018-12-14 14:15:07 | [diff] [blame] | 1278 | // TODO(crbug.com/904637): Re-enable Find and Zoom in locked fullscreen. |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1279 | // All other commands will be disabled (there is an early return in their |
| 1280 | // corresponding UpdateCommandsFor* functions). |
| 1281 | #if DCHECK_IS_ON() |
| 1282 | NonWhitelistedCommandsAreDisabled(&command_updater_); |
| 1283 | #endif |
| 1284 | } else { |
| 1285 | // Do an init call to re-initialize command state after the |
| 1286 | // DisableAllCommands. |
| 1287 | InitCommandState(); |
| 1288 | } |
| 1289 | } |
| 1290 | #endif |
| 1291 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1292 | void BrowserCommandController::UpdatePrintingState() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1293 | if (is_locked_fullscreen_) |
| 1294 | return; |
| 1295 | |
| [email protected] | d53e403 | 2012-06-29 18:58:34 | [diff] [blame] | 1296 | bool print_enabled = CanPrint(browser_); |
| 1297 | command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); |
| Lei Zhang | 48a4a526 | 2018-04-17 20:18:44 | [diff] [blame] | 1298 | #if BUILDFLAG(ENABLE_PRINTING) |
| vitalybuka | f9433e4 | 2014-09-08 10:04:55 | [diff] [blame] | 1299 | command_updater_.UpdateCommandEnabled(IDC_BASIC_PRINT, |
| 1300 | CanBasicPrint(browser_)); |
| Lei Zhang | 48a4a526 | 2018-04-17 20:18:44 | [diff] [blame] | 1301 | #endif |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | void BrowserCommandController::UpdateSaveAsState() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1305 | if (is_locked_fullscreen_) |
| 1306 | return; |
| 1307 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1308 | command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, CanSavePage(browser_)); |
| 1309 | } |
| 1310 | |
| Mihai Sardarescu | 2ec520568 | 2018-09-26 09:20:05 | [diff] [blame] | 1311 | void BrowserCommandController::UpdateShowSyncState(bool show_main_ui) { |
| 1312 | if (is_locked_fullscreen_) |
| 1313 | return; |
| 1314 | |
| Mihai Sardarescu | f87ccc1 | 2018-09-26 10:37:45 | [diff] [blame] | 1315 | command_updater_.UpdateCommandEnabled( |
| Mihai Sardarescu | 290bc88 | 2018-10-12 10:48:14 | [diff] [blame] | 1316 | IDC_SHOW_SIGNIN, show_main_ui && pref_signin_allowed_.GetValue()); |
| Mihai Sardarescu | 2ec520568 | 2018-09-26 09:20:05 | [diff] [blame] | 1317 | } |
| 1318 | |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 1319 | // static |
| 1320 | void BrowserCommandController::UpdateOpenFileState( |
| 1321 | CommandUpdater* command_updater) { |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1322 | bool enabled = true; |
| 1323 | PrefService* local_state = g_browser_process->local_state(); |
| 1324 | if (local_state) |
| 1325 | enabled = local_state->GetBoolean(prefs::kAllowFileSelectionDialogs); |
| 1326 | |
| [email protected] | 0545453 | 2013-01-22 21:09:08 | [diff] [blame] | 1327 | command_updater->UpdateCommandEnabled(IDC_OPEN_FILE, enabled); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1328 | } |
| 1329 | |
| 1330 | void BrowserCommandController::UpdateReloadStopState(bool is_loading, |
| 1331 | bool force) { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1332 | if (is_locked_fullscreen_) |
| 1333 | return; |
| 1334 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1335 | window()->UpdateReloadStopState(is_loading, force); |
| 1336 | command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| 1337 | } |
| 1338 | |
| [email protected] | 2e9369e | 2014-08-15 09:12:53 | [diff] [blame] | 1339 | void BrowserCommandController::UpdateTabRestoreCommandState() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1340 | if (is_locked_fullscreen_) |
| 1341 | return; |
| 1342 | |
| blundell | 74001adc | 2015-09-18 11:04:25 | [diff] [blame] | 1343 | sessions::TabRestoreService* tab_restore_service = |
| [email protected] | 2e9369e | 2014-08-15 09:12:53 | [diff] [blame] | 1344 | TabRestoreServiceFactory::GetForProfile(profile()); |
| 1345 | // The command is enabled if the service hasn't loaded yet to trigger loading. |
| 1346 | // The command is updated once the load completes. |
| 1347 | command_updater_.UpdateCommandEnabled( |
| 1348 | IDC_RESTORE_TAB, |
| 1349 | tab_restore_service && |
| 1350 | (!tab_restore_service->IsLoaded() || |
| 1351 | GetRestoreTabType(browser_) != TabStripModelDelegate::RESTORE_NONE)); |
| 1352 | } |
| 1353 | |
| [email protected] | 3cac8723 | 2012-11-20 01:48:27 | [diff] [blame] | 1354 | void BrowserCommandController::UpdateCommandsForFind() { |
| 1355 | TabStripModel* model = browser_->tab_strip_model(); |
| 1356 | bool enabled = !model->IsTabBlocked(model->active_index()) && |
| 1357 | !browser_->is_devtools(); |
| 1358 | |
| 1359 | command_updater_.UpdateCommandEnabled(IDC_FIND, enabled); |
| 1360 | command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, enabled); |
| 1361 | command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, enabled); |
| 1362 | } |
| 1363 | |
| apacible | 45cbfc9 | 2015-09-28 22:45:41 | [diff] [blame] | 1364 | void BrowserCommandController::UpdateCommandsForMediaRouter() { |
| Ivan Sandrk | 9669d0e | 2017-12-15 23:50:20 | [diff] [blame] | 1365 | if (is_locked_fullscreen_) |
| 1366 | return; |
| 1367 | |
| apacible | 45cbfc9 | 2015-09-28 22:45:41 | [diff] [blame] | 1368 | command_updater_.UpdateCommandEnabled(IDC_ROUTE_MEDIA, |
| 1369 | CanRouteMedia(browser_)); |
| 1370 | } |
| 1371 | |
| [email protected] | 409ea297 | 2012-11-10 19:54:43 | [diff] [blame] | 1372 | void BrowserCommandController::AddInterstitialObservers(WebContents* contents) { |
| [email protected] | 20ca038 | 2013-02-28 19:50:07 | [diff] [blame] | 1373 | interstitial_observers_.push_back(new InterstitialObserver(this, contents)); |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1374 | } |
| 1375 | |
| 1376 | void BrowserCommandController::RemoveInterstitialObservers( |
| [email protected] | e89cfcb | 2012-11-11 14:47:24 | [diff] [blame] | 1377 | WebContents* contents) { |
| [email protected] | 20ca038 | 2013-02-28 19:50:07 | [diff] [blame] | 1378 | for (size_t i = 0; i < interstitial_observers_.size(); i++) { |
| 1379 | if (interstitial_observers_[i]->web_contents() != contents) |
| 1380 | continue; |
| 1381 | |
| 1382 | delete interstitial_observers_[i]; |
| 1383 | interstitial_observers_.erase(interstitial_observers_.begin() + i); |
| 1384 | return; |
| 1385 | } |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1386 | } |
| 1387 | |
| 1388 | BrowserWindow* BrowserCommandController::window() { |
| 1389 | return browser_->window(); |
| 1390 | } |
| 1391 | |
| 1392 | Profile* BrowserCommandController::profile() { |
| 1393 | return browser_->profile(); |
| 1394 | } |
| 1395 | |
| [email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 1396 | } // namespace chrome |