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 "ash/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ash/accelerators/accelerator_commands.h" | 11 #include "ash/accelerators/accelerator_commands.h" |
12 #include "ash/accelerators/accelerator_table.h" | |
13 #include "ash/accelerators/debug_commands.h" | 12 #include "ash/accelerators/debug_commands.h" |
14 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
15 #include "ash/debug.h" | 14 #include "ash/debug.h" |
16 #include "ash/display/display_controller.h" | 15 #include "ash/display/display_controller.h" |
17 #include "ash/display/display_manager.h" | 16 #include "ash/display/display_manager.h" |
18 #include "ash/focus_cycler.h" | 17 #include "ash/focus_cycler.h" |
19 #include "ash/gpu_support.h" | 18 #include "ash/gpu_support.h" |
20 #include "ash/ime_control_delegate.h" | 19 #include "ash/ime_control_delegate.h" |
21 #include "ash/magnifier/magnification_controller.h" | 20 #include "ash/magnifier/magnification_controller.h" |
22 #include "ash/magnifier/partial_magnification_controller.h" | 21 #include "ash/magnifier/partial_magnification_controller.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 119 |
121 bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) { | 120 bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) { |
122 if (accelerator.key_code() == ui::VKEY_TAB) | 121 if (accelerator.key_code() == ui::VKEY_TAB) |
123 base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab")); | 122 base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab")); |
124 | 123 |
125 Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow( | 124 Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow( |
126 WindowCycleController::FORWARD); | 125 WindowCycleController::FORWARD); |
127 return true; | 126 return true; |
128 } | 127 } |
129 | 128 |
130 bool ToggleOverview(const ui::Accelerator& accelerator) { | 129 bool HandleRotatePaneFocus(Shell::Direction direction) { |
131 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); | 130 Shell* shell = Shell::GetInstance(); |
132 Shell::GetInstance()->window_selector_controller()->ToggleOverview(); | 131 switch (direction) { |
| 132 // TODO(stevet): Not sure if this is the same as IDC_FOCUS_NEXT_PANE. |
| 133 case Shell::FORWARD: { |
| 134 base::RecordAction(UserMetricsAction("Accel_Focus_Next_Pane")); |
| 135 shell->focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 136 break; |
| 137 } |
| 138 case Shell::BACKWARD: { |
| 139 base::RecordAction(UserMetricsAction("Accel_Focus_Previous_Pane")); |
| 140 shell->focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 141 break; |
| 142 } |
| 143 } |
133 return true; | 144 return true; |
134 } | 145 } |
135 | 146 |
136 bool HandleFocusShelf() { | 147 bool HandleFocusShelf() { |
137 Shell* shell = Shell::GetInstance(); | 148 Shell* shell = Shell::GetInstance(); |
138 base::RecordAction(base::UserMetricsAction("Accel_Focus_Shelf")); | 149 base::RecordAction(base::UserMetricsAction("Accel_Focus_Shelf")); |
139 return shell->focus_cycler()->FocusWidget( | 150 return shell->focus_cycler()->FocusWidget( |
140 Shelf::ForPrimaryDisplay()->shelf_widget()); | 151 Shelf::ForPrimaryDisplay()->shelf_widget()); |
141 } | 152 } |
142 | 153 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 if (ime_control_delegate) | 251 if (ime_control_delegate) |
241 ime_control_delegate->HandleNextIme(); | 252 ime_control_delegate->HandleNextIme(); |
242 } | 253 } |
243 | 254 |
244 bool HandleOpenFeedbackPage() { | 255 bool HandleOpenFeedbackPage() { |
245 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); | 256 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); |
246 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); | 257 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); |
247 return true; | 258 return true; |
248 } | 259 } |
249 | 260 |
250 bool HandlePositionCenter() { | |
251 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); | |
252 aura::Window* window = wm::GetActiveWindow(); | |
253 // Docked windows do not support centering and ignore accelerator. | |
254 if (window && !wm::GetWindowState(window)->IsDocked()) { | |
255 wm::CenterWindow(window); | |
256 return true; | |
257 } | |
258 return false; | |
259 } | |
260 | |
261 bool HandlePreviousIme(ImeControlDelegate* ime_control_delegate, | 261 bool HandlePreviousIme(ImeControlDelegate* ime_control_delegate, |
262 const ui::Accelerator& accelerator) { | 262 const ui::Accelerator& accelerator) { |
263 base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); | 263 base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); |
264 if (ime_control_delegate) | 264 if (ime_control_delegate) |
265 return ime_control_delegate->HandlePreviousIme(accelerator); | 265 return ime_control_delegate->HandlePreviousIme(accelerator); |
266 return false; | 266 return false; |
267 } | 267 } |
268 | 268 |
269 bool HandleRestoreTab() { | 269 bool HandleRestoreTab() { |
270 base::RecordAction(base::UserMetricsAction("Accel_Restore_Tab")); | 270 base::RecordAction(base::UserMetricsAction("Accel_Restore_Tab")); |
271 Shell::GetInstance()->new_window_delegate()->RestoreTab(); | 271 Shell::GetInstance()->new_window_delegate()->RestoreTab(); |
272 return true; | 272 return true; |
273 } | 273 } |
274 | 274 |
275 bool HandleRotatePaneFocus(Shell::Direction direction) { | |
276 Shell* shell = Shell::GetInstance(); | |
277 switch (direction) { | |
278 // TODO(stevet): Not sure if this is the same as IDC_FOCUS_NEXT_PANE. | |
279 case Shell::FORWARD: { | |
280 base::RecordAction(UserMetricsAction("Accel_Focus_Next_Pane")); | |
281 shell->focus_cycler()->RotateFocus(FocusCycler::FORWARD); | |
282 break; | |
283 } | |
284 case Shell::BACKWARD: { | |
285 base::RecordAction(UserMetricsAction("Accel_Focus_Previous_Pane")); | |
286 shell->focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | |
287 break; | |
288 } | |
289 } | |
290 return true; | |
291 } | |
292 | |
293 // Rotate the active window. | |
294 bool HandleRotateActiveWindow() { | |
295 base::RecordAction(UserMetricsAction("Accel_Rotate_Window")); | |
296 aura::Window* active_window = wm::GetActiveWindow(); | |
297 if (active_window) { | |
298 // The rotation animation bases its target transform on the current | |
299 // rotation and position. Since there could be an animation in progress | |
300 // right now, queue this animation so when it starts it picks up a neutral | |
301 // rotation and position. Use replace so we only enqueue one at a time. | |
302 active_window->layer()->GetAnimator()-> | |
303 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | |
304 active_window->layer()->GetAnimator()->StartAnimation( | |
305 new ui::LayerAnimationSequence( | |
306 new ash::ScreenRotation(360, active_window->layer()))); | |
307 } | |
308 return true; | |
309 } | |
310 | |
311 gfx::Display::Rotation GetNextRotation(gfx::Display::Rotation current) { | 275 gfx::Display::Rotation GetNextRotation(gfx::Display::Rotation current) { |
312 switch (current) { | 276 switch (current) { |
313 case gfx::Display::ROTATE_0: | 277 case gfx::Display::ROTATE_0: |
314 return gfx::Display::ROTATE_90; | 278 return gfx::Display::ROTATE_90; |
315 case gfx::Display::ROTATE_90: | 279 case gfx::Display::ROTATE_90: |
316 return gfx::Display::ROTATE_180; | 280 return gfx::Display::ROTATE_180; |
317 case gfx::Display::ROTATE_180: | 281 case gfx::Display::ROTATE_180: |
318 return gfx::Display::ROTATE_270; | 282 return gfx::Display::ROTATE_270; |
319 case gfx::Display::ROTATE_270: | 283 case gfx::Display::ROTATE_270: |
320 return gfx::Display::ROTATE_0; | 284 return gfx::Display::ROTATE_0; |
321 } | 285 } |
322 NOTREACHED() << "Unknown rotation:" << current; | 286 NOTREACHED() << "Unknown rotation:" << current; |
323 return gfx::Display::ROTATE_0; | 287 return gfx::Display::ROTATE_0; |
324 } | 288 } |
325 | 289 |
326 // Rotates the screen. | 290 // Rotates the screen. |
327 bool HandleRotateScreen() { | 291 bool HandleRotateScreen() { |
328 base::RecordAction(UserMetricsAction("Accel_Rotate_Window")); | 292 base::RecordAction(UserMetricsAction("Accel_Rotate_Window")); |
329 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint(); | 293 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint(); |
330 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point); | 294 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point); |
331 const DisplayInfo& display_info = | 295 const DisplayInfo& display_info = |
332 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); | 296 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); |
333 Shell::GetInstance()->display_manager()->SetDisplayRotation( | 297 Shell::GetInstance()->display_manager()->SetDisplayRotation( |
334 display.id(), GetNextRotation(display_info.rotation())); | 298 display.id(), GetNextRotation(display_info.rotation())); |
335 return true; | 299 return true; |
336 } | 300 } |
337 | 301 |
| 302 // Rotate the active window. |
| 303 bool HandleRotateActiveWindow() { |
| 304 base::RecordAction(UserMetricsAction("Accel_Rotate_Window")); |
| 305 aura::Window* active_window = wm::GetActiveWindow(); |
| 306 if (active_window) { |
| 307 // The rotation animation bases its target transform on the current |
| 308 // rotation and position. Since there could be an animation in progress |
| 309 // right now, queue this animation so when it starts it picks up a neutral |
| 310 // rotation and position. Use replace so we only enqueue one at a time. |
| 311 active_window->layer()->GetAnimator()-> |
| 312 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 313 active_window->layer()->GetAnimator()->StartAnimation( |
| 314 new ui::LayerAnimationSequence( |
| 315 new ash::ScreenRotation(360, active_window->layer()))); |
| 316 } |
| 317 return true; |
| 318 } |
| 319 |
338 bool HandleScaleReset() { | 320 bool HandleScaleReset() { |
339 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 321 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
340 int64 display_id = display_manager->GetDisplayIdForUIScaling(); | 322 int64 display_id = display_manager->GetDisplayIdForUIScaling(); |
341 if (display_id == gfx::Display::kInvalidDisplayID) | 323 if (display_id == gfx::Display::kInvalidDisplayID) |
342 return false; | 324 return false; |
343 | 325 |
344 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Reset")); | 326 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Reset")); |
345 | 327 |
346 float ui_scale = | 328 float ui_scale = |
347 display_manager->GetDisplayInfo(display_id).configured_ui_scale(); | 329 display_manager->GetDisplayInfo(display_id).configured_ui_scale(); |
(...skipping 15 matching lines...) Expand all Loading... |
363 } else { | 345 } else { |
364 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Down")); | 346 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Down")); |
365 } | 347 } |
366 | 348 |
367 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); | 349 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); |
368 float next_scale = DisplayManager::GetNextUIScale(display_info, up); | 350 float next_scale = DisplayManager::GetNextUIScale(display_info, up); |
369 display_manager->SetDisplayUIScale(display_id, next_scale); | 351 display_manager->SetDisplayUIScale(display_id, next_scale); |
370 return true; | 352 return true; |
371 } | 353 } |
372 | 354 |
373 #if defined(OS_CHROMEOS) | |
374 bool HandleSwapPrimaryDisplay() { | |
375 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display")); | |
376 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); | |
377 return true; | |
378 } | |
379 #endif | |
380 | |
381 bool HandleShowKeyboardOverlay() { | 355 bool HandleShowKeyboardOverlay() { |
382 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); | 356 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); |
383 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); | 357 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); |
384 | 358 |
385 return true; | 359 return true; |
386 } | 360 } |
387 | 361 |
388 bool HandleShowMessageCenterBubble() { | 362 bool HandleShowMessageCenterBubble() { |
389 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble")); | 363 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble")); |
390 RootWindowController* controller = | 364 RootWindowController* controller = |
(...skipping 21 matching lines...) Expand all Loading... |
412 } | 386 } |
413 return false; | 387 return false; |
414 } | 388 } |
415 | 389 |
416 bool HandleShowTaskManager() { | 390 bool HandleShowTaskManager() { |
417 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); | 391 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); |
418 Shell::GetInstance()->new_window_delegate()->ShowTaskManager(); | 392 Shell::GetInstance()->new_window_delegate()->ShowTaskManager(); |
419 return true; | 393 return true; |
420 } | 394 } |
421 | 395 |
422 #if defined(OS_CHROMEOS) | |
423 void HandleSilenceSpokenFeedback() { | |
424 base::RecordAction(UserMetricsAction("Accel_Silence_Spoken_Feedback")); | |
425 | |
426 AccessibilityDelegate* delegate = | |
427 Shell::GetInstance()->accessibility_delegate(); | |
428 if (!delegate->IsSpokenFeedbackEnabled()) | |
429 return; | |
430 delegate->SilenceSpokenFeedback(); | |
431 } | |
432 #endif | |
433 | |
434 bool HandleSwitchIme(ImeControlDelegate* ime_control_delegate, | 396 bool HandleSwitchIme(ImeControlDelegate* ime_control_delegate, |
435 const ui::Accelerator& accelerator) { | 397 const ui::Accelerator& accelerator) { |
436 base::RecordAction(UserMetricsAction("Accel_Switch_Ime")); | 398 base::RecordAction(UserMetricsAction("Accel_Switch_Ime")); |
437 if (ime_control_delegate) | 399 if (ime_control_delegate) |
438 return ime_control_delegate->HandleSwitchIme(accelerator); | 400 return ime_control_delegate->HandleSwitchIme(accelerator); |
439 return false; | 401 return false; |
440 } | 402 } |
441 | 403 |
442 bool HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) { | 404 bool HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) { |
443 base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot")); | 405 base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot")); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 } | 447 } |
486 | 448 |
487 bool HandleToggleFullscreen(ui::KeyboardCode key_code) { | 449 bool HandleToggleFullscreen(ui::KeyboardCode key_code) { |
488 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP2) { | 450 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP2) { |
489 base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4")); | 451 base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4")); |
490 } | 452 } |
491 accelerators::ToggleFullscreen(); | 453 accelerators::ToggleFullscreen(); |
492 return true; | 454 return true; |
493 } | 455 } |
494 | 456 |
495 bool HandleWindowSnapOrDock(int action) { | 457 bool HandleToggleOverview(const ui::Accelerator& accelerator) { |
| 458 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); |
| 459 Shell::GetInstance()->window_selector_controller()->ToggleOverview(); |
| 460 return true; |
| 461 } |
| 462 |
| 463 bool HandleWindowSnapOrDock(AcceleratorAction action) { |
496 wm::WindowState* window_state = wm::GetActiveWindowState(); | 464 wm::WindowState* window_state = wm::GetActiveWindowState(); |
497 // Disable window snapping shortcut key for full screen window due to | 465 // Disable window snapping shortcut key for full screen window due to |
498 // http://crbug.com/135487. | 466 // http://crbug.com/135487. |
499 if (!window_state || | 467 if (!window_state || |
500 (window_state->window()->type() != ui::wm::WINDOW_TYPE_NORMAL && | 468 (window_state->window()->type() != ui::wm::WINDOW_TYPE_NORMAL && |
501 window_state->window()->type() != ui::wm::WINDOW_TYPE_PANEL) || | 469 window_state->window()->type() != ui::wm::WINDOW_TYPE_PANEL) || |
502 window_state->IsFullscreen()) { | 470 window_state->IsFullscreen()) { |
503 return false; | 471 return false; |
504 } | 472 } |
505 | 473 |
506 if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT) | 474 if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT) |
507 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); | 475 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); |
508 else | 476 else |
509 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); | 477 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); |
510 | 478 |
511 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT ? | 479 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT ? |
512 wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT : | 480 wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT : |
513 wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); | 481 wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); |
514 window_state->OnWMEvent(&event); | 482 window_state->OnWMEvent(&event); |
515 return true; | 483 return true; |
516 } | 484 } |
517 | 485 |
518 bool HandleWindowMinimize() { | 486 bool HandleWindowMinimize() { |
519 base::RecordAction( | 487 base::RecordAction( |
520 base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); | 488 base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); |
521 return accelerators::ToggleMinimized(); | 489 return accelerators::ToggleMinimized(); |
522 } | 490 } |
523 | 491 |
| 492 bool HandlePositionCenter() { |
| 493 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); |
| 494 aura::Window* window = wm::GetActiveWindow(); |
| 495 // Docked windows do not support centering and ignore accelerator. |
| 496 if (window && !wm::GetWindowState(window)->IsDocked()) { |
| 497 wm::CenterWindow(window); |
| 498 return true; |
| 499 } |
| 500 return false; |
| 501 } |
| 502 |
524 #if defined(OS_CHROMEOS) | 503 #if defined(OS_CHROMEOS) |
| 504 bool HandleDisableCapsLock(ui::KeyboardCode key_code, |
| 505 ui::EventType previous_event_type, |
| 506 ui::KeyboardCode previous_key_code) { |
| 507 if (previous_event_type == ui::ET_KEY_RELEASED || |
| 508 (previous_key_code != ui::VKEY_LSHIFT && |
| 509 previous_key_code != ui::VKEY_SHIFT && |
| 510 previous_key_code != ui::VKEY_RSHIFT)) { |
| 511 // If something else was pressed between the Shift key being pressed |
| 512 // and released, then ignore the release of the Shift key. |
| 513 return false; |
| 514 } |
| 515 base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock")); |
| 516 chromeos::input_method::InputMethodManager* ime = |
| 517 chromeos::input_method::InputMethodManager::Get(); |
| 518 chromeos::input_method::ImeKeyboard* keyboard = |
| 519 ime ? ime->GetImeKeyboard() : NULL; |
| 520 if (keyboard && keyboard->CapsLockIsEnabled()) { |
| 521 keyboard->SetCapsLockEnabled(false); |
| 522 return true; |
| 523 } |
| 524 return false; |
| 525 } |
| 526 |
| 527 bool HandleLock(ui::KeyboardCode key_code) { |
| 528 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); |
| 529 Shell::GetInstance()->session_state_delegate()->LockScreen(); |
| 530 return true; |
| 531 } |
| 532 |
525 bool HandleCrosh() { | 533 bool HandleCrosh() { |
526 base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); | 534 base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); |
527 | 535 |
528 Shell::GetInstance()->new_window_delegate()->OpenCrosh(); | 536 Shell::GetInstance()->new_window_delegate()->OpenCrosh(); |
529 return true; | 537 return true; |
530 } | 538 } |
531 | 539 |
532 bool HandleFileManager() { | 540 bool HandleFileManager() { |
533 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); | 541 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); |
534 | 542 |
535 Shell::GetInstance()->new_window_delegate()->OpenFileManager(); | 543 Shell::GetInstance()->new_window_delegate()->OpenFileManager(); |
536 return true; | 544 return true; |
537 } | 545 } |
538 | 546 |
539 bool HandleLock(ui::KeyboardCode key_code) { | 547 void HandleSilenceSpokenFeedback() { |
540 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); | 548 base::RecordAction(UserMetricsAction("Accel_Silence_Spoken_Feedback")); |
541 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 549 |
| 550 AccessibilityDelegate* delegate = |
| 551 Shell::GetInstance()->accessibility_delegate(); |
| 552 if (!delegate->IsSpokenFeedbackEnabled()) |
| 553 return; |
| 554 delegate->SilenceSpokenFeedback(); |
| 555 } |
| 556 |
| 557 bool HandleSwapPrimaryDisplay() { |
| 558 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display")); |
| 559 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); |
542 return true; | 560 return true; |
543 } | 561 } |
544 | 562 |
545 bool HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) { | 563 bool HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) { |
546 if (!Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) | 564 if (!Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) |
547 return false; | 565 return false; |
548 ash::SessionStateDelegate* delegate = | 566 ash::SessionStateDelegate* delegate = |
549 ash::Shell::GetInstance()->session_state_delegate(); | 567 ash::Shell::GetInstance()->session_state_delegate(); |
550 if (delegate->NumberOfLoggedInUsers() <= 1) | 568 if (delegate->NumberOfLoggedInUsers() <= 1) |
551 return false; | 569 return false; |
552 MultiProfileUMA::RecordSwitchActiveUser( | 570 MultiProfileUMA::RecordSwitchActiveUser( |
553 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); | 571 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); |
554 switch (cycle_user) { | 572 switch (cycle_user) { |
555 case SessionStateDelegate::CYCLE_TO_NEXT_USER: | 573 case SessionStateDelegate::CYCLE_TO_NEXT_USER: |
556 base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User")); | 574 base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User")); |
557 break; | 575 break; |
558 case SessionStateDelegate::CYCLE_TO_PREVIOUS_USER: | 576 case SessionStateDelegate::CYCLE_TO_PREVIOUS_USER: |
559 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); | 577 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); |
560 break; | 578 break; |
561 } | 579 } |
562 delegate->CycleActiveUser(cycle_user); | 580 delegate->CycleActiveUser(cycle_user); |
563 return true; | 581 return true; |
564 } | 582 } |
565 | 583 |
| 584 bool HandleToggleCapsLock(ui::KeyboardCode key_code, |
| 585 ui::EventType previous_event_type, |
| 586 ui::KeyboardCode previous_key_code) { |
| 587 if (key_code == ui::VKEY_LWIN) { |
| 588 // If something else was pressed between the Search key (LWIN) |
| 589 // being pressed and released, then ignore the release of the |
| 590 // Search key. |
| 591 // TODO(danakj): Releasing Alt first breaks this: crbug.com/166495 |
| 592 if (previous_event_type == ui::ET_KEY_RELEASED || |
| 593 previous_key_code != ui::VKEY_LWIN) |
| 594 return false; |
| 595 } |
| 596 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); |
| 597 chromeos::input_method::InputMethodManager* ime = |
| 598 chromeos::input_method::InputMethodManager::Get(); |
| 599 chromeos::input_method::ImeKeyboard* keyboard = |
| 600 ime ? ime->GetImeKeyboard() : NULL; |
| 601 if (keyboard) |
| 602 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
| 603 return true; |
| 604 } |
| 605 |
566 bool HandleToggleMirrorMode() { | 606 bool HandleToggleMirrorMode() { |
567 base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode")); | 607 base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode")); |
568 Shell::GetInstance()->display_controller()->ToggleMirrorMode(); | 608 Shell::GetInstance()->display_controller()->ToggleMirrorMode(); |
569 return true; | 609 return true; |
570 } | 610 } |
571 | 611 |
572 bool HandleToggleSpokenFeedback() { | 612 bool HandleToggleSpokenFeedback() { |
573 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); | 613 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); |
574 | 614 |
575 Shell::GetInstance()->accessibility_delegate()-> | 615 Shell::GetInstance()->accessibility_delegate()-> |
(...skipping 27 matching lines...) Expand all Loading... |
603 bool HandleTouchHudModeChange() { | 643 bool HandleTouchHudModeChange() { |
604 RootWindowController* controller = | 644 RootWindowController* controller = |
605 RootWindowController::ForTargetRootWindow(); | 645 RootWindowController::ForTargetRootWindow(); |
606 if (controller->touch_hud_debug()) { | 646 if (controller->touch_hud_debug()) { |
607 controller->touch_hud_debug()->ChangeToNextMode(); | 647 controller->touch_hud_debug()->ChangeToNextMode(); |
608 return true; | 648 return true; |
609 } | 649 } |
610 return false; | 650 return false; |
611 } | 651 } |
612 | 652 |
613 bool HandleDisableCapsLock(ui::KeyboardCode key_code, | |
614 ui::EventType previous_event_type, | |
615 ui::KeyboardCode previous_key_code) { | |
616 if (previous_event_type == ui::ET_KEY_RELEASED || | |
617 (previous_key_code != ui::VKEY_LSHIFT && | |
618 previous_key_code != ui::VKEY_SHIFT && | |
619 previous_key_code != ui::VKEY_RSHIFT)) { | |
620 // If something else was pressed between the Shift key being pressed | |
621 // and released, then ignore the release of the Shift key. | |
622 return false; | |
623 } | |
624 base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock")); | |
625 chromeos::input_method::InputMethodManager* ime = | |
626 chromeos::input_method::InputMethodManager::Get(); | |
627 chromeos::input_method::ImeKeyboard* keyboard = | |
628 ime ? ime->GetImeKeyboard() : NULL; | |
629 if (keyboard && keyboard->CapsLockIsEnabled()) { | |
630 keyboard->SetCapsLockEnabled(false); | |
631 return true; | |
632 } | |
633 return false; | |
634 } | |
635 | |
636 bool HandleToggleCapsLock(ui::KeyboardCode key_code, | |
637 ui::EventType previous_event_type, | |
638 ui::KeyboardCode previous_key_code) { | |
639 if (key_code == ui::VKEY_LWIN) { | |
640 // If something else was pressed between the Search key (LWIN) | |
641 // being pressed and released, then ignore the release of the | |
642 // Search key. | |
643 // TODO(danakj): Releasing Alt first breaks this: crbug.com/166495 | |
644 if (previous_event_type == ui::ET_KEY_RELEASED || | |
645 previous_key_code != ui::VKEY_LWIN) | |
646 return false; | |
647 } | |
648 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); | |
649 chromeos::input_method::InputMethodManager* ime = | |
650 chromeos::input_method::InputMethodManager::Get(); | |
651 chromeos::input_method::ImeKeyboard* keyboard = | |
652 ime ? ime->GetImeKeyboard() : NULL; | |
653 if (keyboard) | |
654 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | |
655 return true; | |
656 } | |
657 | |
658 #endif // defined(OS_CHROMEOS) | 653 #endif // defined(OS_CHROMEOS) |
659 | 654 |
660 class AutoSet { | 655 class AutoSet { |
661 public: | 656 public: |
662 AutoSet(ui::Accelerator* scoped, ui::Accelerator new_value) | 657 AutoSet(ui::Accelerator* scoped, ui::Accelerator new_value) |
663 : scoped_(scoped), new_value_(new_value) {} | 658 : scoped_(scoped), new_value_(new_value) {} |
664 ~AutoSet() { *scoped_ = new_value_; } | 659 ~AutoSet() { *scoped_ = new_value_; } |
665 | 660 |
666 private: | 661 private: |
667 ui::Accelerator* scoped_; | 662 ui::Accelerator* scoped_; |
668 const ui::Accelerator new_value_; | 663 const ui::Accelerator new_value_; |
669 | 664 |
670 DISALLOW_COPY_AND_ASSIGN(AutoSet); | 665 DISALLOW_COPY_AND_ASSIGN(AutoSet); |
671 }; | 666 }; |
672 | 667 |
673 } // namespace | 668 } // namespace |
674 | 669 |
675 //////////////////////////////////////////////////////////////////////////////// | 670 //////////////////////////////////////////////////////////////////////////////// |
676 // AcceleratorController, public: | 671 // AcceleratorController, public: |
677 | 672 |
678 AcceleratorController::AcceleratorController() | 673 AcceleratorController::AcceleratorController() |
679 : accelerator_manager_(new ui::AcceleratorManager) { | 674 : accelerator_manager_(new ui::AcceleratorManager) { |
680 Init(); | 675 Init(); |
681 } | 676 } |
682 | 677 |
683 AcceleratorController::~AcceleratorController() { | 678 AcceleratorController::~AcceleratorController() { |
684 } | 679 } |
685 | 680 |
686 void AcceleratorController::Init() { | |
687 previous_accelerator_.set_type(ui::ET_UNKNOWN); | |
688 for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) { | |
689 actions_allowed_at_login_screen_.insert( | |
690 kActionsAllowedAtLoginOrLockScreen[i]); | |
691 actions_allowed_at_lock_screen_.insert( | |
692 kActionsAllowedAtLoginOrLockScreen[i]); | |
693 } | |
694 for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) | |
695 actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]); | |
696 for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i) | |
697 actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]); | |
698 for (size_t i = 0; i < kPreferredActionsLength; ++i) | |
699 preferred_actions_.insert(kPreferredActions[i]); | |
700 for (size_t i = 0; i < kReservedActionsLength; ++i) | |
701 reserved_actions_.insert(kReservedActions[i]); | |
702 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) | |
703 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); | |
704 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) | |
705 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); | |
706 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) | |
707 actions_needing_window_.insert(kActionsNeedingWindow[i]); | |
708 | |
709 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); | |
710 | |
711 if (debug::DebugAcceleratorsEnabled()) { | |
712 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); | |
713 // All debug accelerators are reserved. | |
714 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) | |
715 reserved_actions_.insert(kDebugAcceleratorData[i].action); | |
716 } | |
717 | |
718 #if defined(OS_CHROMEOS) | |
719 keyboard_brightness_control_delegate_.reset( | |
720 new KeyboardBrightnessController()); | |
721 #endif | |
722 } | |
723 | |
724 void AcceleratorController::Register(const ui::Accelerator& accelerator, | 681 void AcceleratorController::Register(const ui::Accelerator& accelerator, |
725 ui::AcceleratorTarget* target) { | 682 ui::AcceleratorTarget* target) { |
726 accelerator_manager_->Register(accelerator, | 683 accelerator_manager_->Register(accelerator, |
727 ui::AcceleratorManager::kNormalPriority, | 684 ui::AcceleratorManager::kNormalPriority, |
728 target); | 685 target); |
729 } | 686 } |
730 | 687 |
731 void AcceleratorController::Unregister(const ui::Accelerator& accelerator, | 688 void AcceleratorController::Unregister(const ui::Accelerator& accelerator, |
732 ui::AcceleratorTarget* target) { | 689 ui::AcceleratorTarget* target) { |
733 accelerator_manager_->Unregister(accelerator, target); | 690 accelerator_manager_->Unregister(accelerator, target); |
(...skipping 16 matching lines...) Expand all Loading... |
750 bool AcceleratorController::IsRegistered( | 707 bool AcceleratorController::IsRegistered( |
751 const ui::Accelerator& accelerator) const { | 708 const ui::Accelerator& accelerator) const { |
752 return accelerator_manager_->GetCurrentTarget(accelerator) != NULL; | 709 return accelerator_manager_->GetCurrentTarget(accelerator) != NULL; |
753 } | 710 } |
754 | 711 |
755 bool AcceleratorController::IsPreferred( | 712 bool AcceleratorController::IsPreferred( |
756 const ui::Accelerator& accelerator) const { | 713 const ui::Accelerator& accelerator) const { |
757 const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ? | 714 const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ? |
758 ime_control_delegate_->RemapAccelerator(accelerator) : accelerator; | 715 ime_control_delegate_->RemapAccelerator(accelerator) : accelerator; |
759 | 716 |
760 std::map<ui::Accelerator, int>::const_iterator iter = | 717 std::map<ui::Accelerator, AcceleratorAction>::const_iterator iter = |
761 accelerators_.find(remapped_accelerator); | 718 accelerators_.find(remapped_accelerator); |
762 if (iter == accelerators_.end()) | 719 if (iter == accelerators_.end()) |
763 return false; // not an accelerator. | 720 return false; // not an accelerator. |
764 | 721 |
765 return preferred_actions_.find(iter->second) != preferred_actions_.end(); | 722 return preferred_actions_.find(iter->second) != preferred_actions_.end(); |
766 } | 723 } |
767 | 724 |
768 bool AcceleratorController::IsReserved( | 725 bool AcceleratorController::IsReserved( |
769 const ui::Accelerator& accelerator) const { | 726 const ui::Accelerator& accelerator) const { |
770 const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ? | 727 const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ? |
771 ime_control_delegate_->RemapAccelerator(accelerator) : accelerator; | 728 ime_control_delegate_->RemapAccelerator(accelerator) : accelerator; |
772 | 729 |
773 std::map<ui::Accelerator, int>::const_iterator iter = | 730 std::map<ui::Accelerator, AcceleratorAction>::const_iterator iter = |
774 accelerators_.find(remapped_accelerator); | 731 accelerators_.find(remapped_accelerator); |
775 if (iter == accelerators_.end()) | 732 if (iter == accelerators_.end()) |
776 return false; // not an accelerator. | 733 return false; // not an accelerator. |
777 | 734 |
778 return reserved_actions_.find(iter->second) != reserved_actions_.end(); | 735 return reserved_actions_.find(iter->second) != reserved_actions_.end(); |
779 } | 736 } |
780 | 737 |
781 bool AcceleratorController::PerformActionIfEnabled(int action) { | 738 bool AcceleratorController::PerformActionIfEnabled(AcceleratorAction action) { |
782 return PerformAction(action, ui::Accelerator()); | 739 return PerformAction(action, ui::Accelerator()); |
783 } | 740 } |
784 | 741 |
785 bool AcceleratorController::PerformAction(int action, | 742 AcceleratorController::AcceleratorProcessingRestriction |
| 743 AcceleratorController::GetCurrentAcceleratorRestriction() { |
| 744 return GetAcceleratorProcessingRestriction(-1); |
| 745 } |
| 746 |
| 747 void AcceleratorController::SetBrightnessControlDelegate( |
| 748 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) { |
| 749 brightness_control_delegate_ = brightness_control_delegate.Pass(); |
| 750 } |
| 751 |
| 752 void AcceleratorController::SetImeControlDelegate( |
| 753 scoped_ptr<ImeControlDelegate> ime_control_delegate) { |
| 754 ime_control_delegate_ = ime_control_delegate.Pass(); |
| 755 } |
| 756 |
| 757 void AcceleratorController::SetScreenshotDelegate( |
| 758 scoped_ptr<ScreenshotDelegate> screenshot_delegate) { |
| 759 screenshot_delegate_ = screenshot_delegate.Pass(); |
| 760 } |
| 761 |
| 762 //////////////////////////////////////////////////////////////////////////////// |
| 763 // AcceleratorController, ui::AcceleratorTarget implementation: |
| 764 |
| 765 bool AcceleratorController::AcceleratorPressed( |
| 766 const ui::Accelerator& accelerator) { |
| 767 std::map<ui::Accelerator, AcceleratorAction>::const_iterator it = |
| 768 accelerators_.find(accelerator); |
| 769 DCHECK(it != accelerators_.end()); |
| 770 return PerformAction(it->second, accelerator); |
| 771 } |
| 772 |
| 773 bool AcceleratorController::CanHandleAccelerators() const { |
| 774 return true; |
| 775 } |
| 776 |
| 777 /////////////////////////////////////////////////////////////////////////////// |
| 778 // AcceleratorController, private: |
| 779 |
| 780 void AcceleratorController::Init() { |
| 781 previous_accelerator_.set_type(ui::ET_UNKNOWN); |
| 782 for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) { |
| 783 actions_allowed_at_login_screen_.insert( |
| 784 kActionsAllowedAtLoginOrLockScreen[i]); |
| 785 actions_allowed_at_lock_screen_.insert( |
| 786 kActionsAllowedAtLoginOrLockScreen[i]); |
| 787 } |
| 788 for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) |
| 789 actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]); |
| 790 for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i) |
| 791 actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]); |
| 792 for (size_t i = 0; i < kPreferredActionsLength; ++i) |
| 793 preferred_actions_.insert(kPreferredActions[i]); |
| 794 for (size_t i = 0; i < kReservedActionsLength; ++i) |
| 795 reserved_actions_.insert(kReservedActions[i]); |
| 796 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) |
| 797 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); |
| 798 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) |
| 799 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); |
| 800 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) |
| 801 actions_needing_window_.insert(kActionsNeedingWindow[i]); |
| 802 |
| 803 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); |
| 804 |
| 805 if (debug::DebugAcceleratorsEnabled()) { |
| 806 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); |
| 807 // All debug accelerators are reserved. |
| 808 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) |
| 809 reserved_actions_.insert(kDebugAcceleratorData[i].action); |
| 810 } |
| 811 |
| 812 #if defined(OS_CHROMEOS) |
| 813 keyboard_brightness_control_delegate_.reset( |
| 814 new KeyboardBrightnessController()); |
| 815 #endif |
| 816 } |
| 817 |
| 818 void AcceleratorController::RegisterAccelerators( |
| 819 const AcceleratorData accelerators[], |
| 820 size_t accelerators_length) { |
| 821 for (size_t i = 0; i < accelerators_length; ++i) { |
| 822 ui::Accelerator accelerator(accelerators[i].keycode, |
| 823 accelerators[i].modifiers); |
| 824 accelerator.set_type(accelerators[i].trigger_on_press ? |
| 825 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED); |
| 826 Register(accelerator, this); |
| 827 accelerators_.insert( |
| 828 std::make_pair(accelerator, accelerators[i].action)); |
| 829 } |
| 830 } |
| 831 |
| 832 bool AcceleratorController::PerformAction(AcceleratorAction action, |
786 const ui::Accelerator& accelerator) { | 833 const ui::Accelerator& accelerator) { |
787 ash::Shell* shell = ash::Shell::GetInstance(); | 834 ash::Shell* shell = ash::Shell::GetInstance(); |
788 AcceleratorProcessingRestriction restriction = | 835 AcceleratorProcessingRestriction restriction = |
789 GetAcceleratorProcessingRestriction(action); | 836 GetAcceleratorProcessingRestriction(action); |
790 if (restriction != RESTRICTION_NONE) | 837 if (restriction != RESTRICTION_NONE) |
791 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 838 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
792 | 839 |
793 if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() && | 840 if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() && |
794 accelerator.IsRepeat()) { | 841 accelerator.IsRepeat()) { |
795 return true; | 842 return true; |
(...skipping 10 matching lines...) Expand all Loading... |
806 // and BrowserView::HandleKeyboardEvent, for a single accelerator press. | 853 // and BrowserView::HandleKeyboardEvent, for a single accelerator press. |
807 // | 854 // |
808 // If your accelerator invokes more than one line of code, please either | 855 // If your accelerator invokes more than one line of code, please either |
809 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE | 856 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE |
810 // below) or pull it into a HandleFoo() function above. | 857 // below) or pull it into a HandleFoo() function above. |
811 switch (action) { | 858 switch (action) { |
812 case ACCESSIBLE_FOCUS_NEXT: | 859 case ACCESSIBLE_FOCUS_NEXT: |
813 return HandleAccessibleFocusCycle(false); | 860 return HandleAccessibleFocusCycle(false); |
814 case ACCESSIBLE_FOCUS_PREVIOUS: | 861 case ACCESSIBLE_FOCUS_PREVIOUS: |
815 return HandleAccessibleFocusCycle(true); | 862 return HandleAccessibleFocusCycle(true); |
816 case CYCLE_BACKWARD_MRU: | |
817 return HandleCycleBackwardMRU(accelerator); | |
818 case CYCLE_FORWARD_MRU: | |
819 return HandleCycleForwardMRU(accelerator); | |
820 case TOGGLE_OVERVIEW: | |
821 return ToggleOverview(accelerator); | |
822 #if defined(OS_CHROMEOS) | |
823 case TOGGLE_MIRROR_MODE: | |
824 return HandleToggleMirrorMode(); | |
825 case LOCK_SCREEN: | |
826 return HandleLock(key_code); | |
827 case OPEN_FILE_MANAGER: | |
828 return HandleFileManager(); | |
829 case OPEN_CROSH: | |
830 return HandleCrosh(); | |
831 case SILENCE_SPOKEN_FEEDBACK: | |
832 HandleSilenceSpokenFeedback(); | |
833 return false; | |
834 case SWAP_PRIMARY_DISPLAY: | |
835 return HandleSwapPrimaryDisplay(); | |
836 case SWITCH_TO_NEXT_USER: | |
837 return HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); | |
838 case SWITCH_TO_PREVIOUS_USER: | |
839 return HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); | |
840 case TOGGLE_SPOKEN_FEEDBACK: | |
841 return HandleToggleSpokenFeedback(); | |
842 case TOGGLE_TOUCH_VIEW_TESTING: | |
843 return HandleToggleTouchViewTesting(); | |
844 case TOGGLE_WIFI: | |
845 Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi(); | |
846 return true; | |
847 case TOUCH_HUD_CLEAR: | |
848 return HandleTouchHudClear(); | |
849 case TOUCH_HUD_MODE_CHANGE: | |
850 return HandleTouchHudModeChange(); | |
851 case TOUCH_HUD_PROJECTION_TOGGLE: | |
852 accelerators::ToggleTouchHudProjection(); | |
853 return true; | |
854 case DISABLE_GPU_WATCHDOG: | |
855 Shell::GetInstance()->gpu_support()->DisableGpuWatchdog(); | |
856 return true; | |
857 case DISABLE_CAPS_LOCK: | |
858 return HandleDisableCapsLock( | |
859 key_code, previous_event_type, previous_key_code); | |
860 case TOGGLE_CAPS_LOCK: | |
861 return HandleToggleCapsLock( | |
862 key_code, previous_event_type, previous_key_code); | |
863 #endif // OS_CHROMEOS | |
864 case OPEN_FEEDBACK_PAGE: | |
865 return HandleOpenFeedbackPage(); | |
866 case EXIT: | |
867 // UMA metrics are recorded in the handler. | |
868 exit_warning_handler_.HandleAccelerator(); | |
869 return true; | |
870 case NEW_INCOGNITO_WINDOW: | |
871 return HandleNewIncognitoWindow(); | |
872 case NEW_TAB: | |
873 return HandleNewTab(key_code); | |
874 case NEW_WINDOW: | |
875 return HandleNewWindow(); | |
876 case RESTORE_TAB: | |
877 return HandleRestoreTab(); | |
878 case TAKE_SCREENSHOT: | |
879 return HandleTakeScreenshot(screenshot_delegate_.get()); | |
880 case TAKE_PARTIAL_SCREENSHOT: | |
881 return HandleTakePartialScreenshot(screenshot_delegate_.get()); | |
882 case TOGGLE_APP_LIST: | |
883 return HandleToggleAppList( | |
884 key_code, previous_event_type, previous_key_code, accelerator); | |
885 case BRIGHTNESS_DOWN: | 863 case BRIGHTNESS_DOWN: |
886 if (brightness_control_delegate_) | 864 if (brightness_control_delegate_) |
887 return brightness_control_delegate_->HandleBrightnessDown(accelerator); | 865 return brightness_control_delegate_->HandleBrightnessDown(accelerator); |
888 return false; | 866 return false; |
889 case BRIGHTNESS_UP: | 867 case BRIGHTNESS_UP: |
890 if (brightness_control_delegate_) | 868 if (brightness_control_delegate_) |
891 return brightness_control_delegate_->HandleBrightnessUp(accelerator); | 869 return brightness_control_delegate_->HandleBrightnessUp(accelerator); |
892 return false; | 870 return false; |
893 case KEYBOARD_BRIGHTNESS_DOWN: | 871 case CYCLE_BACKWARD_MRU: |
894 if (keyboard_brightness_control_delegate_) | 872 return HandleCycleBackwardMRU(accelerator); |
895 return keyboard_brightness_control_delegate_-> | 873 case CYCLE_FORWARD_MRU: |
896 HandleKeyboardBrightnessDown(accelerator); | 874 return HandleCycleForwardMRU(accelerator); |
897 return false; | 875 case DEBUG_PRINT_LAYER_HIERARCHY: |
898 case KEYBOARD_BRIGHTNESS_UP: | 876 case DEBUG_PRINT_VIEW_HIERARCHY: |
899 if (keyboard_brightness_control_delegate_) | 877 case DEBUG_PRINT_WINDOW_HIERARCHY: |
900 return keyboard_brightness_control_delegate_-> | 878 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: |
901 HandleKeyboardBrightnessUp(accelerator); | 879 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: |
902 return false; | 880 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
903 case VOLUME_MUTE: { | 881 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: |
904 ash::VolumeControlDelegate* volume_delegate = | 882 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: |
905 shell->system_tray_delegate()->GetVolumeControlDelegate(); | 883 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: |
906 return volume_delegate && volume_delegate->HandleVolumeMute(accelerator); | 884 return debug::PerformDebugAction(action); |
907 } | 885 case EXIT: |
908 case VOLUME_DOWN: { | 886 // UMA metrics are recorded in the handler. |
909 ash::VolumeControlDelegate* volume_delegate = | 887 exit_warning_handler_.HandleAccelerator(); |
910 shell->system_tray_delegate()->GetVolumeControlDelegate(); | 888 return true; |
911 return volume_delegate && volume_delegate->HandleVolumeDown(accelerator); | |
912 } | |
913 case VOLUME_UP: { | |
914 ash::VolumeControlDelegate* volume_delegate = | |
915 shell->system_tray_delegate()->GetVolumeControlDelegate(); | |
916 return volume_delegate && volume_delegate->HandleVolumeUp(accelerator); | |
917 } | |
918 case FOCUS_SHELF: | |
919 return HandleFocusShelf(); | |
920 case FOCUS_NEXT_PANE: | 889 case FOCUS_NEXT_PANE: |
921 return HandleRotatePaneFocus(Shell::FORWARD); | 890 return HandleRotatePaneFocus(Shell::FORWARD); |
922 case FOCUS_PREVIOUS_PANE: | 891 case FOCUS_PREVIOUS_PANE: |
923 return HandleRotatePaneFocus(Shell::BACKWARD); | 892 return HandleRotatePaneFocus(Shell::BACKWARD); |
924 case SHOW_KEYBOARD_OVERLAY: | 893 case FOCUS_SHELF: |
925 return HandleShowKeyboardOverlay(); | 894 return HandleFocusShelf(); |
926 case SHOW_SYSTEM_TRAY_BUBBLE: | |
927 return HandleShowSystemTrayBubble(); | |
928 case SHOW_MESSAGE_CENTER_BUBBLE: | |
929 return HandleShowMessageCenterBubble(); | |
930 case SHOW_TASK_MANAGER: | |
931 return HandleShowTaskManager(); | |
932 case NEXT_IME: | |
933 HandleNextIme( | |
934 ime_control_delegate_.get(), previous_event_type, previous_key_code); | |
935 // NEXT_IME is bound to Alt-Shift key up event. To be consistent with | |
936 // Windows behavior, do not consume the key event here. | |
937 return false; | |
938 case PREVIOUS_IME: | |
939 return HandlePreviousIme(ime_control_delegate_.get(), accelerator); | |
940 case PRINT_UI_HIERARCHIES: | |
941 debug::PrintUIHierarchies(); | |
942 return true; | |
943 case SWITCH_IME: | |
944 return HandleSwitchIme(ime_control_delegate_.get(), accelerator); | |
945 case LAUNCH_APP_0: | 895 case LAUNCH_APP_0: |
946 return HandleLaunchAppN(0); | 896 return HandleLaunchAppN(0); |
947 case LAUNCH_APP_1: | 897 case LAUNCH_APP_1: |
948 return HandleLaunchAppN(1); | 898 return HandleLaunchAppN(1); |
949 case LAUNCH_APP_2: | 899 case LAUNCH_APP_2: |
950 return HandleLaunchAppN(2); | 900 return HandleLaunchAppN(2); |
951 case LAUNCH_APP_3: | 901 case LAUNCH_APP_3: |
952 return HandleLaunchAppN(3); | 902 return HandleLaunchAppN(3); |
953 case LAUNCH_APP_4: | 903 case LAUNCH_APP_4: |
954 return HandleLaunchAppN(4); | 904 return HandleLaunchAppN(4); |
955 case LAUNCH_APP_5: | 905 case LAUNCH_APP_5: |
956 return HandleLaunchAppN(5); | 906 return HandleLaunchAppN(5); |
957 case LAUNCH_APP_6: | 907 case LAUNCH_APP_6: |
958 return HandleLaunchAppN(6); | 908 return HandleLaunchAppN(6); |
959 case LAUNCH_APP_7: | 909 case LAUNCH_APP_7: |
960 return HandleLaunchAppN(7); | 910 return HandleLaunchAppN(7); |
961 case LAUNCH_LAST_APP: | 911 case LAUNCH_LAST_APP: |
962 return HandleLaunchLastApp(); | 912 return HandleLaunchLastApp(); |
963 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | |
964 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | |
965 return HandleWindowSnapOrDock(action); | |
966 case WINDOW_MINIMIZE: | |
967 return HandleWindowMinimize(); | |
968 case TOGGLE_FULLSCREEN: | |
969 return HandleToggleFullscreen(key_code); | |
970 case TOGGLE_MAXIMIZED: | |
971 accelerators::ToggleMaximized(); | |
972 return true; | |
973 case WINDOW_POSITION_CENTER: | |
974 return HandlePositionCenter(); | |
975 case SCALE_UI_UP: | |
976 return HandleScaleUI(true /* up */); | |
977 case SCALE_UI_DOWN: | |
978 return HandleScaleUI(false /* down */); | |
979 case SCALE_UI_RESET: | |
980 return HandleScaleReset(); | |
981 case ROTATE_WINDOW: | |
982 return HandleRotateActiveWindow(); | |
983 case ROTATE_SCREEN: | |
984 return HandleRotateScreen(); | |
985 case MAGNIFY_SCREEN_ZOOM_IN: | 913 case MAGNIFY_SCREEN_ZOOM_IN: |
986 return HandleMagnifyScreen(1); | 914 return HandleMagnifyScreen(1); |
987 case MAGNIFY_SCREEN_ZOOM_OUT: | 915 case MAGNIFY_SCREEN_ZOOM_OUT: |
988 return HandleMagnifyScreen(-1); | 916 return HandleMagnifyScreen(-1); |
989 case MEDIA_NEXT_TRACK: | 917 case MEDIA_NEXT_TRACK: |
990 return HandleMediaNextTrack(); | 918 return HandleMediaNextTrack(); |
991 case MEDIA_PLAY_PAUSE: | 919 case MEDIA_PLAY_PAUSE: |
992 return HandleMediaPlayPause(); | 920 return HandleMediaPlayPause(); |
993 case MEDIA_PREV_TRACK: | 921 case MEDIA_PREV_TRACK: |
994 return HandleMediaPrevTrack(); | 922 return HandleMediaPrevTrack(); |
| 923 case NEW_INCOGNITO_WINDOW: |
| 924 return HandleNewIncognitoWindow(); |
| 925 case NEW_TAB: |
| 926 return HandleNewTab(key_code); |
| 927 case NEW_WINDOW: |
| 928 return HandleNewWindow(); |
| 929 case NEXT_IME: |
| 930 HandleNextIme( |
| 931 ime_control_delegate_.get(), previous_event_type, previous_key_code); |
| 932 // NEXT_IME is bound to Alt-Shift key up event. To be consistent with |
| 933 // Windows behavior, do not consume the key event here. |
| 934 return false; |
| 935 case OPEN_FEEDBACK_PAGE: |
| 936 return HandleOpenFeedbackPage(); |
| 937 case PREVIOUS_IME: |
| 938 return HandlePreviousIme(ime_control_delegate_.get(), accelerator); |
| 939 case PRINT_UI_HIERARCHIES: |
| 940 debug::PrintUIHierarchies(); |
| 941 return true; |
| 942 case RESTORE_TAB: |
| 943 return HandleRestoreTab(); |
| 944 case ROTATE_SCREEN: |
| 945 return HandleRotateScreen(); |
| 946 case ROTATE_WINDOW: |
| 947 return HandleRotateActiveWindow(); |
| 948 case SCALE_UI_DOWN: |
| 949 return HandleScaleUI(false /* down */); |
| 950 case SCALE_UI_RESET: |
| 951 return HandleScaleReset(); |
| 952 case SCALE_UI_UP: |
| 953 return HandleScaleUI(true /* up */); |
| 954 case SHOW_KEYBOARD_OVERLAY: |
| 955 return HandleShowKeyboardOverlay(); |
| 956 case SHOW_MESSAGE_CENTER_BUBBLE: |
| 957 return HandleShowMessageCenterBubble(); |
| 958 case SHOW_SYSTEM_TRAY_BUBBLE: |
| 959 return HandleShowSystemTrayBubble(); |
| 960 case SHOW_TASK_MANAGER: |
| 961 return HandleShowTaskManager(); |
| 962 case SWITCH_IME: |
| 963 return HandleSwitchIme(ime_control_delegate_.get(), accelerator); |
| 964 case TAKE_PARTIAL_SCREENSHOT: |
| 965 return HandleTakePartialScreenshot(screenshot_delegate_.get()); |
| 966 case TAKE_SCREENSHOT: |
| 967 return HandleTakeScreenshot(screenshot_delegate_.get()); |
| 968 case TOGGLE_APP_LIST: |
| 969 return HandleToggleAppList( |
| 970 key_code, previous_event_type, previous_key_code, accelerator); |
| 971 case TOGGLE_FULLSCREEN: |
| 972 return HandleToggleFullscreen(key_code); |
| 973 case TOGGLE_MAXIMIZED: |
| 974 accelerators::ToggleMaximized(); |
| 975 return true; |
| 976 case TOGGLE_OVERVIEW: |
| 977 return HandleToggleOverview(accelerator); |
| 978 case VOLUME_DOWN: { |
| 979 ash::VolumeControlDelegate* volume_delegate = |
| 980 shell->system_tray_delegate()->GetVolumeControlDelegate(); |
| 981 return volume_delegate && volume_delegate->HandleVolumeDown(accelerator); |
| 982 } |
| 983 case VOLUME_MUTE: { |
| 984 ash::VolumeControlDelegate* volume_delegate = |
| 985 shell->system_tray_delegate()->GetVolumeControlDelegate(); |
| 986 return volume_delegate && volume_delegate->HandleVolumeMute(accelerator); |
| 987 } |
| 988 case VOLUME_UP: { |
| 989 ash::VolumeControlDelegate* volume_delegate = |
| 990 shell->system_tray_delegate()->GetVolumeControlDelegate(); |
| 991 return volume_delegate && volume_delegate->HandleVolumeUp(accelerator); |
| 992 } |
| 993 case WINDOW_CYCLE_SNAP_DOCK_LEFT: |
| 994 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: |
| 995 return HandleWindowSnapOrDock(action); |
| 996 case WINDOW_MINIMIZE: |
| 997 return HandleWindowMinimize(); |
| 998 case WINDOW_POSITION_CENTER: |
| 999 return HandlePositionCenter(); |
| 1000 #if defined(OS_CHROMEOS) |
| 1001 case DEBUG_ADD_REMOVE_DISPLAY: |
| 1002 return debug::PerformDebugAction(action); |
| 1003 case DISABLE_CAPS_LOCK: |
| 1004 return HandleDisableCapsLock( |
| 1005 key_code, previous_event_type, previous_key_code); |
| 1006 case DISABLE_GPU_WATCHDOG: |
| 1007 Shell::GetInstance()->gpu_support()->DisableGpuWatchdog(); |
| 1008 return true; |
| 1009 case KEYBOARD_BRIGHTNESS_DOWN: |
| 1010 if (keyboard_brightness_control_delegate_) |
| 1011 return keyboard_brightness_control_delegate_-> |
| 1012 HandleKeyboardBrightnessDown(accelerator); |
| 1013 return false; |
| 1014 case KEYBOARD_BRIGHTNESS_UP: |
| 1015 if (keyboard_brightness_control_delegate_) |
| 1016 return keyboard_brightness_control_delegate_-> |
| 1017 HandleKeyboardBrightnessUp(accelerator); |
| 1018 return false; |
| 1019 case LOCK_PRESSED: |
| 1020 case LOCK_RELEASED: |
| 1021 Shell::GetInstance()->power_button_controller()-> |
| 1022 OnLockButtonEvent(action == LOCK_PRESSED, base::TimeTicks()); |
| 1023 return true; |
| 1024 case LOCK_SCREEN: |
| 1025 return HandleLock(key_code); |
| 1026 case OPEN_CROSH: |
| 1027 return HandleCrosh(); |
| 1028 case OPEN_FILE_MANAGER: |
| 1029 return HandleFileManager(); |
995 case POWER_PRESSED: // fallthrough | 1030 case POWER_PRESSED: // fallthrough |
996 case POWER_RELEASED: | 1031 case POWER_RELEASED: |
997 #if defined(OS_CHROMEOS) | |
998 if (!base::SysInfo::IsRunningOnChromeOS()) { | 1032 if (!base::SysInfo::IsRunningOnChromeOS()) { |
999 // There is no powerd in linux desktop, so call the | 1033 // There is no powerd in linux desktop, so call the |
1000 // PowerButtonController here. | 1034 // PowerButtonController here. |
1001 Shell::GetInstance()->power_button_controller()-> | 1035 Shell::GetInstance()->power_button_controller()-> |
1002 OnPowerButtonEvent(action == POWER_PRESSED, base::TimeTicks()); | 1036 OnPowerButtonEvent(action == POWER_PRESSED, base::TimeTicks()); |
1003 } | 1037 } |
1004 #endif | |
1005 // We don't do anything with these at present on the device, | 1038 // We don't do anything with these at present on the device, |
1006 // (power button events are reported to us from powerm via | 1039 // (power button events are reported to us from powerm via |
1007 // D-BUS), but we consume them to prevent them from getting | 1040 // D-BUS), but we consume them to prevent them from getting |
1008 // passed to apps -- see http://crbug.com/146609. | 1041 // passed to apps -- see http://crbug.com/146609. |
1009 return true; | 1042 return true; |
1010 case LOCK_PRESSED: | 1043 case SILENCE_SPOKEN_FEEDBACK: |
1011 case LOCK_RELEASED: | 1044 HandleSilenceSpokenFeedback(); |
1012 Shell::GetInstance()->power_button_controller()-> | 1045 return false; |
1013 OnLockButtonEvent(action == LOCK_PRESSED, base::TimeTicks()); | 1046 case SWAP_PRIMARY_DISPLAY: |
| 1047 return HandleSwapPrimaryDisplay(); |
| 1048 case SWITCH_TO_NEXT_USER: |
| 1049 return HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); |
| 1050 case SWITCH_TO_PREVIOUS_USER: |
| 1051 return HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); |
| 1052 case TOGGLE_CAPS_LOCK: |
| 1053 return HandleToggleCapsLock( |
| 1054 key_code, previous_event_type, previous_key_code); |
| 1055 case TOGGLE_MIRROR_MODE: |
| 1056 return HandleToggleMirrorMode(); |
| 1057 case TOGGLE_SPOKEN_FEEDBACK: |
| 1058 return HandleToggleSpokenFeedback(); |
| 1059 case TOGGLE_TOUCH_VIEW_TESTING: |
| 1060 return HandleToggleTouchViewTesting(); |
| 1061 case TOGGLE_WIFI: |
| 1062 Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi(); |
1014 return true; | 1063 return true; |
1015 default: | 1064 case TOUCH_HUD_CLEAR: |
1016 DCHECK(debug::DebugAcceleratorsEnabled()) | 1065 return HandleTouchHudClear(); |
1017 << "Unhandled action " << action; | 1066 case TOUCH_HUD_MODE_CHANGE: |
| 1067 return HandleTouchHudModeChange(); |
| 1068 case TOUCH_HUD_PROJECTION_TOGGLE: |
| 1069 accelerators::ToggleTouchHudProjection(); |
| 1070 return true; |
| 1071 #else |
| 1072 case DUMMY_FOR_RESERVED: |
| 1073 NOTREACHED(); |
| 1074 return false; |
| 1075 #endif // OS_CHROMEOS |
1018 } | 1076 } |
1019 | 1077 return false; |
1020 // If |action| is a debug action, run it. | |
1021 return debug::PerformDebugAction(action); | |
1022 } | 1078 } |
1023 | 1079 |
1024 AcceleratorController::AcceleratorProcessingRestriction | 1080 AcceleratorController::AcceleratorProcessingRestriction |
1025 AcceleratorController::GetCurrentAcceleratorRestriction() { | |
1026 return GetAcceleratorProcessingRestriction(-1); | |
1027 } | |
1028 | |
1029 AcceleratorController::AcceleratorProcessingRestriction | |
1030 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { | 1081 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { |
1031 ash::Shell* shell = ash::Shell::GetInstance(); | 1082 ash::Shell* shell = ash::Shell::GetInstance(); |
1032 if (!shell->session_state_delegate()->IsActiveUserSessionStarted() && | 1083 if (!shell->session_state_delegate()->IsActiveUserSessionStarted() && |
1033 actions_allowed_at_login_screen_.find(action) == | 1084 actions_allowed_at_login_screen_.find(action) == |
1034 actions_allowed_at_login_screen_.end()) { | 1085 actions_allowed_at_login_screen_.end()) { |
1035 return RESTRICTION_PREVENT_PROCESSING; | 1086 return RESTRICTION_PREVENT_PROCESSING; |
1036 } | 1087 } |
1037 if (shell->session_state_delegate()->IsScreenLocked() && | 1088 if (shell->session_state_delegate()->IsScreenLocked() && |
1038 actions_allowed_at_lock_screen_.find(action) == | 1089 actions_allowed_at_lock_screen_.find(action) == |
1039 actions_allowed_at_lock_screen_.end()) { | 1090 actions_allowed_at_lock_screen_.end()) { |
(...skipping 15 matching lines...) Expand all Loading... |
1055 } | 1106 } |
1056 if (MruWindowTracker::BuildWindowList(false).empty() && | 1107 if (MruWindowTracker::BuildWindowList(false).empty() && |
1057 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 1108 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
1058 Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert( | 1109 Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert( |
1059 ui::A11Y_ALERT_WINDOW_NEEDED); | 1110 ui::A11Y_ALERT_WINDOW_NEEDED); |
1060 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1111 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
1061 } | 1112 } |
1062 return RESTRICTION_NONE; | 1113 return RESTRICTION_NONE; |
1063 } | 1114 } |
1064 | 1115 |
1065 void AcceleratorController::SetBrightnessControlDelegate( | |
1066 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) { | |
1067 brightness_control_delegate_ = brightness_control_delegate.Pass(); | |
1068 } | |
1069 | |
1070 void AcceleratorController::SetImeControlDelegate( | |
1071 scoped_ptr<ImeControlDelegate> ime_control_delegate) { | |
1072 ime_control_delegate_ = ime_control_delegate.Pass(); | |
1073 } | |
1074 | |
1075 void AcceleratorController::SetScreenshotDelegate( | |
1076 scoped_ptr<ScreenshotDelegate> screenshot_delegate) { | |
1077 screenshot_delegate_ = screenshot_delegate.Pass(); | |
1078 } | |
1079 | |
1080 //////////////////////////////////////////////////////////////////////////////// | |
1081 // AcceleratorController, ui::AcceleratorTarget implementation: | |
1082 | |
1083 bool AcceleratorController::AcceleratorPressed( | |
1084 const ui::Accelerator& accelerator) { | |
1085 std::map<ui::Accelerator, int>::const_iterator it = | |
1086 accelerators_.find(accelerator); | |
1087 DCHECK(it != accelerators_.end()); | |
1088 return PerformAction(static_cast<AcceleratorAction>(it->second), accelerator); | |
1089 } | |
1090 | |
1091 void AcceleratorController::RegisterAccelerators( | |
1092 const AcceleratorData accelerators[], | |
1093 size_t accelerators_length) { | |
1094 for (size_t i = 0; i < accelerators_length; ++i) { | |
1095 ui::Accelerator accelerator(accelerators[i].keycode, | |
1096 accelerators[i].modifiers); | |
1097 accelerator.set_type(accelerators[i].trigger_on_press ? | |
1098 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED); | |
1099 Register(accelerator, this); | |
1100 accelerators_.insert( | |
1101 std::make_pair(accelerator, accelerators[i].action)); | |
1102 } | |
1103 } | |
1104 | |
1105 void AcceleratorController::SetKeyboardBrightnessControlDelegate( | 1116 void AcceleratorController::SetKeyboardBrightnessControlDelegate( |
1106 scoped_ptr<KeyboardBrightnessControlDelegate> | 1117 scoped_ptr<KeyboardBrightnessControlDelegate> |
1107 keyboard_brightness_control_delegate) { | 1118 keyboard_brightness_control_delegate) { |
1108 keyboard_brightness_control_delegate_ = | 1119 keyboard_brightness_control_delegate_ = |
1109 keyboard_brightness_control_delegate.Pass(); | 1120 keyboard_brightness_control_delegate.Pass(); |
1110 } | 1121 } |
1111 | 1122 |
1112 bool AcceleratorController::CanHandleAccelerators() const { | |
1113 return true; | |
1114 } | |
1115 | |
1116 } // namespace ash | 1123 } // namespace ash |
OLD | NEW |