blob: ff9cdefba8a7af31206353198e5505a268ab7105 [file] [log] [blame]
[email protected]5d98294912012-06-27 22:57:401// 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
[email protected]3853a4c2013-02-11 17:15:577#include "base/prefs/pref_service.h"
[email protected]5d98294912012-06-27 22:57:408#include "chrome/app/chrome_command_ids.h"
9#include "chrome/browser/browser_process.h"
[email protected]dcc8fbc2013-07-12 00:54:0910#include "chrome/browser/chrome_notification_types.h"
[email protected]5d98294912012-06-27 22:57:4011#include "chrome/browser/defaults.h"
12#include "chrome/browser/extensions/extension_service.h"
[email protected]2e9d79f2013-08-16 05:45:5613#include "chrome/browser/lifetime/application_lifetime.h"
[email protected]5d98294912012-06-27 22:57:4014#include "chrome/browser/prefs/incognito_mode_prefs.h"
[email protected]32e8a8c2013-09-20 23:10:2015#include "chrome/browser/profiles/avatar_menu.h"
[email protected]5d98294912012-06-27 22:57:4016#include "chrome/browser/profiles/profile.h"
17#include "chrome/browser/profiles/profile_manager.h"
18#include "chrome/browser/sessions/tab_restore_service.h"
19#include "chrome/browser/sessions/tab_restore_service_factory.h"
[email protected]0b32f9b62012-09-17 19:08:0320#include "chrome/browser/shell_integration.h"
[email protected]3d27d272013-07-31 03:15:1621#include "chrome/browser/signin/signin_promo.h"
[email protected]5d98294912012-06-27 22:57:4022#include "chrome/browser/sync/profile_sync_service.h"
23#include "chrome/browser/sync/profile_sync_service_factory.h"
24#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
25#include "chrome/browser/ui/browser.h"
26#include "chrome/browser/ui/browser_commands.h"
[email protected]5d98294912012-06-27 22:57:4027#include "chrome/browser/ui/browser_window.h"
28#include "chrome/browser/ui/chrome_pages.h"
[email protected]5d98294912012-06-27 22:57:4029#include "chrome/browser/ui/tabs/tab_strip_model.h"
[email protected]00a1cc5b2012-11-07 13:44:5130#include "chrome/browser/ui/tabs/tab_strip_model_utils.h"
[email protected]2056c3192013-10-21 22:40:5131#include "chrome/browser/ui/webui/inspect_ui.h"
[email protected]3c71576ce2013-07-23 02:00:0132#include "chrome/common/content_restriction.h"
[email protected]5d98294912012-06-27 22:57:4033#include "chrome/common/pref_names.h"
34#include "chrome/common/profiling.h"
35#include "content/public/browser/native_web_keyboard_event.h"
36#include "content/public/browser/navigation_controller.h"
37#include "content/public/browser/navigation_entry.h"
[email protected]6708dbc2012-11-04 00:17:2238#include "content/public/browser/user_metrics.h"
[email protected]5d98294912012-06-27 22:57:4039#include "content/public/browser/web_contents.h"
[email protected]20ca0382013-02-28 19:50:0740#include "content/public/browser/web_contents_observer.h"
[email protected]5d98294912012-06-27 22:57:4041#include "content/public/common/url_constants.h"
[email protected]7e9acd082013-09-17 23:31:1642#include "ui/events/keycodes/keyboard_codes.h"
[email protected]5d98294912012-06-27 22:57:4043
[email protected]9c4d68332013-01-30 13:34:4144#if defined(OS_MACOSX)
45#include "chrome/browser/ui/browser_commands_mac.h"
46#endif
47
[email protected]5d98294912012-06-27 22:57:4048#if defined(OS_WIN)
49#include "base/win/metro.h"
[email protected]a43ed002013-02-05 19:47:5450#include "base/win/windows_version.h"
[email protected]471e1e82013-08-14 09:53:5251#include "chrome/browser/ui/apps/apps_metro_handler_win.h"
[email protected]5d98294912012-06-27 22:57:4052#endif
53
[email protected]4b0bcef2012-09-27 00:20:5654#if defined(USE_ASH)
[email protected]fa9412762013-09-04 23:31:3355#include "ash/accelerators/accelerator_commands.h"
[email protected]4b0bcef2012-09-27 00:20:5656#include "chrome/browser/ui/ash/ash_util.h"
57#endif
58
[email protected]d12cc5e2013-10-19 18:25:0659#if defined(OS_CHROMEOS)
60#include "ash/session_state_delegate.h"
61#include "ash/shell.h"
62#include "chrome/browser/ui/ash/multi_user_window_manager.h"
63#endif
64
[email protected]5d98294912012-06-27 22:57:4065using content::NavigationEntry;
66using content::NavigationController;
67using content::WebContents;
68
69namespace {
70
[email protected]32dfede2013-08-25 15:48:2571enum WindowState {
72 // Not in fullscreen mode.
73 WINDOW_STATE_NOT_FULLSCREEN,
74
75 // Fullscreen mode, occupying the whole screen.
76 WINDOW_STATE_FULLSCREEN,
77
78 // Fullscreen mode for metro snap, occupying the full height and 20% of
79 // the screen width.
80 WINDOW_STATE_METRO_SNAP,
81};
82
[email protected]5d98294912012-06-27 22:57:4083// Returns |true| if entry has an internal chrome:// URL, |false| otherwise.
84bool HasInternalURL(const NavigationEntry* entry) {
85 if (!entry)
86 return false;
87
88 // Check the |virtual_url()| first. This catches regular chrome:// URLs
89 // including URLs that were rewritten (such as chrome://bookmarks).
90 if (entry->GetVirtualURL().SchemeIs(chrome::kChromeUIScheme))
91 return true;
92
93 // If the |virtual_url()| isn't a chrome:// URL, check if it's actually
94 // view-source: of a chrome:// URL.
[email protected]dbdda5402013-05-30 22:13:4895 if (entry->GetVirtualURL().SchemeIs(content::kViewSourceScheme))
[email protected]5d98294912012-06-27 22:57:4096 return entry->GetURL().SchemeIs(chrome::kChromeUIScheme);
97
98 return false;
99}
100
[email protected]0b32f9b62012-09-17 19:08:03101#if defined(OS_WIN)
102// Windows 8 specific helper class to manage DefaultBrowserWorker. It does the
103// following asynchronous actions in order:
104// 1- Check that chrome is the default browser
105// 2- If we are the default, restart chrome in metro and exit
106// 3- If not the default browser show the 'select default browser' system dialog
107// 4- When dialog dismisses check again who got made the default
108// 5- If we are the default then restart chrome in metro and exit
109// 6- If we are not the default exit.
110//
111// Note: this class deletes itself.
[email protected]24ced7dc02013-04-04 08:32:39112class SwitchToMetroUIHandler
[email protected]0b32f9b62012-09-17 19:08:03113 : public ShellIntegration::DefaultWebClientObserver {
114 public:
[email protected]24ced7dc02013-04-04 08:32:39115 SwitchToMetroUIHandler()
[email protected]d4b2d232013-04-30 21:14:23116 : default_browser_worker_(
117 new ShellIntegration::DefaultBrowserWorker(this)),
[email protected]0b32f9b62012-09-17 19:08:03118 first_check_(true) {
119 default_browser_worker_->StartCheckIsDefault();
120 }
121
[email protected]24ced7dc02013-04-04 08:32:39122 virtual ~SwitchToMetroUIHandler() {
[email protected]0b32f9b62012-09-17 19:08:03123 default_browser_worker_->ObserverDestroyed();
124 }
125
126 private:
127 virtual void SetDefaultWebClientUIState(
128 ShellIntegration::DefaultWebClientUIState state) OVERRIDE {
129 switch (state) {
130 case ShellIntegration::STATE_PROCESSING:
131 return;
132 case ShellIntegration::STATE_UNKNOWN :
133 break;
134 case ShellIntegration::STATE_IS_DEFAULT:
[email protected]0c98ab652013-02-18 00:39:37135 chrome::AttemptRestartWithModeSwitch();
[email protected]0b32f9b62012-09-17 19:08:03136 break;
137 case ShellIntegration::STATE_NOT_DEFAULT:
138 if (first_check_) {
139 default_browser_worker_->StartSetAsDefault();
140 return;
141 }
142 break;
143 default:
144 NOTREACHED();
145 }
146 delete this;
147 }
148
149 virtual void OnSetAsDefaultConcluded(bool success) OVERRIDE {
150 if (!success) {
151 delete this;
152 return;
153 }
154 first_check_ = false;
155 default_browser_worker_->StartCheckIsDefault();
156 }
157
158 virtual bool IsInteractiveSetDefaultPermitted() OVERRIDE {
159 return true;
160 }
161
162 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_;
163 bool first_check_;
164
[email protected]24ced7dc02013-04-04 08:32:39165 DISALLOW_COPY_AND_ASSIGN(SwitchToMetroUIHandler);
[email protected]0b32f9b62012-09-17 19:08:03166};
167#endif // defined(OS_WIN)
168
[email protected]5d98294912012-06-27 22:57:40169} // namespace
170
171namespace chrome {
172
173///////////////////////////////////////////////////////////////////////////////
174// BrowserCommandController, public:
175
[email protected]557c4e22012-12-18 18:30:55176BrowserCommandController::BrowserCommandController(
177 Browser* browser,
178 ProfileManager* profile_manager)
[email protected]5d98294912012-06-27 22:57:40179 : browser_(browser),
[email protected]557c4e22012-12-18 18:30:55180 profile_manager_(profile_manager),
[email protected]d4b2d232013-04-30 21:14:23181 command_updater_(this),
[email protected]5d98294912012-06-27 22:57:40182 block_command_execution_(false),
183 last_blocked_command_id_(-1),
184 last_blocked_command_disposition_(CURRENT_TAB) {
[email protected]557c4e22012-12-18 18:30:55185 if (profile_manager_)
186 profile_manager_->GetProfileInfoCache().AddObserver(this);
[email protected]5d98294912012-06-27 22:57:40187 browser_->tab_strip_model()->AddObserver(this);
188 PrefService* local_state = g_browser_process->local_state();
189 if (local_state) {
190 local_pref_registrar_.Init(local_state);
[email protected]9ec3ea5b2012-12-03 18:14:30191 local_pref_registrar_.Add(
192 prefs::kAllowFileSelectionDialogs,
193 base::Bind(
194 &BrowserCommandController::UpdateCommandsForFileSelectionDialogs,
195 base::Unretained(this)));
[email protected]5d98294912012-06-27 22:57:40196 }
197
198 profile_pref_registrar_.Init(profile()->GetPrefs());
[email protected]9ec3ea5b2012-12-03 18:14:30199 profile_pref_registrar_.Add(
200 prefs::kDevToolsDisabled,
201 base::Bind(&BrowserCommandController::UpdateCommandsForDevTools,
202 base::Unretained(this)));
203 profile_pref_registrar_.Add(
204 prefs::kEditBookmarksEnabled,
205 base::Bind(&BrowserCommandController::UpdateCommandsForBookmarkEditing,
206 base::Unretained(this)));
207 profile_pref_registrar_.Add(
208 prefs::kShowBookmarkBar,
209 base::Bind(&BrowserCommandController::UpdateCommandsForBookmarkBar,
210 base::Unretained(this)));
211 profile_pref_registrar_.Add(
212 prefs::kIncognitoModeAvailability,
213 base::Bind(
214 &BrowserCommandController::UpdateCommandsForIncognitoAvailability,
215 base::Unretained(this)));
216 profile_pref_registrar_.Add(
217 prefs::kPrintingEnabled,
218 base::Bind(&BrowserCommandController::UpdatePrintingState,
219 base::Unretained(this)));
[email protected]32dfede2013-08-25 15:48:25220#if !defined(OS_MACOSX)
221 profile_pref_registrar_.Add(
222 prefs::kFullscreenAllowed,
223 base::Bind(&BrowserCommandController::UpdateCommandsForFullscreenMode,
224 base::Unretained(this)));
225#endif
[email protected]074311a2013-02-28 23:14:09226 pref_signin_allowed_.Init(
227 prefs::kSigninAllowed,
228 profile()->GetOriginalProfile()->GetPrefs(),
229 base::Bind(&BrowserCommandController::OnSigninAllowedPrefChange,
230 base::Unretained(this)));
[email protected]5d98294912012-06-27 22:57:40231
232 InitCommandState();
233
234 TabRestoreService* tab_restore_service =
235 TabRestoreServiceFactory::GetForProfile(profile());
236 if (tab_restore_service) {
237 tab_restore_service->AddObserver(this);
238 TabRestoreServiceChanged(tab_restore_service);
239 }
[email protected]5d98294912012-06-27 22:57:40240}
241
242BrowserCommandController::~BrowserCommandController() {
[email protected]95e39472012-10-05 23:37:36243 // TabRestoreService may have been shutdown by the time we get here. Don't
244 // trigger creating it.
[email protected]5d98294912012-06-27 22:57:40245 TabRestoreService* tab_restore_service =
[email protected]95e39472012-10-05 23:37:36246 TabRestoreServiceFactory::GetForProfileIfExisting(profile());
[email protected]5d98294912012-06-27 22:57:40247 if (tab_restore_service)
248 tab_restore_service->RemoveObserver(this);
249 profile_pref_registrar_.RemoveAll();
250 local_pref_registrar_.RemoveAll();
251 browser_->tab_strip_model()->RemoveObserver(this);
[email protected]557c4e22012-12-18 18:30:55252 if (profile_manager_)
253 profile_manager_->GetProfileInfoCache().RemoveObserver(this);
[email protected]5d98294912012-06-27 22:57:40254}
255
256bool BrowserCommandController::IsReservedCommandOrKey(
257 int command_id,
258 const content::NativeWebKeyboardEvent& event) {
259 // In Apps mode, no keys are reserved.
260 if (browser_->is_app())
261 return false;
262
263#if defined(OS_CHROMEOS)
[email protected]397abd32013-08-21 05:44:19264 // On Chrome OS, the top row of keys are mapped to browser actions like
265 // back/forward or refresh. We don't want web pages to be able to change the
266 // behavior of these keys. Ash handles F4 and up; this leaves us needing to
267 // reserve browser back/forward and refresh here.
[email protected]5d98294912012-06-27 22:57:40268 ui::KeyboardCode key_code =
[email protected]3642e2d2012-10-29 21:31:14269 static_cast<ui::KeyboardCode>(event.windowsKeyCode);
[email protected]397abd32013-08-21 05:44:19270 if ((key_code == ui::VKEY_BROWSER_BACK && command_id == IDC_BACK) ||
271 (key_code == ui::VKEY_BROWSER_FORWARD && command_id == IDC_FORWARD) ||
272 (key_code == ui::VKEY_BROWSER_REFRESH && command_id == IDC_RELOAD)) {
[email protected]5d98294912012-06-27 22:57:40273 return true;
274 }
275#endif
276
277 if (window()->IsFullscreen() && command_id == IDC_FULLSCREEN)
278 return true;
279 return command_id == IDC_CLOSE_TAB ||
280 command_id == IDC_CLOSE_WINDOW ||
281 command_id == IDC_NEW_INCOGNITO_WINDOW ||
282 command_id == IDC_NEW_TAB ||
283 command_id == IDC_NEW_WINDOW ||
284 command_id == IDC_RESTORE_TAB ||
285 command_id == IDC_SELECT_NEXT_TAB ||
286 command_id == IDC_SELECT_PREVIOUS_TAB ||
287 command_id == IDC_TABPOSE ||
[email protected]3642e2d2012-10-29 21:31:14288 command_id == IDC_EXIT;
[email protected]5d98294912012-06-27 22:57:40289}
290
291void BrowserCommandController::SetBlockCommandExecution(bool block) {
292 block_command_execution_ = block;
293 if (block) {
294 last_blocked_command_id_ = -1;
295 last_blocked_command_disposition_ = CURRENT_TAB;
296 }
297}
298
299int BrowserCommandController::GetLastBlockedCommand(
300 WindowOpenDisposition* disposition) {
301 if (disposition)
302 *disposition = last_blocked_command_disposition_;
303 return last_blocked_command_id_;
304}
305
306void BrowserCommandController::TabStateChanged() {
307 UpdateCommandsForTabState();
308}
309
310void BrowserCommandController::ContentRestrictionsChanged() {
311 UpdateCommandsForContentRestrictionState();
312}
313
314void BrowserCommandController::FullscreenStateChanged() {
[email protected]32dfede2013-08-25 15:48:25315 UpdateCommandsForFullscreenMode();
[email protected]5d98294912012-06-27 22:57:40316}
317
318void BrowserCommandController::PrintingStateChanged() {
319 UpdatePrintingState();
320}
321
322void BrowserCommandController::LoadingStateChanged(bool is_loading,
323 bool force) {
324 UpdateReloadStopState(is_loading, force);
325}
326
[email protected]5d98294912012-06-27 22:57:40327////////////////////////////////////////////////////////////////////////////////
[email protected]de0d0f42012-12-06 21:27:11328// BrowserCommandController, CommandUpdaterDelegate implementation:
[email protected]5d98294912012-06-27 22:57:40329
330void BrowserCommandController::ExecuteCommandWithDisposition(
[email protected]de0d0f42012-12-06 21:27:11331 int id,
332 WindowOpenDisposition disposition) {
[email protected]5d98294912012-06-27 22:57:40333 // No commands are enabled if there is not yet any selected tab.
334 // TODO(pkasting): It seems like we should not need this, because either
335 // most/all commands should not have been enabled yet anyway or the ones that
336 // are enabled should be global, or safe themselves against having no selected
337 // tab. However, Ben says he tried removing this before and got lots of
338 // crashes, e.g. from Windows sending WM_COMMANDs at random times during
339 // window construction. This probably could use closer examination someday.
[email protected]59253a652012-11-20 00:17:26340 if (browser_->tab_strip_model()->active_index() == TabStripModel::kNoTab)
[email protected]5d98294912012-06-27 22:57:40341 return;
342
343 DCHECK(command_updater_.IsCommandEnabled(id)) << "Invalid/disabled command "
344 << id;
345
346 // If command execution is blocked then just record the command and return.
347 if (block_command_execution_) {
348 // We actually only allow no more than one blocked command, otherwise some
349 // commands maybe lost.
350 DCHECK_EQ(last_blocked_command_id_, -1);
351 last_blocked_command_id_ = id;
352 last_blocked_command_disposition_ = disposition;
353 return;
354 }
355
356 // The order of commands in this switch statement must match the function
357 // declaration order in browser.h!
358 switch (id) {
359 // Navigation commands
360 case IDC_BACK:
361 GoBack(browser_, disposition);
362 break;
363 case IDC_FORWARD:
364 GoForward(browser_, disposition);
365 break;
366 case IDC_RELOAD:
367 Reload(browser_, disposition);
368 break;
[email protected]58e29032012-08-06 20:19:57369 case IDC_RELOAD_CLEARING_CACHE:
370 ClearCache(browser_);
371 // FALL THROUGH
[email protected]5d98294912012-06-27 22:57:40372 case IDC_RELOAD_IGNORING_CACHE:
373 ReloadIgnoringCache(browser_, disposition);
374 break;
375 case IDC_HOME:
376 Home(browser_, disposition);
377 break;
378 case IDC_OPEN_CURRENT_URL:
379 OpenCurrentURL(browser_);
380 break;
381 case IDC_STOP:
382 Stop(browser_);
383 break;
384
385 // Window management commands
386 case IDC_NEW_WINDOW:
387 NewWindow(browser_);
388 break;
389 case IDC_NEW_INCOGNITO_WINDOW:
390 NewIncognitoWindow(browser_);
391 break;
392 case IDC_CLOSE_WINDOW:
[email protected]438e3b822013-04-13 01:50:27393 content::RecordAction(content::UserMetricsAction("CloseWindowByKey"));
[email protected]04b9e692012-08-24 14:49:09394 CloseWindow(browser_);
[email protected]5d98294912012-06-27 22:57:40395 break;
396 case IDC_NEW_TAB:
397 NewTab(browser_);
398 break;
399 case IDC_CLOSE_TAB:
[email protected]438e3b822013-04-13 01:50:27400 content::RecordAction(content::UserMetricsAction("CloseTabByKey"));
[email protected]04b9e692012-08-24 14:49:09401 CloseTab(browser_);
[email protected]5d98294912012-06-27 22:57:40402 break;
403 case IDC_SELECT_NEXT_TAB:
[email protected]0db969d2013-05-30 18:26:16404 content::RecordAction(content::UserMetricsAction("Accel_SelectNextTab"));
[email protected]5d98294912012-06-27 22:57:40405 SelectNextTab(browser_);
406 break;
407 case IDC_SELECT_PREVIOUS_TAB:
[email protected]0db969d2013-05-30 18:26:16408 content::RecordAction(
409 content::UserMetricsAction("Accel_SelectPreviousTab"));
[email protected]5d98294912012-06-27 22:57:40410 SelectPreviousTab(browser_);
411 break;
412 case IDC_TABPOSE:
413 OpenTabpose(browser_);
414 break;
415 case IDC_MOVE_TAB_NEXT:
416 MoveTabNext(browser_);
417 break;
418 case IDC_MOVE_TAB_PREVIOUS:
419 MoveTabPrevious(browser_);
420 break;
421 case IDC_SELECT_TAB_0:
422 case IDC_SELECT_TAB_1:
423 case IDC_SELECT_TAB_2:
424 case IDC_SELECT_TAB_3:
425 case IDC_SELECT_TAB_4:
426 case IDC_SELECT_TAB_5:
427 case IDC_SELECT_TAB_6:
428 case IDC_SELECT_TAB_7:
429 SelectNumberedTab(browser_, id - IDC_SELECT_TAB_0);
430 break;
431 case IDC_SELECT_LAST_TAB:
432 SelectLastTab(browser_);
433 break;
434 case IDC_DUPLICATE_TAB:
435 DuplicateTab(browser_);
436 break;
437 case IDC_RESTORE_TAB:
438 RestoreTab(browser_);
439 break;
[email protected]5d98294912012-06-27 22:57:40440 case IDC_SHOW_AS_TAB:
441 ConvertPopupToTabbedBrowser(browser_);
442 break;
443 case IDC_FULLSCREEN:
[email protected]9c4d68332013-01-30 13:34:41444#if defined(OS_MACOSX)
[email protected]d74d1e12013-02-11 23:01:49445 chrome::ToggleFullscreenWithChromeOrFallback(browser_);
[email protected]9c4d68332013-01-30 13:34:41446#else
[email protected]3f32b9b2012-07-09 16:59:28447 chrome::ToggleFullscreenMode(browser_);
[email protected]9c4d68332013-01-30 13:34:41448#endif
[email protected]5d98294912012-06-27 22:57:40449 break;
[email protected]770c6d82012-09-06 22:21:32450
[email protected]4b0bcef2012-09-27 00:20:56451#if defined(USE_ASH)
452 case IDC_TOGGLE_ASH_DESKTOP:
453 chrome::ToggleAshDesktop();
454 break;
[email protected]fa9412762013-09-04 23:31:33455 case IDC_MINIMIZE_WINDOW:
456 ash::accelerators::ToggleMinimized();
457 break;
458 // If Ash needs many more commands here we should implement a general
459 // mechanism to pass accelerators back into Ash. http://crbug.com/285308
[email protected]4b0bcef2012-09-27 00:20:56460#endif
461
[email protected]d12cc5e2013-10-19 18:25:06462#if defined(OS_CHROMEOS)
463 case IDC_VISIT_DESKTOP_OF_LRU_USER_2:
464 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: {
465 // When running the multi user mode on Chrome OS, windows can "visit"
466 // another user's desktop.
467 const std::string& user_id =
468 ash::Shell::GetInstance()->session_state_delegate()->GetUserID(
469 IDC_VISIT_DESKTOP_OF_LRU_USER_2 == id ? 1 : 2);
470 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(
471 browser_->window()->GetNativeWindow(),
472 user_id);
473 break;
474 }
475#endif
476
[email protected]5d98294912012-06-27 22:57:40477#if defined(OS_WIN)
[email protected]770c6d82012-09-06 22:21:32478 // Windows 8 specific commands.
[email protected]5d98294912012-06-27 22:57:40479 case IDC_METRO_SNAP_ENABLE:
480 browser_->SetMetroSnapMode(true);
481 break;
482 case IDC_METRO_SNAP_DISABLE:
483 browser_->SetMetroSnapMode(false);
484 break;
[email protected]770c6d82012-09-06 22:21:32485 case IDC_WIN8_DESKTOP_RESTART:
[email protected]0c98ab652013-02-18 00:39:37486 chrome::AttemptRestartWithModeSwitch();
[email protected]6708dbc2012-11-04 00:17:22487 content::RecordAction(content::UserMetricsAction("Win8DesktopRestart"));
[email protected]770c6d82012-09-06 22:21:32488 break;
[email protected]0b32f9b62012-09-17 19:08:03489 case IDC_WIN8_METRO_RESTART:
[email protected]471e1e82013-08-14 09:53:52490 if (!VerifySwitchToMetroForApps(window()->GetNativeWindow()))
[email protected]24ced7dc02013-04-04 08:32:39491 break;
492
493 // SwitchToMetroUIHandler deletes itself.
494 new SwitchToMetroUIHandler;
[email protected]6708dbc2012-11-04 00:17:22495 content::RecordAction(content::UserMetricsAction("Win8MetroRestart"));
[email protected]0b32f9b62012-09-17 19:08:03496 break;
[email protected]5d98294912012-06-27 22:57:40497#endif
[email protected]770c6d82012-09-06 22:21:32498
[email protected]5d98294912012-06-27 22:57:40499#if defined(OS_MACOSX)
500 case IDC_PRESENTATION_MODE:
[email protected]9c4d68332013-01-30 13:34:41501 chrome::ToggleFullscreenMode(browser_);
[email protected]5d98294912012-06-27 22:57:40502 break;
503#endif
504 case IDC_EXIT:
505 Exit();
506 break;
507
508 // Page-related commands
509 case IDC_SAVE_PAGE:
510 SavePage(browser_);
511 break;
512 case IDC_BOOKMARK_PAGE:
513 BookmarkCurrentPage(browser_);
514 break;
[email protected]172b67f2012-11-02 05:32:39515 case IDC_BOOKMARK_PAGE_FROM_STAR:
516 BookmarkCurrentPageFromStar(browser_);
517 break;
[email protected]e6ba5a12012-08-07 02:05:53518 case IDC_PIN_TO_START_SCREEN:
[email protected]ffe6de62012-07-19 00:02:35519 TogglePagePinnedToStartScreen(browser_);
[email protected]5d98294912012-06-27 22:57:40520 break;
521 case IDC_BOOKMARK_ALL_TABS:
522 BookmarkAllTabs(browser_);
523 break;
524 case IDC_VIEW_SOURCE:
525 ViewSelectedSource(browser_);
526 break;
527 case IDC_EMAIL_PAGE_LOCATION:
528 EmailPageLocation(browser_);
529 break;
530 case IDC_PRINT:
531 Print(browser_);
532 break;
533 case IDC_ADVANCED_PRINT:
534 AdvancedPrint(browser_);
535 break;
[email protected]d53e4032012-06-29 18:58:34536 case IDC_PRINT_TO_DESTINATION:
537 PrintToDestination(browser_);
538 break;
[email protected]5d98294912012-06-27 22:57:40539 case IDC_ENCODING_AUTO_DETECT:
540 browser_->ToggleEncodingAutoDetect();
541 break;
542 case IDC_ENCODING_UTF8:
543 case IDC_ENCODING_UTF16LE:
544 case IDC_ENCODING_ISO88591:
545 case IDC_ENCODING_WINDOWS1252:
546 case IDC_ENCODING_GBK:
547 case IDC_ENCODING_GB18030:
548 case IDC_ENCODING_BIG5HKSCS:
549 case IDC_ENCODING_BIG5:
550 case IDC_ENCODING_KOREAN:
551 case IDC_ENCODING_SHIFTJIS:
552 case IDC_ENCODING_ISO2022JP:
553 case IDC_ENCODING_EUCJP:
554 case IDC_ENCODING_THAI:
555 case IDC_ENCODING_ISO885915:
556 case IDC_ENCODING_MACINTOSH:
557 case IDC_ENCODING_ISO88592:
558 case IDC_ENCODING_WINDOWS1250:
559 case IDC_ENCODING_ISO88595:
560 case IDC_ENCODING_WINDOWS1251:
561 case IDC_ENCODING_KOI8R:
562 case IDC_ENCODING_KOI8U:
563 case IDC_ENCODING_ISO88597:
564 case IDC_ENCODING_WINDOWS1253:
565 case IDC_ENCODING_ISO88594:
566 case IDC_ENCODING_ISO885913:
567 case IDC_ENCODING_WINDOWS1257:
568 case IDC_ENCODING_ISO88593:
569 case IDC_ENCODING_ISO885910:
570 case IDC_ENCODING_ISO885914:
571 case IDC_ENCODING_ISO885916:
572 case IDC_ENCODING_WINDOWS1254:
573 case IDC_ENCODING_ISO88596:
574 case IDC_ENCODING_WINDOWS1256:
575 case IDC_ENCODING_ISO88598:
576 case IDC_ENCODING_ISO88598I:
577 case IDC_ENCODING_WINDOWS1255:
578 case IDC_ENCODING_WINDOWS1258:
579 browser_->OverrideEncoding(id);
580 break;
581
582 // Clipboard commands
583 case IDC_CUT:
584 Cut(browser_);
585 break;
586 case IDC_COPY:
587 Copy(browser_);
588 break;
589 case IDC_PASTE:
590 Paste(browser_);
591 break;
592
593 // Find-in-page
594 case IDC_FIND:
595 Find(browser_);
596 break;
597 case IDC_FIND_NEXT:
598 FindNext(browser_);
599 break;
600 case IDC_FIND_PREVIOUS:
601 FindPrevious(browser_);
602 break;
603
604 // Zoom
605 case IDC_ZOOM_PLUS:
606 Zoom(browser_, content::PAGE_ZOOM_IN);
607 break;
608 case IDC_ZOOM_NORMAL:
609 Zoom(browser_, content::PAGE_ZOOM_RESET);
610 break;
611 case IDC_ZOOM_MINUS:
612 Zoom(browser_, content::PAGE_ZOOM_OUT);
613 break;
614
615 // Focus various bits of UI
616 case IDC_FOCUS_TOOLBAR:
617 FocusToolbar(browser_);
618 break;
619 case IDC_FOCUS_LOCATION:
620 FocusLocationBar(browser_);
621 break;
622 case IDC_FOCUS_SEARCH:
623 FocusSearch(browser_);
624 break;
625 case IDC_FOCUS_MENU_BAR:
626 FocusAppMenu(browser_);
627 break;
628 case IDC_FOCUS_BOOKMARKS:
629 FocusBookmarksToolbar(browser_);
630 break;
[email protected]822ca8c62013-04-19 00:49:15631 case IDC_FOCUS_INFOBARS:
632 FocusInfobars(browser_);
633 break;
[email protected]5d98294912012-06-27 22:57:40634 case IDC_FOCUS_NEXT_PANE:
635 FocusNextPane(browser_);
636 break;
637 case IDC_FOCUS_PREVIOUS_PANE:
638 FocusPreviousPane(browser_);
639 break;
640
641 // Show various bits of UI
642 case IDC_OPEN_FILE:
643 browser_->OpenFile();
644 break;
645 case IDC_CREATE_SHORTCUTS:
[email protected]619f86182012-07-03 21:30:18646 CreateApplicationShortcuts(browser_);
[email protected]5d98294912012-06-27 22:57:40647 break;
648 case IDC_DEV_TOOLS:
[email protected]d16657c2012-09-03 14:25:10649 ToggleDevToolsWindow(browser_, DEVTOOLS_TOGGLE_ACTION_SHOW);
[email protected]5d98294912012-06-27 22:57:40650 break;
651 case IDC_DEV_TOOLS_CONSOLE:
652 ToggleDevToolsWindow(browser_, DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
653 break;
[email protected]2056c3192013-10-21 22:40:51654 case IDC_DEV_TOOLS_DEVICES:
655 InspectUI::InspectDevices(browser_);
656 break;
[email protected]5d98294912012-06-27 22:57:40657 case IDC_DEV_TOOLS_INSPECT:
658 ToggleDevToolsWindow(browser_, DEVTOOLS_TOGGLE_ACTION_INSPECT);
659 break;
[email protected]d16657c2012-09-03 14:25:10660 case IDC_DEV_TOOLS_TOGGLE:
661 ToggleDevToolsWindow(browser_, DEVTOOLS_TOGGLE_ACTION_TOGGLE);
662 break;
[email protected]5d98294912012-06-27 22:57:40663 case IDC_TASK_MANAGER:
[email protected]29c262de2013-06-22 15:39:38664 OpenTaskManager(browser_);
[email protected]5d98294912012-06-27 22:57:40665 break;
[email protected]236ad3022013-09-04 03:27:43666#if defined(GOOGLE_CHROME_BUILD)
[email protected]5d98294912012-06-27 22:57:40667 case IDC_FEEDBACK:
668 OpenFeedbackDialog(browser_);
669 break;
[email protected]236ad3022013-09-04 03:27:43670#endif
[email protected]5d98294912012-06-27 22:57:40671 case IDC_SHOW_BOOKMARK_BAR:
672 ToggleBookmarkBar(browser_);
673 break;
674 case IDC_PROFILING_ENABLED:
675 Profiling::Toggle();
676 break;
677
678 case IDC_SHOW_BOOKMARK_MANAGER:
679 ShowBookmarkManager(browser_);
680 break;
681 case IDC_SHOW_APP_MENU:
682 ShowAppMenu(browser_);
683 break;
684 case IDC_SHOW_AVATAR_MENU:
685 ShowAvatarMenu(browser_);
686 break;
687 case IDC_SHOW_HISTORY:
688 ShowHistory(browser_);
689 break;
690 case IDC_SHOW_DOWNLOADS:
691 ShowDownloads(browser_);
692 break;
693 case IDC_MANAGE_EXTENSIONS:
[email protected]bc9833c32013-02-28 04:05:08694 ShowExtensions(browser_, std::string());
[email protected]5d98294912012-06-27 22:57:40695 break;
696 case IDC_OPTIONS:
697 ShowSettings(browser_);
698 break;
699 case IDC_EDIT_SEARCH_ENGINES:
700 ShowSearchEngineSettings(browser_);
701 break;
702 case IDC_VIEW_PASSWORDS:
703 ShowPasswordManager(browser_);
704 break;
705 case IDC_CLEAR_BROWSING_DATA:
706 ShowClearBrowsingDataDialog(browser_);
707 break;
708 case IDC_IMPORT_SETTINGS:
709 ShowImportDialog(browser_);
710 break;
[email protected]9b7ab882012-09-10 23:46:36711 case IDC_TOGGLE_REQUEST_TABLET_SITE:
712 ToggleRequestTabletSite(browser_);
713 break;
[email protected]5d98294912012-06-27 22:57:40714 case IDC_ABOUT:
715 ShowAboutChrome(browser_);
716 break;
717 case IDC_UPGRADE_DIALOG:
718 OpenUpdateChromeDialog(browser_);
719 break;
720 case IDC_VIEW_INCOMPATIBILITIES:
721 ShowConflicts(browser_);
722 break;
723 case IDC_HELP_PAGE_VIA_KEYBOARD:
724 ShowHelp(browser_, HELP_SOURCE_KEYBOARD);
725 break;
726 case IDC_HELP_PAGE_VIA_MENU:
727 ShowHelp(browser_, HELP_SOURCE_MENU);
728 break;
[email protected]08fafe42013-02-03 08:10:49729 case IDC_SHOW_SIGNIN:
[email protected]3d27d272013-07-31 03:15:16730 ShowBrowserSignin(browser_, signin::SOURCE_MENU);
[email protected]5d98294912012-06-27 22:57:40731 break;
732 case IDC_TOGGLE_SPEECH_INPUT:
733 ToggleSpeechInput(browser_);
734 break;
735
736 default:
737 LOG(WARNING) << "Received Unimplemented Command: " << id;
738 break;
739 }
740}
741
742////////////////////////////////////////////////////////////////////////////////
[email protected]557c4e22012-12-18 18:30:55743// BrowserCommandController, ProfileInfoCacheObserver implementation:
744
[email protected]650b2d52013-02-10 03:41:45745void BrowserCommandController::OnProfileAdded(
746 const base::FilePath& profile_path) {
[email protected]557c4e22012-12-18 18:30:55747 UpdateCommandsForMultipleProfiles();
748}
749
750void BrowserCommandController::OnProfileWasRemoved(
[email protected]650b2d52013-02-10 03:41:45751 const base::FilePath& profile_path,
[email protected]557c4e22012-12-18 18:30:55752 const string16& profile_name) {
753 UpdateCommandsForMultipleProfiles();
754}
755
[email protected]557c4e22012-12-18 18:30:55756////////////////////////////////////////////////////////////////////////////////
[email protected]074311a2013-02-28 23:14:09757// BrowserCommandController, SigninPrefObserver implementation:
758
759void BrowserCommandController::OnSigninAllowedPrefChange() {
760 // For unit tests, we don't have a window.
761 if (!window())
762 return;
763 UpdateShowSyncState(IsShowingMainUI());
764}
765
[email protected]5d98294912012-06-27 22:57:40766// BrowserCommandController, TabStripModelObserver implementation:
767
[email protected]409ea2972012-11-10 19:54:43768void BrowserCommandController::TabInsertedAt(WebContents* contents,
[email protected]5d98294912012-06-27 22:57:40769 int index,
770 bool foreground) {
771 AddInterstitialObservers(contents);
772}
773
[email protected]e89cfcb2012-11-11 14:47:24774void BrowserCommandController::TabDetachedAt(WebContents* contents, int index) {
[email protected]5d98294912012-06-27 22:57:40775 RemoveInterstitialObservers(contents);
776}
777
778void BrowserCommandController::TabReplacedAt(TabStripModel* tab_strip_model,
[email protected]b624ddc2012-11-15 18:04:13779 WebContents* old_contents,
780 WebContents* new_contents,
[email protected]5d98294912012-06-27 22:57:40781 int index) {
[email protected]b624ddc2012-11-15 18:04:13782 RemoveInterstitialObservers(old_contents);
783 AddInterstitialObservers(new_contents);
[email protected]5d98294912012-06-27 22:57:40784}
785
[email protected]3cac87232012-11-20 01:48:27786void BrowserCommandController::TabBlockedStateChanged(
787 content::WebContents* contents,
788 int index) {
789 PrintingStateChanged();
790 FullscreenStateChanged();
791 UpdateCommandsForFind();
792}
793
[email protected]5d98294912012-06-27 22:57:40794////////////////////////////////////////////////////////////////////////////////
795// BrowserCommandController, TabRestoreServiceObserver implementation:
796
797void BrowserCommandController::TabRestoreServiceChanged(
798 TabRestoreService* service) {
[email protected]2bf6314b2013-02-20 03:51:14799 command_updater_.UpdateCommandEnabled(
800 IDC_RESTORE_TAB,
801 GetRestoreTabType(browser_) != TabStripModelDelegate::RESTORE_NONE);
[email protected]5d98294912012-06-27 22:57:40802}
803
804void BrowserCommandController::TabRestoreServiceDestroyed(
805 TabRestoreService* service) {
806 service->RemoveObserver(this);
807}
808
809////////////////////////////////////////////////////////////////////////////////
[email protected]5d98294912012-06-27 22:57:40810// BrowserCommandController, private:
811
[email protected]20ca0382013-02-28 19:50:07812class BrowserCommandController::InterstitialObserver
813 : public content::WebContentsObserver {
814 public:
815 InterstitialObserver(BrowserCommandController* controller,
816 content::WebContents* web_contents)
817 : WebContentsObserver(web_contents),
818 controller_(controller) {
819 }
820
821 using content::WebContentsObserver::web_contents;
822
823 virtual void DidAttachInterstitialPage() OVERRIDE {
824 controller_->UpdateCommandsForTabState();
825 }
826
827 virtual void DidDetachInterstitialPage() OVERRIDE {
828 controller_->UpdateCommandsForTabState();
829 }
830
831 private:
832 BrowserCommandController* controller_;
833
834 DISALLOW_COPY_AND_ASSIGN(InterstitialObserver);
835};
836
[email protected]6a414ff2013-02-27 08:22:54837bool BrowserCommandController::IsShowingMainUI() {
838 bool should_hide_ui = window() && window()->ShouldHideUIForFullscreen();
839 return browser_->is_type_tabbed() && !should_hide_ui;
[email protected]5d98294912012-06-27 22:57:40840}
841
842void BrowserCommandController::InitCommandState() {
843 // All browser commands whose state isn't set automagically some other way
844 // (like Back & Forward with initial page load) must have their state
845 // initialized here, otherwise they will be forever disabled.
846
847 // Navigation commands
848 command_updater_.UpdateCommandEnabled(IDC_RELOAD, true);
849 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, true);
[email protected]58e29032012-08-06 20:19:57850 command_updater_.UpdateCommandEnabled(IDC_RELOAD_CLEARING_CACHE, true);
[email protected]5d98294912012-06-27 22:57:40851
852 // Window management commands
853 command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true);
854 command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true);
855 command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true);
856 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, true);
857 command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, false);
[email protected]6ed406c2013-03-12 17:57:11858#if defined(OS_WIN) && defined(USE_ASH)
859 if (browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
860 command_updater_.UpdateCommandEnabled(IDC_EXIT, true);
861#else
[email protected]d28d3782013-02-26 16:31:55862 command_updater_.UpdateCommandEnabled(IDC_EXIT, true);
[email protected]6ed406c2013-03-12 17:57:11863#endif
[email protected]5d98294912012-06-27 22:57:40864 command_updater_.UpdateCommandEnabled(IDC_DEBUG_FRAME_TOGGLE, true);
[email protected]30e22102013-02-14 01:06:08865#if defined(OS_WIN) && defined(USE_ASH) && !defined(NDEBUG)
[email protected]a43ed002013-02-05 19:47:54866 if (base::win::GetVersion() < base::win::VERSION_WIN8 &&
867 chrome::HOST_DESKTOP_TYPE_NATIVE != chrome::HOST_DESKTOP_TYPE_ASH)
[email protected]0f9ccc82012-10-23 22:02:53868 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_ASH_DESKTOP, true);
[email protected]4b0bcef2012-09-27 00:20:56869#endif
[email protected]fa9412762013-09-04 23:31:33870#if defined(USE_ASH)
871 command_updater_.UpdateCommandEnabled(IDC_MINIMIZE_WINDOW, true);
872#endif
[email protected]d12cc5e2013-10-19 18:25:06873#if defined(OS_CHROMEOS)
874 command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_2, true);
875 command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_3, true);
876#endif
[email protected]5d98294912012-06-27 22:57:40877
878 // Page-related commands
879 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true);
880 command_updater_.UpdateCommandEnabled(IDC_ENCODING_AUTO_DETECT, true);
881 command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF8, true);
882 command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF16LE, true);
883 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88591, true);
884 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1252, true);
885 command_updater_.UpdateCommandEnabled(IDC_ENCODING_GBK, true);
886 command_updater_.UpdateCommandEnabled(IDC_ENCODING_GB18030, true);
887 command_updater_.UpdateCommandEnabled(IDC_ENCODING_BIG5HKSCS, true);
888 command_updater_.UpdateCommandEnabled(IDC_ENCODING_BIG5, true);
889 command_updater_.UpdateCommandEnabled(IDC_ENCODING_THAI, true);
890 command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOREAN, true);
891 command_updater_.UpdateCommandEnabled(IDC_ENCODING_SHIFTJIS, true);
892 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO2022JP, true);
893 command_updater_.UpdateCommandEnabled(IDC_ENCODING_EUCJP, true);
894 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885915, true);
895 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MACINTOSH, true);
896 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88592, true);
897 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1250, true);
898 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88595, true);
899 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1251, true);
900 command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOI8R, true);
901 command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOI8U, true);
902 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88597, true);
903 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1253, true);
904 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88594, true);
905 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885913, true);
906 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1257, true);
907 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88593, true);
908 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885910, true);
909 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885914, true);
910 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885916, true);
911 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1254, true);
912 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true);
913 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true);
914 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true);
915 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true);
916 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true);
917 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true);
918
919 // Zoom
920 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true);
921 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true);
922 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, true);
923 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true);
924
925 // Show various bits of UI
[email protected]05454532013-01-22 21:09:08926 UpdateOpenFileState(&command_updater_);
[email protected]5d98294912012-06-27 22:57:40927 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false);
928 UpdateCommandsForDevTools();
929 command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, CanOpenTaskManager());
[email protected]0b083cd2012-09-26 16:21:23930 command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY,
[email protected]10507b332012-12-13 22:37:33931 !profile()->IsGuestSession());
[email protected]5d98294912012-06-27 22:57:40932 command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true);
933 command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE_VIA_KEYBOARD, true);
934 command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE_VIA_MENU, true);
[email protected]fae8b9e2012-10-12 21:40:10935 command_updater_.UpdateCommandEnabled(IDC_BOOKMARKS_MENU,
[email protected]10507b332012-12-13 22:37:33936 !profile()->IsGuestSession());
[email protected]2f1acc212012-11-13 10:43:51937 command_updater_.UpdateCommandEnabled(IDC_RECENT_TABS_MENU,
[email protected]10507b332012-12-13 22:37:33938 !profile()->IsGuestSession() &&
[email protected]2f1acc212012-11-13 10:43:51939 !profile()->IsOffTheRecord());
[email protected]5d98294912012-06-27 22:57:40940
[email protected]074311a2013-02-28 23:14:09941 UpdateShowSyncState(true);
[email protected]5d98294912012-06-27 22:57:40942
943 // Initialize other commands based on the window type.
944 bool normal_window = browser_->is_type_tabbed();
945
946 // Navigation commands
947 command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window);
948
949 // Window management commands
[email protected]5d98294912012-06-27 22:57:40950 command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window);
951 command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB,
952 normal_window);
953 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_NEXT, normal_window);
954 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window);
955 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window);
956 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window);
957 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window);
958 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window);
959 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window);
960 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window);
961 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window);
962 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window);
963 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window);
964#if defined(OS_WIN)
965 const bool metro_mode = base::win::IsMetroProcess();
966 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_ENABLE, metro_mode);
967 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_DISABLE, metro_mode);
[email protected]770c6d82012-09-06 22:21:32968 int restart_mode = metro_mode ?
969 IDC_WIN8_DESKTOP_RESTART : IDC_WIN8_METRO_RESTART;
970 command_updater_.UpdateCommandEnabled(restart_mode, normal_window);
[email protected]5d98294912012-06-27 22:57:40971#endif
[email protected]5d98294912012-06-27 22:57:40972 command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window);
[email protected]5d98294912012-06-27 22:57:40973
[email protected]5d98294912012-06-27 22:57:40974 // Show various bits of UI
975 command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window);
976
977 // The upgrade entry and the view incompatibility entry should always be
978 // enabled. Whether they are visible is a separate matter determined on menu
979 // show.
980 command_updater_.UpdateCommandEnabled(IDC_UPGRADE_DIALOG, true);
981 command_updater_.UpdateCommandEnabled(IDC_VIEW_INCOMPATIBILITIES, true);
982
[email protected]5d98294912012-06-27 22:57:40983 // Toggle speech input
984 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_SPEECH_INPUT, true);
985
986 // Initialize other commands whose state changes based on fullscreen mode.
[email protected]32dfede2013-08-25 15:48:25987 UpdateCommandsForFullscreenMode();
[email protected]5d98294912012-06-27 22:57:40988
989 UpdateCommandsForContentRestrictionState();
990
991 UpdateCommandsForBookmarkEditing();
992
993 UpdateCommandsForIncognitoAvailability();
994}
995
[email protected]05454532013-01-22 21:09:08996// static
997void BrowserCommandController::UpdateSharedCommandsForIncognitoAvailability(
998 CommandUpdater* command_updater,
999 Profile* profile) {
[email protected]5d98294912012-06-27 22:57:401000 IncognitoModePrefs::Availability incognito_availability =
[email protected]05454532013-01-22 21:09:081001 IncognitoModePrefs::GetAvailability(profile->GetPrefs());
1002 command_updater->UpdateCommandEnabled(
[email protected]5d98294912012-06-27 22:57:401003 IDC_NEW_WINDOW,
1004 incognito_availability != IncognitoModePrefs::FORCED);
[email protected]05454532013-01-22 21:09:081005 command_updater->UpdateCommandEnabled(
[email protected]5d98294912012-06-27 22:57:401006 IDC_NEW_INCOGNITO_WINDOW,
1007 incognito_availability != IncognitoModePrefs::DISABLED);
1008
1009 // Bookmark manager and settings page/subpages are forced to open in normal
1010 // mode. For this reason we disable these commands when incognito is forced.
1011 const bool command_enabled =
1012 incognito_availability != IncognitoModePrefs::FORCED;
[email protected]05454532013-01-22 21:09:081013 command_updater->UpdateCommandEnabled(
[email protected]5d98294912012-06-27 22:57:401014 IDC_SHOW_BOOKMARK_MANAGER,
1015 browser_defaults::bookmarks_enabled && command_enabled);
[email protected]05454532013-01-22 21:09:081016 ExtensionService* extension_service = profile->GetExtensionService();
[email protected]5d98294912012-06-27 22:57:401017 bool enable_extensions =
1018 extension_service && extension_service->extensions_enabled();
[email protected]05454532013-01-22 21:09:081019 command_updater->UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS,
[email protected]5d98294912012-06-27 22:57:401020 enable_extensions && command_enabled);
1021
[email protected]05454532013-01-22 21:09:081022 command_updater->UpdateCommandEnabled(IDC_IMPORT_SETTINGS, command_enabled);
1023 command_updater->UpdateCommandEnabled(IDC_OPTIONS, command_enabled);
[email protected]7ca791232013-05-30 12:30:071024 command_updater->UpdateCommandEnabled(IDC_SHOW_SIGNIN, command_enabled);
[email protected]05454532013-01-22 21:09:081025}
1026
1027void BrowserCommandController::UpdateCommandsForIncognitoAvailability() {
1028 UpdateSharedCommandsForIncognitoAvailability(&command_updater_, profile());
1029
[email protected]6a414ff2013-02-27 08:22:541030 if (!IsShowingMainUI()) {
[email protected]05454532013-01-22 21:09:081031 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, false);
1032 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, false);
1033 }
[email protected]5d98294912012-06-27 22:57:401034}
1035
1036void BrowserCommandController::UpdateCommandsForTabState() {
[email protected]617ee962013-01-29 20:49:121037 WebContents* current_web_contents =
1038 browser_->tab_strip_model()->GetActiveWebContents();
[email protected]1c5119c2012-09-19 00:08:571039 if (!current_web_contents) // May be NULL during tab restore.
[email protected]5d98294912012-06-27 22:57:401040 return;
[email protected]5d98294912012-06-27 22:57:401041
1042 // Navigation commands
1043 command_updater_.UpdateCommandEnabled(IDC_BACK, CanGoBack(browser_));
1044 command_updater_.UpdateCommandEnabled(IDC_FORWARD, CanGoForward(browser_));
1045 command_updater_.UpdateCommandEnabled(IDC_RELOAD, CanReload(browser_));
1046 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE,
1047 CanReload(browser_));
[email protected]58e29032012-08-06 20:19:571048 command_updater_.UpdateCommandEnabled(IDC_RELOAD_CLEARING_CACHE,
1049 CanReload(browser_));
[email protected]5d98294912012-06-27 22:57:401050
1051 // Window management commands
1052 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB,
1053 !browser_->is_app() && CanDuplicateTab(browser_));
1054
1055 // Page-related commands
1056 window()->SetStarredState(
[email protected]1c5119c2012-09-19 00:08:571057 BookmarkTabHelper::FromWebContents(current_web_contents)->is_starred());
[email protected]5423c372012-08-22 05:50:161058 window()->ZoomChangedForActiveTab(false);
[email protected]5d98294912012-06-27 22:57:401059 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE,
1060 CanViewSource(browser_));
1061 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION,
1062 CanEmailPageLocation(browser_));
1063 if (browser_->is_devtools())
1064 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false);
1065
1066 // Changing the encoding is not possible on Chrome-internal webpages.
1067 NavigationController& nc = current_web_contents->GetController();
1068 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) ||
1069 current_web_contents->ShowingInterstitialPage();
1070 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU,
1071 !is_chrome_internal && current_web_contents->IsSavable());
1072
1073 // Show various bits of UI
1074 // TODO(pinkerton): Disable app-mode in the model until we implement it
1075 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148
1076#if !defined(OS_MACOSX)
1077 command_updater_.UpdateCommandEnabled(
1078 IDC_CREATE_SHORTCUTS,
1079 CanCreateApplicationShortcuts(browser_));
1080#endif
1081
[email protected]9b7ab882012-09-10 23:46:361082 command_updater_.UpdateCommandEnabled(
1083 IDC_TOGGLE_REQUEST_TABLET_SITE,
1084 CanRequestTabletSite(current_web_contents));
1085
[email protected]5d98294912012-06-27 22:57:401086 UpdateCommandsForContentRestrictionState();
1087 UpdateCommandsForBookmarkEditing();
[email protected]3cac87232012-11-20 01:48:271088 UpdateCommandsForFind();
[email protected]5d98294912012-06-27 22:57:401089}
1090
1091void BrowserCommandController::UpdateCommandsForContentRestrictionState() {
1092 int restrictions = GetContentRestrictions(browser_);
1093
1094 command_updater_.UpdateCommandEnabled(
[email protected]3c71576ce2013-07-23 02:00:011095 IDC_COPY, !(restrictions & CONTENT_RESTRICTION_COPY));
[email protected]5d98294912012-06-27 22:57:401096 command_updater_.UpdateCommandEnabled(
[email protected]3c71576ce2013-07-23 02:00:011097 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT));
[email protected]5d98294912012-06-27 22:57:401098 command_updater_.UpdateCommandEnabled(
[email protected]3c71576ce2013-07-23 02:00:011099 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE));
[email protected]5d98294912012-06-27 22:57:401100 UpdateSaveAsState();
1101 UpdatePrintingState();
1102}
1103
1104void BrowserCommandController::UpdateCommandsForDevTools() {
1105 bool dev_tools_enabled =
1106 !profile()->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled);
1107 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS,
1108 dev_tools_enabled);
1109 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_CONSOLE,
1110 dev_tools_enabled);
[email protected]2056c3192013-10-21 22:40:511111 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_DEVICES,
1112 dev_tools_enabled);
[email protected]5d98294912012-06-27 22:57:401113 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_INSPECT,
1114 dev_tools_enabled);
[email protected]d16657c2012-09-03 14:25:101115 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_TOGGLE,
1116 dev_tools_enabled);
[email protected]5d98294912012-06-27 22:57:401117}
1118
1119void BrowserCommandController::UpdateCommandsForBookmarkEditing() {
1120 command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_PAGE,
1121 CanBookmarkCurrentPage(browser_));
1122 command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_ALL_TABS,
1123 CanBookmarkAllTabs(browser_));
[email protected]e6ba5a12012-08-07 02:05:531124 command_updater_.UpdateCommandEnabled(IDC_PIN_TO_START_SCREEN,
[email protected]5d98294912012-06-27 22:57:401125 true);
1126}
1127
1128void BrowserCommandController::UpdateCommandsForBookmarkBar() {
[email protected]5d98294912012-06-27 22:57:401129 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR,
1130 browser_defaults::bookmarks_enabled &&
1131 !profile()->GetPrefs()->IsManagedPreference(prefs::kShowBookmarkBar) &&
[email protected]6a414ff2013-02-27 08:22:541132 IsShowingMainUI());
[email protected]5d98294912012-06-27 22:57:401133}
1134
[email protected]9ec3ea5b2012-12-03 18:14:301135void BrowserCommandController::UpdateCommandsForFileSelectionDialogs() {
1136 UpdateSaveAsState();
[email protected]05454532013-01-22 21:09:081137 UpdateOpenFileState(&command_updater_);
[email protected]9ec3ea5b2012-12-03 18:14:301138}
1139
[email protected]32dfede2013-08-25 15:48:251140void BrowserCommandController::UpdateCommandsForFullscreenMode() {
1141 WindowState window_state = WINDOW_STATE_NOT_FULLSCREEN;
1142 if (window() && window()->IsFullscreen()) {
1143 window_state = WINDOW_STATE_FULLSCREEN;
1144#if defined(OS_WIN)
1145 if (window()->IsInMetroSnapMode())
1146 window_state = WINDOW_STATE_METRO_SNAP;
1147#endif
1148 }
[email protected]6a414ff2013-02-27 08:22:541149 bool show_main_ui = IsShowingMainUI();
[email protected]32dfede2013-08-25 15:48:251150 bool main_not_fullscreen =
1151 show_main_ui && window_state == WINDOW_STATE_NOT_FULLSCREEN;
[email protected]5d98294912012-06-27 22:57:401152
1153 // Navigation commands
1154 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui);
1155
1156 // Window management commands
1157 command_updater_.UpdateCommandEnabled(
1158 IDC_SHOW_AS_TAB,
[email protected]32dfede2013-08-25 15:48:251159 !browser_->is_type_tabbed() &&
1160 window_state == WINDOW_STATE_NOT_FULLSCREEN);
[email protected]5d98294912012-06-27 22:57:401161
1162 // Focus various bits of UI
1163 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui);
1164 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui);
1165 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui);
1166 command_updater_.UpdateCommandEnabled(
1167 IDC_FOCUS_MENU_BAR, main_not_fullscreen);
1168 command_updater_.UpdateCommandEnabled(
1169 IDC_FOCUS_NEXT_PANE, main_not_fullscreen);
1170 command_updater_.UpdateCommandEnabled(
1171 IDC_FOCUS_PREVIOUS_PANE, main_not_fullscreen);
1172 command_updater_.UpdateCommandEnabled(
1173 IDC_FOCUS_BOOKMARKS, main_not_fullscreen);
[email protected]822ca8c62013-04-19 00:49:151174 command_updater_.UpdateCommandEnabled(
1175 IDC_FOCUS_INFOBARS, main_not_fullscreen);
[email protected]5d98294912012-06-27 22:57:401176
1177 // Show various bits of UI
1178 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui);
[email protected]236ad3022013-09-04 03:27:431179#if defined(GOOGLE_CHROME_BUILD)
[email protected]5d98294912012-06-27 22:57:401180 command_updater_.UpdateCommandEnabled(IDC_FEEDBACK, show_main_ui);
[email protected]236ad3022013-09-04 03:27:431181#endif
[email protected]074311a2013-02-28 23:14:091182 UpdateShowSyncState(show_main_ui);
[email protected]5d98294912012-06-27 22:57:401183
1184 // Settings page/subpages are forced to open in normal mode. We disable these
1185 // commands when incognito is forced.
1186 const bool options_enabled = show_main_ui &&
1187 IncognitoModePrefs::GetAvailability(
1188 profile()->GetPrefs()) != IncognitoModePrefs::FORCED;
1189 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled);
1190 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled);
1191
1192 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui);
1193 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui);
1194 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui);
1195 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui);
1196#if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC)
1197 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui);
1198#endif
1199
[email protected]7efaed362013-04-04 09:33:321200 // Disable explicit fullscreen toggling when in metro snap mode.
[email protected]32dfede2013-08-25 15:48:251201 bool fullscreen_enabled = window_state != WINDOW_STATE_METRO_SNAP;
[email protected]00a1cc5b2012-11-07 13:44:511202#if defined(OS_MACOSX)
1203 // The Mac implementation doesn't support switching to fullscreen while
1204 // a tab modal dialog is displayed.
[email protected]3cac87232012-11-20 01:48:271205 int tab_index = chrome::IndexOfFirstBlockedTab(browser_->tab_strip_model());
1206 bool has_blocked_tab = tab_index != browser_->tab_strip_model()->count();
[email protected]00a1cc5b2012-11-07 13:44:511207 fullscreen_enabled &= !has_blocked_tab;
[email protected]32dfede2013-08-25 15:48:251208#else
1209 if (window_state == WINDOW_STATE_NOT_FULLSCREEN &&
1210 !profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed)) {
1211 // Disable toggling into fullscreen mode if disallowed by pref.
1212 fullscreen_enabled = false;
1213 }
[email protected]00a1cc5b2012-11-07 13:44:511214#endif
1215
1216 command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, fullscreen_enabled);
1217 command_updater_.UpdateCommandEnabled(IDC_PRESENTATION_MODE,
1218 fullscreen_enabled);
[email protected]5d98294912012-06-27 22:57:401219
1220 UpdateCommandsForBookmarkBar();
1221 UpdateCommandsForMultipleProfiles();
1222}
1223
1224void BrowserCommandController::UpdateCommandsForMultipleProfiles() {
[email protected]6a414ff2013-02-27 08:22:541225 bool enable = IsShowingMainUI() &&
[email protected]5d98294912012-06-27 22:57:401226 !profile()->IsOffTheRecord() &&
[email protected]a0cdf262013-02-01 01:12:121227 profile_manager_ &&
[email protected]32e8a8c2013-09-20 23:10:201228 AvatarMenu::ShouldShowAvatarMenu();
[email protected]a0cdf262013-02-01 01:12:121229 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU,
1230 enable);
[email protected]5d98294912012-06-27 22:57:401231}
1232
1233void BrowserCommandController::UpdatePrintingState() {
[email protected]d53e4032012-06-29 18:58:341234 bool print_enabled = CanPrint(browser_);
1235 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled);
[email protected]5d98294912012-06-27 22:57:401236 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT,
1237 CanAdvancedPrint(browser_));
[email protected]d53e4032012-06-29 18:58:341238 command_updater_.UpdateCommandEnabled(IDC_PRINT_TO_DESTINATION,
1239 print_enabled);
1240#if defined(OS_WIN)
1241 HMODULE metro_module = base::win::GetMetroModule();
1242 if (metro_module != NULL) {
1243 typedef void (*MetroEnablePrinting)(BOOL);
1244 MetroEnablePrinting metro_enable_printing =
1245 reinterpret_cast<MetroEnablePrinting>(
1246 ::GetProcAddress(metro_module, "MetroEnablePrinting"));
1247 if (metro_enable_printing)
1248 metro_enable_printing(print_enabled);
1249 }
1250#endif
[email protected]5d98294912012-06-27 22:57:401251}
1252
1253void BrowserCommandController::UpdateSaveAsState() {
1254 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, CanSavePage(browser_));
1255}
1256
[email protected]074311a2013-02-28 23:14:091257void BrowserCommandController::UpdateShowSyncState(bool show_main_ui) {
1258 command_updater_.UpdateCommandEnabled(
1259 IDC_SHOW_SYNC_SETUP, show_main_ui && pref_signin_allowed_.GetValue());
1260}
1261
[email protected]05454532013-01-22 21:09:081262// static
1263void BrowserCommandController::UpdateOpenFileState(
1264 CommandUpdater* command_updater) {
[email protected]5d98294912012-06-27 22:57:401265 bool enabled = true;
1266 PrefService* local_state = g_browser_process->local_state();
1267 if (local_state)
1268 enabled = local_state->GetBoolean(prefs::kAllowFileSelectionDialogs);
1269
[email protected]05454532013-01-22 21:09:081270 command_updater->UpdateCommandEnabled(IDC_OPEN_FILE, enabled);
[email protected]5d98294912012-06-27 22:57:401271}
1272
1273void BrowserCommandController::UpdateReloadStopState(bool is_loading,
1274 bool force) {
1275 window()->UpdateReloadStopState(is_loading, force);
1276 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading);
1277}
1278
[email protected]3cac87232012-11-20 01:48:271279void BrowserCommandController::UpdateCommandsForFind() {
1280 TabStripModel* model = browser_->tab_strip_model();
1281 bool enabled = !model->IsTabBlocked(model->active_index()) &&
1282 !browser_->is_devtools();
1283
1284 command_updater_.UpdateCommandEnabled(IDC_FIND, enabled);
1285 command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, enabled);
1286 command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, enabled);
1287}
1288
[email protected]409ea2972012-11-10 19:54:431289void BrowserCommandController::AddInterstitialObservers(WebContents* contents) {
[email protected]20ca0382013-02-28 19:50:071290 interstitial_observers_.push_back(new InterstitialObserver(this, contents));
[email protected]5d98294912012-06-27 22:57:401291}
1292
1293void BrowserCommandController::RemoveInterstitialObservers(
[email protected]e89cfcb2012-11-11 14:47:241294 WebContents* contents) {
[email protected]20ca0382013-02-28 19:50:071295 for (size_t i = 0; i < interstitial_observers_.size(); i++) {
1296 if (interstitial_observers_[i]->web_contents() != contents)
1297 continue;
1298
1299 delete interstitial_observers_[i];
1300 interstitial_observers_.erase(interstitial_observers_.begin() + i);
1301 return;
1302 }
[email protected]5d98294912012-06-27 22:57:401303}
1304
1305BrowserWindow* BrowserCommandController::window() {
1306 return browser_->window();
1307}
1308
1309Profile* BrowserCommandController::profile() {
1310 return browser_->profile();
1311}
1312
[email protected]5d98294912012-06-27 22:57:401313} // namespace chrome