| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/browser_command_controller.h" | 5 #include "chrome/browser/ui/browser_command_controller.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/command_updater.h" | 10 #include "chrome/browser/command_updater.h" |
| 11 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" |
| 11 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 12 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/browser/profiles/profiles_state.h" | 14 #include "chrome/browser/profiles/profiles_state.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 16 #include "chrome/browser/ui/browser_window_state.h" | 17 #include "chrome/browser/ui/browser_window_state.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/test/base/browser_with_test_window_test.h" | 20 #include "chrome/test/base/browser_with_test_window_test.h" |
| 20 #include "chrome/test/base/test_browser_window.h" | 21 #include "chrome/test/base/test_browser_window.h" |
| 21 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 23 #include "chrome/test/base/testing_profile_manager.h" | 24 #include "chrome/test/base/testing_profile_manager.h" |
| 25 #include "components/nacl/browser/nacl_browser.h" |
| 24 #include "components/signin/core/common/profile_management_switches.h" | 26 #include "components/signin/core/common/profile_management_switches.h" |
| 25 #include "content/public/browser/native_web_keyboard_event.h" | 27 #include "content/public/browser/native_web_keyboard_event.h" |
| 26 #include "ui/events/keycodes/keyboard_codes.h" | 28 #include "ui/events/keycodes/keyboard_codes.h" |
| 27 | 29 |
| 28 typedef BrowserWithTestWindowTest BrowserCommandControllerTest; | 30 typedef BrowserWithTestWindowTest BrowserCommandControllerTest; |
| 29 | 31 |
| 30 TEST_F(BrowserCommandControllerTest, IsReservedCommandOrKey) { | 32 TEST_F(BrowserCommandControllerTest, IsReservedCommandOrKey) { |
| 31 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
| 32 // F1-3 keys are reserved Chrome accelerators on Chrome OS. | 34 // F1-3 keys are reserved Chrome accelerators on Chrome OS. |
| 33 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 35 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 TestingProfile::Builder().Build(); | 255 TestingProfile::Builder().Build(); |
| 254 TestingProfile::Builder guest_builder; | 256 TestingProfile::Builder guest_builder; |
| 255 guest_builder.SetGuestSession(); | 257 guest_builder.SetGuestSession(); |
| 256 guest_builder.SetPath(ProfileManager::GetGuestProfilePath()); | 258 guest_builder.SetPath(ProfileManager::GetGuestProfilePath()); |
| 257 // Browsers in Guest mode must be off the record profiles. | 259 // Browsers in Guest mode must be off the record profiles. |
| 258 TestingProfile* guest_profile = | 260 TestingProfile* guest_profile = |
| 259 guest_builder.BuildIncognito(original_profile.get()); | 261 guest_builder.BuildIncognito(original_profile.get()); |
| 260 | 262 |
| 261 ASSERT_TRUE(guest_profile->IsGuestSession()); | 263 ASSERT_TRUE(guest_profile->IsGuestSession()); |
| 262 | 264 |
| 265 #if !defined(DISABLE_NACL) |
| 266 // BrowserDataRemover needs a NaCl delegate. |
| 267 nacl::NaClBrowser::SetDelegate( |
| 268 new NaClBrowserDelegateImpl(testing_profile_manager.profile_manager())); |
| 269 #endif |
| 270 |
| 263 // Create a new browser based on the guest profile. | 271 // Create a new browser based on the guest profile. |
| 264 Browser::CreateParams profile_params(guest_profile, | 272 Browser::CreateParams profile_params(guest_profile, |
| 265 chrome::GetActiveDesktop()); | 273 chrome::GetActiveDesktop()); |
| 266 scoped_ptr<Browser> guest_browser( | 274 scoped_ptr<Browser> guest_browser( |
| 267 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); | 275 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); |
| 268 chrome::BrowserCommandController command_controller(guest_browser.get()); | 276 chrome::BrowserCommandController command_controller(guest_browser.get()); |
| 269 const CommandUpdater* command_updater = command_controller.command_updater(); | 277 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 270 #if defined(OS_CHROMEOS) | 278 #if defined(OS_CHROMEOS) |
| 271 // Chrome OS uses system tray menu to handle multi-profiles. | 279 // Chrome OS uses system tray menu to handle multi-profiles. |
| 272 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 280 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 463 |
| 456 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 464 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 457 chrome::BrowserCommandController command_controller(browser()); | 465 chrome::BrowserCommandController command_controller(browser()); |
| 458 const CommandUpdater* command_updater = command_controller.command_updater(); | 466 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 459 | 467 |
| 460 // Check that the SYNC_SETUP command is updated on preference change. | 468 // Check that the SYNC_SETUP command is updated on preference change. |
| 461 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 469 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 462 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 470 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 463 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 471 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 464 } | 472 } |
| OLD | NEW |