| 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 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "base/sys_info.h" | 72 #include "base/sys_info.h" |
| 73 #include "ui/base/ime/chromeos/ime_keyboard.h" | 73 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 74 #include "ui/base/ime/chromeos/input_method_manager.h" | 74 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 75 #endif // defined(OS_CHROMEOS) | 75 #endif // defined(OS_CHROMEOS) |
| 76 | 76 |
| 77 namespace ash { | 77 namespace ash { |
| 78 namespace { | 78 namespace { |
| 79 | 79 |
| 80 using base::UserMetricsAction; | 80 using base::UserMetricsAction; |
| 81 | 81 |
| 82 bool CanHandleAccessibleFocusCycle() { |
| 83 if (!Shell::GetInstance()->accessibility_delegate()-> |
| 84 IsSpokenFeedbackEnabled()) { |
| 85 return false; |
| 86 } |
| 87 aura::Window* active_window = ash::wm::GetActiveWindow(); |
| 88 if (!active_window) |
| 89 return false; |
| 90 views::Widget* widget = |
| 91 views::Widget::GetWidgetForNativeWindow(active_window); |
| 92 if (!widget) |
| 93 return false; |
| 94 views::FocusManager* focus_manager = widget->GetFocusManager(); |
| 95 if (!focus_manager) |
| 96 return false; |
| 97 views::View* view = focus_manager->GetFocusedView(); |
| 98 return view && strcmp(view->GetClassName(), views::WebView::kViewClassName); |
| 99 } |
| 100 |
| 101 void HandleAccessibleFocusCycle(bool reverse) { |
| 102 if (reverse) |
| 103 base::RecordAction(UserMetricsAction("Accel_Accessible_Focus_Previous")); |
| 104 else |
| 105 base::RecordAction(UserMetricsAction("Accel_Accessible_Focus_Next")); |
| 106 |
| 107 aura::Window* active_window = ash::wm::GetActiveWindow(); |
| 108 views::Widget* widget = |
| 109 views::Widget::GetWidgetForNativeWindow(active_window); |
| 110 widget->GetFocusManager()->AdvanceFocus(reverse); |
| 111 } |
| 112 |
| 82 void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { | 113 void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { |
| 83 if (accelerator.key_code() == ui::VKEY_TAB) | 114 if (accelerator.key_code() == ui::VKEY_TAB) |
| 84 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); | 115 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); |
| 85 | 116 |
| 86 Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow( | 117 Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow( |
| 87 WindowCycleController::BACKWARD); | 118 WindowCycleController::BACKWARD); |
| 88 } | 119 } |
| 89 | 120 |
| 90 void HandleCycleForwardMRU(const ui::Accelerator& accelerator) { | 121 void HandleCycleForwardMRU(const ui::Accelerator& accelerator) { |
| 91 if (accelerator.key_code() == ui::VKEY_TAB) | 122 if (accelerator.key_code() == ui::VKEY_TAB) |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 if (restriction != RESTRICTION_NONE) | 873 if (restriction != RESTRICTION_NONE) |
| 843 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 874 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 844 | 875 |
| 845 const ui::Accelerator& previous_accelerator = | 876 const ui::Accelerator& previous_accelerator = |
| 846 accelerator_history_->previous_accelerator(); | 877 accelerator_history_->previous_accelerator(); |
| 847 | 878 |
| 848 // True should be returned if running |action| does something. Otherwise, | 879 // True should be returned if running |action| does something. Otherwise, |
| 849 // false should be returned to give the web contents a chance at handling the | 880 // false should be returned to give the web contents a chance at handling the |
| 850 // accelerator. | 881 // accelerator. |
| 851 switch (action) { | 882 switch (action) { |
| 883 case ACCESSIBLE_FOCUS_NEXT: |
| 884 case ACCESSIBLE_FOCUS_PREVIOUS: |
| 885 return CanHandleAccessibleFocusCycle(); |
| 852 case DEBUG_PRINT_LAYER_HIERARCHY: | 886 case DEBUG_PRINT_LAYER_HIERARCHY: |
| 853 case DEBUG_PRINT_VIEW_HIERARCHY: | 887 case DEBUG_PRINT_VIEW_HIERARCHY: |
| 854 case DEBUG_PRINT_WINDOW_HIERARCHY: | 888 case DEBUG_PRINT_WINDOW_HIERARCHY: |
| 855 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: | 889 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: |
| 856 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: | 890 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: |
| 857 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: | 891 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
| 858 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: | 892 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: |
| 859 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: | 893 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: |
| 860 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: | 894 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: |
| 861 return debug::DebugAcceleratorsEnabled(); | 895 return debug::DebugAcceleratorsEnabled(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 const ui::Accelerator& accelerator) { | 1006 const ui::Accelerator& accelerator) { |
| 973 AcceleratorProcessingRestriction restriction = | 1007 AcceleratorProcessingRestriction restriction = |
| 974 GetAcceleratorProcessingRestriction(action); | 1008 GetAcceleratorProcessingRestriction(action); |
| 975 if (restriction != RESTRICTION_NONE) | 1009 if (restriction != RESTRICTION_NONE) |
| 976 return; | 1010 return; |
| 977 | 1011 |
| 978 // If your accelerator invokes more than one line of code, please either | 1012 // If your accelerator invokes more than one line of code, please either |
| 979 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE | 1013 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE |
| 980 // below) or pull it into a HandleFoo() function above. | 1014 // below) or pull it into a HandleFoo() function above. |
| 981 switch (action) { | 1015 switch (action) { |
| 1016 case ACCESSIBLE_FOCUS_NEXT: |
| 1017 HandleAccessibleFocusCycle(false); |
| 1018 break; |
| 1019 case ACCESSIBLE_FOCUS_PREVIOUS: |
| 1020 HandleAccessibleFocusCycle(true); |
| 1021 break; |
| 982 case CYCLE_BACKWARD_MRU: | 1022 case CYCLE_BACKWARD_MRU: |
| 983 HandleCycleBackwardMRU(accelerator); | 1023 HandleCycleBackwardMRU(accelerator); |
| 984 break; | 1024 break; |
| 985 case CYCLE_FORWARD_MRU: | 1025 case CYCLE_FORWARD_MRU: |
| 986 HandleCycleForwardMRU(accelerator); | 1026 HandleCycleForwardMRU(accelerator); |
| 987 break; | 1027 break; |
| 988 case DEBUG_PRINT_LAYER_HIERARCHY: | 1028 case DEBUG_PRINT_LAYER_HIERARCHY: |
| 989 case DEBUG_PRINT_VIEW_HIERARCHY: | 1029 case DEBUG_PRINT_VIEW_HIERARCHY: |
| 990 case DEBUG_PRINT_WINDOW_HIERARCHY: | 1030 case DEBUG_PRINT_WINDOW_HIERARCHY: |
| 991 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: | 1031 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 } | 1328 } |
| 1289 | 1329 |
| 1290 void AcceleratorController::SetKeyboardBrightnessControlDelegate( | 1330 void AcceleratorController::SetKeyboardBrightnessControlDelegate( |
| 1291 scoped_ptr<KeyboardBrightnessControlDelegate> | 1331 scoped_ptr<KeyboardBrightnessControlDelegate> |
| 1292 keyboard_brightness_control_delegate) { | 1332 keyboard_brightness_control_delegate) { |
| 1293 keyboard_brightness_control_delegate_ = | 1333 keyboard_brightness_control_delegate_ = |
| 1294 keyboard_brightness_control_delegate.Pass(); | 1334 keyboard_brightness_control_delegate.Pass(); |
| 1295 } | 1335 } |
| 1296 | 1336 |
| 1297 } // namespace ash | 1337 } // namespace ash |
| OLD | NEW |