Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 | 47 |
| 48 KeyRewriter(); | 48 KeyRewriter(); |
| 49 virtual ~KeyRewriter(); | 49 virtual ~KeyRewriter(); |
| 50 | 50 |
| 51 // Calls DeviceAddedInternal. | 51 // Calls DeviceAddedInternal. |
| 52 DeviceType DeviceAddedForTesting(int device_id, | 52 DeviceType DeviceAddedForTesting(int device_id, |
| 53 const std::string& device_name); | 53 const std::string& device_name); |
| 54 // Calls Rewrite. | 54 // Calls Rewrite. |
| 55 void RewriteForTesting(aura::KeyEvent* event); | 55 void RewriteForTesting(aura::KeyEvent* event); |
| 56 | 56 |
| 57 // Calls RewriteLocatedEvent. | |
| 58 void RewriteLocatedEventForTesting(aura::LocatedEvent* event); | |
| 59 | |
| 57 const std::map<int, DeviceType>& device_id_to_type_for_testing() const { | 60 const std::map<int, DeviceType>& device_id_to_type_for_testing() const { |
| 58 return device_id_to_type_; | 61 return device_id_to_type_; |
| 59 } | 62 } |
| 60 void set_last_device_id_for_testing(int device_id) { | 63 void set_last_device_id_for_testing(int device_id) { |
| 61 last_device_id_ = device_id; | 64 last_device_id_ = device_id; |
| 62 } | 65 } |
| 63 void set_pref_service_for_testing(const PrefService* pref_service) { | 66 void set_pref_service_for_testing(const PrefService* pref_service) { |
| 64 pref_service_ = pref_service; | 67 pref_service_ = pref_service; |
| 65 } | 68 } |
| 66 #if defined(OS_CHROMEOS) | 69 #if defined(OS_CHROMEOS) |
| 67 void set_xkeyboard_for_testing(chromeos::input_method::XKeyboard* xkeyboard) { | 70 void set_xkeyboard_for_testing(chromeos::input_method::XKeyboard* xkeyboard) { |
| 68 xkeyboard_ = xkeyboard; | 71 xkeyboard_ = xkeyboard; |
| 69 } | 72 } |
| 70 #endif | 73 #endif |
| 71 | 74 |
| 72 // Gets DeviceType from the |device_name|. | 75 // Gets DeviceType from the |device_name|. |
| 73 static DeviceType GetDeviceType(const std::string& device_name); | 76 static DeviceType GetDeviceType(const std::string& device_name); |
| 74 | 77 |
| 75 private: | 78 private: |
| 76 // ash::KeyRewriterDelegate overrides: | 79 // ash::KeyRewriterDelegate overrides: |
| 77 virtual ash::KeyRewriterDelegate::Action RewriteOrFilterKeyEvent( | 80 virtual ash::KeyRewriterDelegate::Action RewriteOrFilterKeyEvent( |
| 78 aura::KeyEvent* event) OVERRIDE; | 81 aura::KeyEvent* event) OVERRIDE; |
| 82 virtual ash::KeyRewriterDelegate::Action RewriteOrFilterLocatedEvent( | |
| 83 aura::LocatedEvent* event) OVERRIDE; | |
| 79 | 84 |
| 80 // aura::RootWindowObserver overrides: | 85 // aura::RootWindowObserver overrides: |
| 81 virtual void OnKeyboardMappingChanged(const aura::RootWindow* root) OVERRIDE; | 86 virtual void OnKeyboardMappingChanged(const aura::RootWindow* root) OVERRIDE; |
| 82 | 87 |
| 83 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
| 84 // chromeos::DeviceHierarchyObserver overrides: | 89 // chromeos::DeviceHierarchyObserver overrides: |
| 85 virtual void DeviceHierarchyChanged() OVERRIDE {} | 90 virtual void DeviceHierarchyChanged() OVERRIDE {} |
| 86 virtual void DeviceAdded(int device_id) OVERRIDE; | 91 virtual void DeviceAdded(int device_id) OVERRIDE; |
| 87 virtual void DeviceRemoved(int device_id) OVERRIDE; | 92 virtual void DeviceRemoved(int device_id) OVERRIDE; |
| 88 virtual void DeviceKeyPressedOrReleased(int device_id) OVERRIDE; | 93 virtual void DeviceKeyPressedOrReleased(int device_id) OVERRIDE; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 105 bool RewriteNumPadKeys(aura::KeyEvent* event); | 110 bool RewriteNumPadKeys(aura::KeyEvent* event); |
| 106 | 111 |
| 107 // Rewrites Backspace and Arrow keys following the Chrome OS keyboard spec. | 112 // Rewrites Backspace and Arrow keys following the Chrome OS keyboard spec. |
| 108 // * Alt+Backspace -> Delete | 113 // * Alt+Backspace -> Delete |
| 109 // * Alt+Up -> Prior (aka PageUp) | 114 // * Alt+Up -> Prior (aka PageUp) |
| 110 // * Alt+Down -> Next (aka PageDown) | 115 // * Alt+Down -> Next (aka PageDown) |
| 111 // * Ctrl+Alt+Up -> Home | 116 // * Ctrl+Alt+Up -> Home |
| 112 // * Ctrl+Alt+Down -> End | 117 // * Ctrl+Alt+Down -> End |
| 113 bool RewriteBackspaceAndArrowKeys(aura::KeyEvent* event); | 118 bool RewriteBackspaceAndArrowKeys(aura::KeyEvent* event); |
| 114 | 119 |
| 120 // Rewrites the located |event|. | |
| 121 void RewriteLocatedEvent(aura::LocatedEvent* event); | |
| 122 | |
| 115 // Overwrites |event| with the keycodes and flags. | 123 // Overwrites |event| with the keycodes and flags. |
| 116 void OverwriteEvent(aura::KeyEvent* event, | 124 void OverwriteEvent(aura::KeyEvent* event, |
| 117 unsigned int new_native_keycode, | 125 unsigned int new_native_keycode, |
| 118 unsigned int new_native_state, | 126 unsigned int new_native_state, |
| 119 ui::KeyboardCode new_keycode, | 127 ui::KeyboardCode new_keycode, |
| 120 int new_flags); | 128 int new_flags); |
| 121 | 129 |
| 122 // Checks the type of the |device_name|, and inserts a new entry to | 130 // Checks the type of the |device_name|, and inserts a new entry to |
| 123 // |device_id_to_type_|. | 131 // |device_id_to_type_|. |
| 124 DeviceType DeviceAddedInternal(int device_id, const std::string& device_name); | 132 DeviceType DeviceAddedInternal(int device_id, const std::string& device_name); |
| 125 | 133 |
| 126 // Returns true if |last_device_id_| is Apple's. | 134 // Returns true if |last_device_id_| is Apple's. |
| 127 bool IsAppleKeyboard() const; | 135 bool IsAppleKeyboard() const; |
| 128 | 136 |
| 137 // Remaps |original_flags| to |remapped_flags|, |original_native_modifiers| to | |
|
Daniel Erat
2012/07/09 18:18:28
nit: s/,/ and/
Yusuke Sato
2012/07/09 20:36:50
Done.
| |
| 138 // |remapped_native_modifiers| following the current user prefs. | |
| 139 void GetRemappedModifierMasks(int original_flags, | |
| 140 unsigned int original_native_modifiers, | |
| 141 int* remapped_flags, | |
| 142 unsigned int* remapped_native_modifiers) const; | |
| 143 | |
| 129 std::map<int, DeviceType> device_id_to_type_; | 144 std::map<int, DeviceType> device_id_to_type_; |
| 130 int last_device_id_; | 145 int last_device_id_; |
| 131 | 146 |
| 132 #if defined(OS_CHROMEOS) | 147 #if defined(OS_CHROMEOS) |
| 133 // X keycodes corresponding to various keysyms. | 148 // X keycodes corresponding to various keysyms. |
| 134 unsigned int control_l_xkeycode_; | 149 unsigned int control_l_xkeycode_; |
| 135 unsigned int control_r_xkeycode_; | 150 unsigned int control_r_xkeycode_; |
| 136 unsigned int alt_l_xkeycode_; | 151 unsigned int alt_l_xkeycode_; |
| 137 unsigned int alt_r_xkeycode_; | 152 unsigned int alt_r_xkeycode_; |
| 138 unsigned int meta_l_xkeycode_; | 153 unsigned int meta_l_xkeycode_; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 159 | 174 |
| 160 chromeos::input_method::XKeyboard* xkeyboard_; // for testing. | 175 chromeos::input_method::XKeyboard* xkeyboard_; // for testing. |
| 161 #endif | 176 #endif |
| 162 | 177 |
| 163 const PrefService* pref_service_; // for testing. | 178 const PrefService* pref_service_; // for testing. |
| 164 | 179 |
| 165 DISALLOW_COPY_AND_ASSIGN(KeyRewriter); | 180 DISALLOW_COPY_AND_ASSIGN(KeyRewriter); |
| 166 }; | 181 }; |
| 167 | 182 |
| 168 #endif // CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_ | 183 #endif // CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_ |
| OLD | NEW |