| 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 <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/message_loop/message_pump_observer.h" | 16 #include "base/message_loop/message_pump_observer.h" |
| 17 #include "chrome/browser/chromeos/device_hierarchy_observer.h" | 17 #include "chrome/browser/chromeos/device_hierarchy_observer.h" |
| 18 #include "ui/aura/window_tree_host_observer.h" | |
| 19 #include "ui/events/keycodes/keyboard_codes.h" | 18 #include "ui/events/keycodes/keyboard_codes.h" |
| 20 | 19 |
| 21 class PrefService; | 20 class PrefService; |
| 22 typedef union _XEvent XEvent; | 21 typedef union _XEvent XEvent; |
| 23 | 22 |
| 24 namespace aura { | |
| 25 class RootWindow; | |
| 26 } | |
| 27 | |
| 28 namespace chromeos { | 23 namespace chromeos { |
| 29 class KeyboardDrivenEventRewriter; | 24 class KeyboardDrivenEventRewriter; |
| 30 namespace input_method { | 25 namespace input_method { |
| 31 class XKeyboard; | 26 class XKeyboard; |
| 32 } | 27 } |
| 33 | 28 |
| 34 class EventRewriter : public aura::WindowTreeHostObserver, | 29 class EventRewriter : public DeviceHierarchyObserver, |
| 35 public DeviceHierarchyObserver, | |
| 36 public base::MessagePumpObserver { | 30 public base::MessagePumpObserver { |
| 37 public: | 31 public: |
| 38 enum DeviceType { | 32 enum DeviceType { |
| 39 kDeviceUnknown = 0, | 33 kDeviceUnknown = 0, |
| 40 kDeviceAppleKeyboard, | 34 kDeviceAppleKeyboard, |
| 41 }; | 35 }; |
| 42 | 36 |
| 43 EventRewriter(); | 37 EventRewriter(); |
| 44 virtual ~EventRewriter(); | 38 virtual ~EventRewriter(); |
| 45 | 39 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 xkeyboard_for_testing_ = xkeyboard; | 56 xkeyboard_for_testing_ = xkeyboard; |
| 63 } | 57 } |
| 64 | 58 |
| 65 // Gets DeviceType from the |device_name|. | 59 // Gets DeviceType from the |device_name|. |
| 66 static DeviceType GetDeviceType(const std::string& device_name); | 60 static DeviceType GetDeviceType(const std::string& device_name); |
| 67 | 61 |
| 68 private: | 62 private: |
| 69 friend class EventRewriterAshTest; | 63 friend class EventRewriterAshTest; |
| 70 friend class EventRewriterTest; | 64 friend class EventRewriterTest; |
| 71 | 65 |
| 72 // aura::WindowTreeHostObserver overrides: | |
| 73 virtual void OnKeyboardMappingChanged( | |
| 74 const aura::WindowTreeHost* host) OVERRIDE; | |
| 75 | |
| 76 // base::MessagePumpObserver overrides: | 66 // base::MessagePumpObserver overrides: |
| 77 virtual base::EventStatus WillProcessEvent( | 67 virtual base::EventStatus WillProcessEvent( |
| 78 const base::NativeEvent& event) OVERRIDE; | 68 const base::NativeEvent& event) OVERRIDE; |
| 79 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; | 69 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; |
| 80 | 70 |
| 81 // DeviceHierarchyObserver overrides: | 71 // DeviceHierarchyObserver overrides: |
| 82 virtual void DeviceHierarchyChanged() OVERRIDE {} | 72 virtual void DeviceHierarchyChanged() OVERRIDE {} |
| 83 virtual void DeviceAdded(int device_id) OVERRIDE; | 73 virtual void DeviceAdded(int device_id) OVERRIDE; |
| 84 virtual void DeviceRemoved(int device_id) OVERRIDE; | 74 virtual void DeviceRemoved(int device_id) OVERRIDE; |
| 85 virtual void DeviceKeyPressedOrReleased(int device_id) OVERRIDE; | 75 virtual void DeviceKeyPressedOrReleased(int device_id) OVERRIDE; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 keyboard_driven_event_rewriter_; | 196 keyboard_driven_event_rewriter_; |
| 207 | 197 |
| 208 const PrefService* pref_service_for_testing_; | 198 const PrefService* pref_service_for_testing_; |
| 209 | 199 |
| 210 DISALLOW_COPY_AND_ASSIGN(EventRewriter); | 200 DISALLOW_COPY_AND_ASSIGN(EventRewriter); |
| 211 }; | 201 }; |
| 212 | 202 |
| 213 } // namespace chromeos | 203 } // namespace chromeos |
| 214 | 204 |
| 215 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ | 205 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ |
| OLD | NEW |