| 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 | |
| 113 void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { | 82 void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { |
| 114 if (accelerator.key_code() == ui::VKEY_TAB) | 83 if (accelerator.key_code() == ui::VKEY_TAB) |
| 115 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); | 84 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); |
| 116 | 85 |
| 117 Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow( | 86 Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow( |
| 118 WindowCycleController::BACKWARD); | 87 WindowCycleController::BACKWARD); |
| 119 } | 88 } |
| 120 | 89 |
| 121 void HandleCycleForwardMRU(const ui::Accelerator& accelerator) { | 90 void HandleCycleForwardMRU(const ui::Accelerator& accelerator) { |
| 122 if (accelerator.key_code() == ui::VKEY_TAB) | 91 if (accelerator.key_code() == ui::VKEY_TAB) |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 if (restriction != RESTRICTION_NONE) | 842 if (restriction != RESTRICTION_NONE) |
| 874 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 843 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 875 | 844 |
| 876 const ui::Accelerator& previous_accelerator = | 845 const ui::Accelerator& previous_accelerator = |
| 877 accelerator_history_->previous_accelerator(); | 846 accelerator_history_->previous_accelerator(); |
| 878 | 847 |
| 879 // True should be returned if running |action| does something. Otherwise, | 848 // True should be returned if running |action| does something. Otherwise, |
| 880 // false should be returned to give the web contents a chance at handling the | 849 // false should be returned to give the web contents a chance at handling the |
| 881 // accelerator. | 850 // accelerator. |
| 882 switch (action) { | 851 switch (action) { |
| 883 case ACCESSIBLE_FOCUS_NEXT: | |
| 884 case ACCESSIBLE_FOCUS_PREVIOUS: | |
| 885 return CanHandleAccessibleFocusCycle(); | |
| 886 case DEBUG_PRINT_LAYER_HIERARCHY: | 852 case DEBUG_PRINT_LAYER_HIERARCHY: |
| 887 case DEBUG_PRINT_VIEW_HIERARCHY: | 853 case DEBUG_PRINT_VIEW_HIERARCHY: |
| 888 case DEBUG_PRINT_WINDOW_HIERARCHY: | 854 case DEBUG_PRINT_WINDOW_HIERARCHY: |
| 889 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: | 855 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: |
| 890 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: | 856 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: |
| 891 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: | 857 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
| 892 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: | 858 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: |
| 893 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: | 859 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: |
| 894 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: | 860 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: |
| 895 return debug::DebugAcceleratorsEnabled(); | 861 return debug::DebugAcceleratorsEnabled(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 const ui::Accelerator& accelerator) { | 972 const ui::Accelerator& accelerator) { |
| 1007 AcceleratorProcessingRestriction restriction = | 973 AcceleratorProcessingRestriction restriction = |
| 1008 GetAcceleratorProcessingRestriction(action); | 974 GetAcceleratorProcessingRestriction(action); |
| 1009 if (restriction != RESTRICTION_NONE) | 975 if (restriction != RESTRICTION_NONE) |
| 1010 return; | 976 return; |
| 1011 | 977 |
| 1012 // If your accelerator invokes more than one line of code, please either | 978 // If your accelerator invokes more than one line of code, please either |
| 1013 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE | 979 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE |
| 1014 // below) or pull it into a HandleFoo() function above. | 980 // below) or pull it into a HandleFoo() function above. |
| 1015 switch (action) { | 981 switch (action) { |
| 1016 case ACCESSIBLE_FOCUS_NEXT: | |
| 1017 HandleAccessibleFocusCycle(false); | |
| 1018 break; | |
| 1019 case ACCESSIBLE_FOCUS_PREVIOUS: | |
| 1020 HandleAccessibleFocusCycle(true); | |
| 1021 break; | |
| 1022 case CYCLE_BACKWARD_MRU: | 982 case CYCLE_BACKWARD_MRU: |
| 1023 HandleCycleBackwardMRU(accelerator); | 983 HandleCycleBackwardMRU(accelerator); |
| 1024 break; | 984 break; |
| 1025 case CYCLE_FORWARD_MRU: | 985 case CYCLE_FORWARD_MRU: |
| 1026 HandleCycleForwardMRU(accelerator); | 986 HandleCycleForwardMRU(accelerator); |
| 1027 break; | 987 break; |
| 1028 case DEBUG_PRINT_LAYER_HIERARCHY: | 988 case DEBUG_PRINT_LAYER_HIERARCHY: |
| 1029 case DEBUG_PRINT_VIEW_HIERARCHY: | 989 case DEBUG_PRINT_VIEW_HIERARCHY: |
| 1030 case DEBUG_PRINT_WINDOW_HIERARCHY: | 990 case DEBUG_PRINT_WINDOW_HIERARCHY: |
| 1031 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: | 991 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 } | 1288 } |
| 1329 | 1289 |
| 1330 void AcceleratorController::SetKeyboardBrightnessControlDelegate( | 1290 void AcceleratorController::SetKeyboardBrightnessControlDelegate( |
| 1331 scoped_ptr<KeyboardBrightnessControlDelegate> | 1291 scoped_ptr<KeyboardBrightnessControlDelegate> |
| 1332 keyboard_brightness_control_delegate) { | 1292 keyboard_brightness_control_delegate) { |
| 1333 keyboard_brightness_control_delegate_ = | 1293 keyboard_brightness_control_delegate_ = |
| 1334 keyboard_brightness_control_delegate.Pass(); | 1294 keyboard_brightness_control_delegate.Pass(); |
| 1335 } | 1295 } |
| 1336 | 1296 |
| 1337 } // namespace ash | 1297 } // namespace ash |
| OLD | NEW |