Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: ash/accelerators/accelerator_controller.cc

Issue 10388230: Allow Control+Shift+Q on lock screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | ash/accelerators/accelerator_table.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include "ash/accelerators/accelerator_table.h" 7 #include "ash/accelerators/accelerator_table.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/caps_lock_delegate.h" 9 #include "ash/caps_lock_delegate.h"
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 AcceleratorController::AcceleratorController() 183 AcceleratorController::AcceleratorController()
184 : accelerator_manager_(new ui::AcceleratorManager) { 184 : accelerator_manager_(new ui::AcceleratorManager) {
185 Init(); 185 Init();
186 } 186 }
187 187
188 AcceleratorController::~AcceleratorController() { 188 AcceleratorController::~AcceleratorController() {
189 } 189 }
190 190
191 void AcceleratorController::Init() { 191 void AcceleratorController::Init() {
192 for (size_t i = 0; i < kActionsAllowedAtLoginScreenLength; ++i) { 192 for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) {
193 actions_allowed_at_login_screen_.insert(kActionsAllowedAtLoginScreen[i]); 193 actions_allowed_at_login_screen_.insert(
194 kActionsAllowedAtLoginOrLockScreen[i]);
195 actions_allowed_at_lock_screen_.insert(
196 kActionsAllowedAtLoginOrLockScreen[i]);
197 }
198 for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) {
199 actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]);
194 } 200 }
195 201
196 for (size_t i = 0; i < kAcceleratorDataLength; ++i) { 202 for (size_t i = 0; i < kAcceleratorDataLength; ++i) {
197 ui::Accelerator accelerator(kAcceleratorData[i].keycode, 203 ui::Accelerator accelerator(kAcceleratorData[i].keycode,
198 kAcceleratorData[i].modifiers); 204 kAcceleratorData[i].modifiers);
199 accelerator.set_type(kAcceleratorData[i].trigger_on_press ? 205 accelerator.set_type(kAcceleratorData[i].trigger_on_press ?
200 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED); 206 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED);
201 Register(accelerator, this); 207 Register(accelerator, this);
202 accelerators_.insert( 208 accelerators_.insert(
203 std::make_pair(accelerator, kAcceleratorData[i].action)); 209 std::make_pair(accelerator, kAcceleratorData[i].action));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // AcceleratorController, ui::AcceleratorTarget implementation: 264 // AcceleratorController, ui::AcceleratorTarget implementation:
259 265
260 bool AcceleratorController::AcceleratorPressed( 266 bool AcceleratorController::AcceleratorPressed(
261 const ui::Accelerator& accelerator) { 267 const ui::Accelerator& accelerator) {
262 std::map<ui::Accelerator, int>::const_iterator it = 268 std::map<ui::Accelerator, int>::const_iterator it =
263 accelerators_.find(accelerator); 269 accelerators_.find(accelerator);
264 DCHECK(it != accelerators_.end()); 270 DCHECK(it != accelerators_.end());
265 AcceleratorAction action = static_cast<AcceleratorAction>(it->second); 271 AcceleratorAction action = static_cast<AcceleratorAction>(it->second);
266 272
267 ash::Shell* shell = ash::Shell::GetInstance(); 273 ash::Shell* shell = ash::Shell::GetInstance();
274 bool at_login_screen = false;
268 #if defined(OS_CHROMEOS) 275 #if defined(OS_CHROMEOS)
269 bool at_login_screen = shell->IsScreenLocked() || 276 at_login_screen = (shell->delegate() && !shell->delegate()->IsUserLoggedIn());
270 (shell->delegate() && !shell->delegate()->IsUserLoggedIn()); 277 #endif
271 #else 278 bool at_lock_screen = shell->IsScreenLocked();
272 bool at_login_screen = shell->IsScreenLocked();
273 #endif // OS_CHROMEOS
274 279
275 if (at_login_screen && 280 if (at_login_screen &&
276 actions_allowed_at_login_screen_.find(action) == 281 actions_allowed_at_login_screen_.find(action) ==
277 actions_allowed_at_login_screen_.end()) { 282 actions_allowed_at_login_screen_.end()) {
278 return false; 283 return false;
279 } 284 }
285 if (at_lock_screen &&
286 actions_allowed_at_lock_screen_.find(action) ==
287 actions_allowed_at_lock_screen_.end()) {
288 return false;
289 }
280 290
281 switch (action) { 291 switch (action) {
282 case CYCLE_BACKWARD_MRU: 292 case CYCLE_BACKWARD_MRU:
283 return HandleCycleWindowMRU(WindowCycleController::BACKWARD, 293 return HandleCycleWindowMRU(WindowCycleController::BACKWARD,
284 accelerator.IsAltDown()); 294 accelerator.IsAltDown());
285 case CYCLE_FORWARD_MRU: 295 case CYCLE_FORWARD_MRU:
286 return HandleCycleWindowMRU(WindowCycleController::FORWARD, 296 return HandleCycleWindowMRU(WindowCycleController::FORWARD,
287 accelerator.IsAltDown()); 297 accelerator.IsAltDown());
288 case CYCLE_BACKWARD_LINEAR: 298 case CYCLE_BACKWARD_LINEAR:
289 HandleCycleWindowLinear(CYCLE_BACKWARD); 299 HandleCycleWindowLinear(CYCLE_BACKWARD);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // Then set this one as active. 513 // Then set this one as active.
504 Shell::GetInstance()->launcher()->ActivateLauncherItem(found_index); 514 Shell::GetInstance()->launcher()->ActivateLauncherItem(found_index);
505 } 515 }
506 } 516 }
507 517
508 bool AcceleratorController::CanHandleAccelerators() const { 518 bool AcceleratorController::CanHandleAccelerators() const {
509 return true; 519 return true;
510 } 520 }
511 521
512 } // namespace ash 522 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | ash/accelerators/accelerator_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698