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 <iostream> | 9 #include <iostream> |
10 #include <string> | 10 #include <string> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 bool DebugShortcutsEnabled() { | 80 bool DebugShortcutsEnabled() { |
81 #if defined(NDEBUG) | 81 #if defined(NDEBUG) |
82 return CommandLine::ForCurrentProcess()->HasSwitch( | 82 return CommandLine::ForCurrentProcess()->HasSwitch( |
83 switches::kAshDebugShortcuts); | 83 switches::kAshDebugShortcuts); |
84 #else | 84 #else |
85 return true; | 85 return true; |
86 #endif | 86 #endif |
87 } | 87 } |
88 | 88 |
| 89 bool OverviewEnabled() { |
| 90 return !CommandLine::ForCurrentProcess()->HasSwitch( |
| 91 switches::kAshDisableOverviewMode); |
| 92 } |
| 93 |
89 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, | 94 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, |
90 bool is_alt_down) { | 95 bool is_alt_down) { |
91 Shell::GetInstance()-> | 96 Shell::GetInstance()-> |
92 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down); | 97 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down); |
93 // Always report we handled the key, even if the window didn't change. | 98 // Always report we handled the key, even if the window didn't change. |
94 return true; | 99 return true; |
95 } | 100 } |
96 | 101 |
97 bool HandleCycleWindowOverviewMRU(WindowSelector::Direction direction) { | 102 bool HandleCycleWindowOverviewMRU(WindowSelector::Direction direction) { |
98 Shell::GetInstance()-> | 103 Shell::GetInstance()-> |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent | 522 // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent |
518 // and BrowserView::HandleKeyboardEvent, for a single accelerator press. | 523 // and BrowserView::HandleKeyboardEvent, for a single accelerator press. |
519 switch (action) { | 524 switch (action) { |
520 case ACCESSIBLE_FOCUS_NEXT: | 525 case ACCESSIBLE_FOCUS_NEXT: |
521 return HandleAccessibleFocusCycle(false); | 526 return HandleAccessibleFocusCycle(false); |
522 case ACCESSIBLE_FOCUS_PREVIOUS: | 527 case ACCESSIBLE_FOCUS_PREVIOUS: |
523 return HandleAccessibleFocusCycle(true); | 528 return HandleAccessibleFocusCycle(true); |
524 case CYCLE_BACKWARD_MRU: | 529 case CYCLE_BACKWARD_MRU: |
525 if (key_code == ui::VKEY_TAB) | 530 if (key_code == ui::VKEY_TAB) |
526 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_TAB); | 531 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_TAB); |
527 if (CommandLine::ForCurrentProcess()->HasSwitch( | 532 if (OverviewEnabled()) |
528 switches::kAshEnableOverviewMode)) { | |
529 return HandleCycleWindowOverviewMRU(WindowSelector::BACKWARD); | 533 return HandleCycleWindowOverviewMRU(WindowSelector::BACKWARD); |
530 } | |
531 return HandleCycleWindowMRU(WindowCycleController::BACKWARD, | 534 return HandleCycleWindowMRU(WindowCycleController::BACKWARD, |
532 accelerator.IsAltDown()); | 535 accelerator.IsAltDown()); |
533 case CYCLE_FORWARD_MRU: | 536 case CYCLE_FORWARD_MRU: |
534 if (key_code == ui::VKEY_TAB) | 537 if (key_code == ui::VKEY_TAB) |
535 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_TAB); | 538 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_TAB); |
536 if (CommandLine::ForCurrentProcess()->HasSwitch( | 539 if (OverviewEnabled()) |
537 switches::kAshEnableOverviewMode)) { | |
538 return HandleCycleWindowOverviewMRU(WindowSelector::FORWARD); | 540 return HandleCycleWindowOverviewMRU(WindowSelector::FORWARD); |
539 } | |
540 return HandleCycleWindowMRU(WindowCycleController::FORWARD, | 541 return HandleCycleWindowMRU(WindowCycleController::FORWARD, |
541 accelerator.IsAltDown()); | 542 accelerator.IsAltDown()); |
542 case CYCLE_BACKWARD_LINEAR: | 543 case CYCLE_BACKWARD_LINEAR: |
543 if (CommandLine::ForCurrentProcess()->HasSwitch( | 544 if (OverviewEnabled()) { |
544 switches::kAshEnableOverviewMode)) { | |
545 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_OVERVIEW_F5); | 545 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_OVERVIEW_F5); |
546 ToggleOverviewMode(); | 546 ToggleOverviewMode(); |
547 return true; | 547 return true; |
548 } | 548 } |
549 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP1) | 549 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP1) |
550 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_F5); | 550 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_F5); |
551 HandleCycleWindowLinear(CYCLE_BACKWARD); | 551 HandleCycleWindowLinear(CYCLE_BACKWARD); |
552 return true; | 552 return true; |
553 case CYCLE_FORWARD_LINEAR: | 553 case CYCLE_FORWARD_LINEAR: |
554 if (CommandLine::ForCurrentProcess()->HasSwitch( | 554 if (OverviewEnabled()) { |
555 switches::kAshEnableOverviewMode)) { | |
556 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_OVERVIEW_F5); | 555 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_OVERVIEW_F5); |
557 ToggleOverviewMode(); | 556 ToggleOverviewMode(); |
558 return true; | 557 return true; |
559 } | 558 } |
560 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP1) | 559 if (key_code == ui::VKEY_MEDIA_LAUNCH_APP1) |
561 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_F5); | 560 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_F5); |
562 HandleCycleWindowLinear(CYCLE_FORWARD); | 561 HandleCycleWindowLinear(CYCLE_FORWARD); |
563 return true; | 562 return true; |
564 #if defined(OS_CHROMEOS) | 563 #if defined(OS_CHROMEOS) |
565 case ADD_REMOVE_DISPLAY: | 564 case ADD_REMOVE_DISPLAY: |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 keyboard_brightness_control_delegate) { | 998 keyboard_brightness_control_delegate) { |
1000 keyboard_brightness_control_delegate_ = | 999 keyboard_brightness_control_delegate_ = |
1001 keyboard_brightness_control_delegate.Pass(); | 1000 keyboard_brightness_control_delegate.Pass(); |
1002 } | 1001 } |
1003 | 1002 |
1004 bool AcceleratorController::CanHandleAccelerators() const { | 1003 bool AcceleratorController::CanHandleAccelerators() const { |
1005 return true; | 1004 return true; |
1006 } | 1005 } |
1007 | 1006 |
1008 } // namespace ash | 1007 } // namespace ash |
OLD | NEW |