diff options
author | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-23 17:17:02 +0000 |
---|---|---|
committer | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-23 17:17:02 +0000 |
commit | 0c8d0e7fa9e3dd94303e24a35d6fd496379b02d4 (patch) | |
tree | 1b2731acd94a288c844da9b00f2c15bf494627d3 /ash | |
parent | 100746b62e075acdd9bfb1a7433c56fc2c2b105d (diff) | |
download | chromium_src-0c8d0e7fa9e3dd94303e24a35d6fd496379b02d4.zip chromium_src-0c8d0e7fa9e3dd94303e24a35d6fd496379b02d4.tar.gz chromium_src-0c8d0e7fa9e3dd94303e24a35d6fd496379b02d4.tar.bz2 |
Allow Control+Shift+Q on lock screen.
Usually, when the screen is locked and the status area at the bottom right corner of the screen is not focused, Control+Shift+Q is handled by chrome/browser/chromeos/login/webui_login_view.cc. But when the status area is focused, Control+Shift+Q is handled by Ash, accelerator_controller.cc.
BUG=120953
TEST=aura_shell_unittests + manual: focus the area and press C+S+Q on both login and lock screens
Review URL: https://chromiumcodereview.appspot.com/10388230
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138509 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/accelerators/accelerator_controller.cc | 24 | ||||
-rw-r--r-- | ash/accelerators/accelerator_controller.h | 4 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.cc | 13 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.h | 13 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table_unittest.cc | 12 |
5 files changed, 48 insertions, 18 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 2762f94..ee67958 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -189,8 +189,14 @@ AcceleratorController::~AcceleratorController() { } void AcceleratorController::Init() { - for (size_t i = 0; i < kActionsAllowedAtLoginScreenLength; ++i) { - actions_allowed_at_login_screen_.insert(kActionsAllowedAtLoginScreen[i]); + for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) { + actions_allowed_at_login_screen_.insert( + kActionsAllowedAtLoginOrLockScreen[i]); + actions_allowed_at_lock_screen_.insert( + kActionsAllowedAtLoginOrLockScreen[i]); + } + for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) { + actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]); } for (size_t i = 0; i < kAcceleratorDataLength; ++i) { @@ -265,18 +271,22 @@ bool AcceleratorController::AcceleratorPressed( AcceleratorAction action = static_cast<AcceleratorAction>(it->second); ash::Shell* shell = ash::Shell::GetInstance(); + bool at_login_screen = false; #if defined(OS_CHROMEOS) - bool at_login_screen = shell->IsScreenLocked() || - (shell->delegate() && !shell->delegate()->IsUserLoggedIn()); -#else - bool at_login_screen = shell->IsScreenLocked(); -#endif // OS_CHROMEOS + at_login_screen = (shell->delegate() && !shell->delegate()->IsUserLoggedIn()); +#endif + bool at_lock_screen = shell->IsScreenLocked(); if (at_login_screen && actions_allowed_at_login_screen_.find(action) == actions_allowed_at_login_screen_.end()) { return false; } + if (at_lock_screen && + actions_allowed_at_lock_screen_.find(action) == + actions_allowed_at_lock_screen_.end()) { + return false; + } switch (action) { case CYCLE_BACKWARD_MRU: diff --git a/ash/accelerators/accelerator_controller.h b/ash/accelerators/accelerator_controller.h index df47427..9660107 100644 --- a/ash/accelerators/accelerator_controller.h +++ b/ash/accelerators/accelerator_controller.h @@ -103,8 +103,10 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { // the implementation. std::map<ui::Accelerator, int> accelerators_; - // Actions allowed when the user is not signed in or screen is locked + // Actions allowed when the user is not signed in. std::set<int> actions_allowed_at_login_screen_; + // Actions allowed when the screen is locked. + std::set<int> actions_allowed_at_lock_screen_; DISALLOW_COPY_AND_ASSIGN(AcceleratorController); }; diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc index 225ad90..0800a90 100644 --- a/ash/accelerators/accelerator_table.cc +++ b/ash/accelerators/accelerator_table.cc @@ -128,7 +128,7 @@ const AcceleratorData kAcceleratorData[] = { const size_t kAcceleratorDataLength = arraysize(kAcceleratorData); -const AcceleratorAction kActionsAllowedAtLoginScreen[] = { +const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = { BRIGHTNESS_DOWN, BRIGHTNESS_UP, NEXT_IME, @@ -149,7 +149,14 @@ const AcceleratorAction kActionsAllowedAtLoginScreen[] = { #endif }; -const size_t kActionsAllowedAtLoginScreenLength = - arraysize(kActionsAllowedAtLoginScreen); +const size_t kActionsAllowedAtLoginOrLockScreenLength = + arraysize(kActionsAllowedAtLoginOrLockScreen); + +const AcceleratorAction kActionsAllowedAtLockScreen[] = { + EXIT, +}; + +const size_t kActionsAllowedAtLockScreenLength = + arraysize(kActionsAllowedAtLockScreen); } // namespace ash diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h index ce411a7..922cef4 100644 --- a/ash/accelerators/accelerator_table.h +++ b/ash/accelerators/accelerator_table.h @@ -85,10 +85,17 @@ ASH_EXPORT extern const AcceleratorData kAcceleratorData[]; ASH_EXPORT extern const size_t kAcceleratorDataLength; // Actions allowed while user is not signed in or screen is locked. -ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLoginScreen[]; +ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[]; -// The number of elements in kActionsAllowedAtLoginScreen. -ASH_EXPORT extern const size_t kActionsAllowedAtLoginScreenLength; +// The number of elements in kActionsAllowedAtLoginOrLockScreen. +ASH_EXPORT extern const size_t kActionsAllowedAtLoginOrLockScreenLength; + +// Actions allowed while screen is locked (in addition to +// kActionsAllowedAtLoginOrLockScreen). +ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLockScreen[]; + +// The number of elements in kActionsAllowedAtLockScreen. +ASH_EXPORT extern const size_t kActionsAllowedAtLockScreenLength; } // namespace ash diff --git a/ash/accelerators/accelerator_table_unittest.cc b/ash/accelerators/accelerator_table_unittest.cc index 9be3906..730d633 100644 --- a/ash/accelerators/accelerator_table_unittest.cc +++ b/ash/accelerators/accelerator_table_unittest.cc @@ -38,11 +38,15 @@ TEST(AcceleratorTableTest, CheckDuplicatedAccelerators) { } } -TEST(AcceleratorTableTest, CheckDuplicatedActionsAllowedAtLoginScreen) { +TEST(AcceleratorTableTest, CheckDuplicatedActionsAllowedAtLoginOrLockScreen) { std::set<AcceleratorAction> actions; - for (size_t i = 0; i < kActionsAllowedAtLoginScreenLength; ++i) { - EXPECT_TRUE(actions.insert(kActionsAllowedAtLoginScreen[i]).second) - << "Duplicated action: " << kActionsAllowedAtLoginScreen[i]; + for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) { + EXPECT_TRUE(actions.insert(kActionsAllowedAtLoginOrLockScreen[i]).second) + << "Duplicated action: " << kActionsAllowedAtLoginOrLockScreen[i]; + } + for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) { + EXPECT_TRUE(actions.insert(kActionsAllowedAtLockScreen[i]).second) + << "Duplicated action: " << kActionsAllowedAtLockScreen[i]; } } |