| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 IDC_FORWARD, content::NativeWebKeyboardEvent(ui::KeyEvent( | 44 IDC_FORWARD, content::NativeWebKeyboardEvent(ui::KeyEvent( |
| 45 ui::ET_KEY_PRESSED, ui::VKEY_BROWSER_FORWARD, | 45 ui::ET_KEY_PRESSED, ui::VKEY_BROWSER_FORWARD, |
| 46 ui::DomCode::BROWSER_FORWARD, 0)))); | 46 ui::DomCode::BROWSER_FORWARD, 0)))); |
| 47 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 47 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
| 48 IDC_RELOAD, content::NativeWebKeyboardEvent( | 48 IDC_RELOAD, content::NativeWebKeyboardEvent( |
| 49 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_BROWSER_REFRESH, | 49 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_BROWSER_REFRESH, |
| 50 ui::DomCode::BROWSER_REFRESH, 0)))); | 50 ui::DomCode::BROWSER_REFRESH, 0)))); |
| 51 | 51 |
| 52 // When there are modifier keys pressed, don't reserve. | 52 // When there are modifier keys pressed, don't reserve. |
| 53 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | 53 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( |
| 54 IDC_RELOAD_IGNORING_CACHE, content::NativeWebKeyboardEvent(ui::KeyEvent( | 54 IDC_RELOAD_BYPASSING_CACHE, content::NativeWebKeyboardEvent(ui::KeyEvent( |
| 55 ui::ET_KEY_PRESSED, ui::VKEY_F3, | 55 ui::ET_KEY_PRESSED, ui::VKEY_F3, |
| 56 ui::DomCode::F3, ui::EF_SHIFT_DOWN)))); | 56 ui::DomCode::F3, ui::EF_SHIFT_DOWN)))); |
| 57 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | 57 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( |
| 58 IDC_RELOAD_IGNORING_CACHE, content::NativeWebKeyboardEvent(ui::KeyEvent( | 58 IDC_RELOAD_BYPASSING_CACHE, content::NativeWebKeyboardEvent(ui::KeyEvent( |
| 59 ui::ET_KEY_PRESSED, ui::VKEY_F3, | 59 ui::ET_KEY_PRESSED, ui::VKEY_F3, |
| 60 ui::DomCode::F3, ui::EF_CONTROL_DOWN)))); | 60 ui::DomCode::F3, ui::EF_CONTROL_DOWN)))); |
| 61 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | 61 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( |
| 62 IDC_FULLSCREEN, content::NativeWebKeyboardEvent( | 62 IDC_FULLSCREEN, content::NativeWebKeyboardEvent( |
| 63 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_F4, | 63 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_F4, |
| 64 ui::DomCode::F4, ui::EF_SHIFT_DOWN)))); | 64 ui::DomCode::F4, ui::EF_SHIFT_DOWN)))); |
| 65 | 65 |
| 66 // F4-10 keys are not reserved since they are Ash accelerators. | 66 // F4-10 keys are not reserved since they are Ash accelerators. |
| 67 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | 67 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( |
| 68 -1, content::NativeWebKeyboardEvent(ui::KeyEvent( | 68 -1, content::NativeWebKeyboardEvent(ui::KeyEvent( |
| 69 ui::ET_KEY_PRESSED, ui::VKEY_F4, ui::DomCode::F4, 0)))); | 69 ui::ET_KEY_PRESSED, ui::VKEY_F4, ui::DomCode::F4, 0)))); |
| 70 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | 70 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 422 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 423 chrome::BrowserCommandController command_controller(browser()); | 423 chrome::BrowserCommandController command_controller(browser()); |
| 424 const CommandUpdater* command_updater = command_controller.command_updater(); | 424 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 425 | 425 |
| 426 // Check that the SYNC_SETUP command is updated on preference change. | 426 // Check that the SYNC_SETUP command is updated on preference change. |
| 427 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 427 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 428 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 428 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 429 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 429 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 430 } | 430 } |
| OLD | NEW |