| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_EVENTS_EVENT_REWRITER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <set> | 10 #include <set> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
| 17 #include "ui/events/event_rewriter.h" | 17 #include "ui/events/event_rewriter.h" |
| 18 #include "ui/events/keycodes/dom/dom_key.h" | 18 #include "ui/events/keycodes/dom/dom_key.h" |
| 19 | 19 |
| 20 class PrefService; | 20 class PrefService; |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ash { |
| 23 class StickyKeysController; | 23 class StickyKeysController; |
| 24 } | 24 } |
| 25 | 25 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 explicit EventRewriter(ash::StickyKeysController* sticky_keys_controller); | 65 explicit EventRewriter(ash::StickyKeysController* sticky_keys_controller); |
| 66 ~EventRewriter() override; | 66 ~EventRewriter() override; |
| 67 | 67 |
| 68 // Calls KeyboardDeviceAddedInternal. | 68 // Calls KeyboardDeviceAddedInternal. |
| 69 DeviceType KeyboardDeviceAddedForTesting(int device_id, | 69 DeviceType KeyboardDeviceAddedForTesting(int device_id, |
| 70 const std::string& device_name); | 70 const std::string& device_name); |
| 71 | 71 |
| 72 // Calls RewriteMouseEvent(). | 72 // Calls RewriteMouseEvent(). |
| 73 void RewriteMouseButtonEventForTesting( | 73 void RewriteMouseButtonEventForTesting( |
| 74 const ui::MouseEvent& event, | 74 const ui::MouseEvent& event, |
| 75 scoped_ptr<ui::Event>* rewritten_event); | 75 std::unique_ptr<ui::Event>* rewritten_event); |
| 76 | 76 |
| 77 const std::map<int, DeviceType>& device_id_to_type_for_testing() const { | 77 const std::map<int, DeviceType>& device_id_to_type_for_testing() const { |
| 78 return device_id_to_type_; | 78 return device_id_to_type_; |
| 79 } | 79 } |
| 80 void set_last_keyboard_device_id_for_testing(int device_id) { | 80 void set_last_keyboard_device_id_for_testing(int device_id) { |
| 81 last_keyboard_device_id_ = device_id; | 81 last_keyboard_device_id_ = device_id; |
| 82 } | 82 } |
| 83 void set_pref_service_for_testing(const PrefService* pref_service) { | 83 void set_pref_service_for_testing(const PrefService* pref_service) { |
| 84 pref_service_for_testing_ = pref_service; | 84 pref_service_for_testing_ = pref_service; |
| 85 } | 85 } |
| 86 void set_ime_keyboard_for_testing( | 86 void set_ime_keyboard_for_testing( |
| 87 chromeos::input_method::ImeKeyboard* ime_keyboard) { | 87 chromeos::input_method::ImeKeyboard* ime_keyboard) { |
| 88 ime_keyboard_for_testing_ = ime_keyboard; | 88 ime_keyboard_for_testing_ = ime_keyboard; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // EventRewriter overrides: | 91 // EventRewriter overrides: |
| 92 ui::EventRewriteStatus RewriteEvent( | 92 ui::EventRewriteStatus RewriteEvent( |
| 93 const ui::Event& event, | 93 const ui::Event& event, |
| 94 scoped_ptr<ui::Event>* rewritten_event) override; | 94 std::unique_ptr<ui::Event>* rewritten_event) override; |
| 95 ui::EventRewriteStatus NextDispatchEvent( | 95 ui::EventRewriteStatus NextDispatchEvent( |
| 96 const ui::Event& last_event, | 96 const ui::Event& last_event, |
| 97 scoped_ptr<ui::Event>* new_event) override; | 97 std::unique_ptr<ui::Event>* new_event) override; |
| 98 | 98 |
| 99 // Generate a new key event from an original key event and the replacement | 99 // Generate a new key event from an original key event and the replacement |
| 100 // state determined by a key rewriter. | 100 // state determined by a key rewriter. |
| 101 static void BuildRewrittenKeyEvent(const ui::KeyEvent& key_event, | 101 static void BuildRewrittenKeyEvent( |
| 102 const MutableKeyState& state, | 102 const ui::KeyEvent& key_event, |
| 103 scoped_ptr<ui::Event>* rewritten_event); | 103 const MutableKeyState& state, |
| 104 std::unique_ptr<ui::Event>* rewritten_event); |
| 104 | 105 |
| 105 private: | 106 private: |
| 106 void DeviceKeyPressedOrReleased(int device_id); | 107 void DeviceKeyPressedOrReleased(int device_id); |
| 107 | 108 |
| 108 // Returns the PrefService that should be used. | 109 // Returns the PrefService that should be used. |
| 109 const PrefService* GetPrefService() const; | 110 const PrefService* GetPrefService() const; |
| 110 | 111 |
| 111 // Adds a device to |device_id_to_type_|. | 112 // Adds a device to |device_id_to_type_|. |
| 112 DeviceType KeyboardDeviceAdded(int device_id); | 113 DeviceType KeyboardDeviceAdded(int device_id); |
| 113 | 114 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 133 | 134 |
| 134 // Given modifier flags |original_flags|, returns the remapped modifiers | 135 // Given modifier flags |original_flags|, returns the remapped modifiers |
| 135 // according to user preferences and/or event properties. | 136 // according to user preferences and/or event properties. |
| 136 int GetRemappedModifierMasks(const PrefService& pref_service, | 137 int GetRemappedModifierMasks(const PrefService& pref_service, |
| 137 const ui::Event& event, | 138 const ui::Event& event, |
| 138 int original_flags) const; | 139 int original_flags) const; |
| 139 | 140 |
| 140 // Rewrite a particular kind of event. | 141 // Rewrite a particular kind of event. |
| 141 ui::EventRewriteStatus RewriteKeyEvent( | 142 ui::EventRewriteStatus RewriteKeyEvent( |
| 142 const ui::KeyEvent& key_event, | 143 const ui::KeyEvent& key_event, |
| 143 scoped_ptr<ui::Event>* rewritten_event); | 144 std::unique_ptr<ui::Event>* rewritten_event); |
| 144 ui::EventRewriteStatus RewriteMouseButtonEvent( | 145 ui::EventRewriteStatus RewriteMouseButtonEvent( |
| 145 const ui::MouseEvent& mouse_event, | 146 const ui::MouseEvent& mouse_event, |
| 146 scoped_ptr<ui::Event>* rewritten_event); | 147 std::unique_ptr<ui::Event>* rewritten_event); |
| 147 ui::EventRewriteStatus RewriteMouseWheelEvent( | 148 ui::EventRewriteStatus RewriteMouseWheelEvent( |
| 148 const ui::MouseWheelEvent& mouse_event, | 149 const ui::MouseWheelEvent& mouse_event, |
| 149 scoped_ptr<ui::Event>* rewritten_event); | 150 std::unique_ptr<ui::Event>* rewritten_event); |
| 150 ui::EventRewriteStatus RewriteTouchEvent( | 151 ui::EventRewriteStatus RewriteTouchEvent( |
| 151 const ui::TouchEvent& touch_event, | 152 const ui::TouchEvent& touch_event, |
| 152 scoped_ptr<ui::Event>* rewritten_event); | 153 std::unique_ptr<ui::Event>* rewritten_event); |
| 153 ui::EventRewriteStatus RewriteScrollEvent( | 154 ui::EventRewriteStatus RewriteScrollEvent( |
| 154 const ui::ScrollEvent& scroll_event, | 155 const ui::ScrollEvent& scroll_event, |
| 155 scoped_ptr<ui::Event>* rewritten_event); | 156 std::unique_ptr<ui::Event>* rewritten_event); |
| 156 | 157 |
| 157 // Rewriter phases. These can inspect the original |event|, but operate using | 158 // Rewriter phases. These can inspect the original |event|, but operate using |
| 158 // the current |state|, which may have been modified by previous phases. | 159 // the current |state|, which may have been modified by previous phases. |
| 159 bool RewriteModifierKeys(const ui::KeyEvent& event, MutableKeyState* state); | 160 bool RewriteModifierKeys(const ui::KeyEvent& event, MutableKeyState* state); |
| 160 void RewriteNumPadKeys(const ui::KeyEvent& event, MutableKeyState* state); | 161 void RewriteNumPadKeys(const ui::KeyEvent& event, MutableKeyState* state); |
| 161 void RewriteExtendedKeys(const ui::KeyEvent& event, MutableKeyState* state); | 162 void RewriteExtendedKeys(const ui::KeyEvent& event, MutableKeyState* state); |
| 162 void RewriteFunctionKeys(const ui::KeyEvent& event, MutableKeyState* state); | 163 void RewriteFunctionKeys(const ui::KeyEvent& event, MutableKeyState* state); |
| 163 void RewriteLocatedEvent(const ui::Event& event, int* flags); | 164 void RewriteLocatedEvent(const ui::Event& event, int* flags); |
| 164 int RewriteModifierClick(const ui::MouseEvent& event, int* flags); | 165 int RewriteModifierClick(const ui::MouseEvent& event, int* flags); |
| 165 | 166 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 int pressed_modifier_latches_; | 200 int pressed_modifier_latches_; |
| 200 int latched_modifier_latches_; | 201 int latched_modifier_latches_; |
| 201 int used_modifier_latches_; | 202 int used_modifier_latches_; |
| 202 | 203 |
| 203 DISALLOW_COPY_AND_ASSIGN(EventRewriter); | 204 DISALLOW_COPY_AND_ASSIGN(EventRewriter); |
| 204 }; | 205 }; |
| 205 | 206 |
| 206 } // namespace chromeos | 207 } // namespace chromeos |
| 207 | 208 |
| 208 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ | 209 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ |
| OLD | NEW |