Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: chrome/browser/chromeos/events/event_rewriter.h

Issue 232333002: ozone: Rename XKeyboard to KeyboardController & use fake under ozone (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename to ImeKeyboard & rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/chromeos/device_hierarchy_observer.h" 16 #include "chrome/browser/chromeos/device_hierarchy_observer.h"
17 #include "chromeos/ime/ime_keyboard.h"
17 #include "ui/events/keycodes/keyboard_codes.h" 18 #include "ui/events/keycodes/keyboard_codes.h"
18 #include "ui/events/platform/platform_event_observer.h" 19 #include "ui/events/platform/platform_event_observer.h"
19 20
20 class PrefService; 21 class PrefService;
21 typedef union _XEvent XEvent; 22 typedef union _XEvent XEvent;
22 23
23 namespace chromeos { 24 namespace chromeos {
24 class KeyboardDrivenEventRewriter; 25 class KeyboardDrivenEventRewriter;
25 namespace input_method { 26 namespace input_method {
26 class XKeyboard; 27 class ImeKeyboard;
27 } 28 }
28 29
29 class EventRewriter : public DeviceHierarchyObserver, 30 class EventRewriter : public DeviceHierarchyObserver,
30 public ui::PlatformEventObserver { 31 public ui::PlatformEventObserver {
31 public: 32 public:
32 enum DeviceType { 33 enum DeviceType {
33 kDeviceUnknown = 0, 34 kDeviceUnknown = 0,
34 kDeviceAppleKeyboard, 35 kDeviceAppleKeyboard,
35 }; 36 };
36 37
37 EventRewriter(); 38 EventRewriter();
38 virtual ~EventRewriter(); 39 virtual ~EventRewriter();
39 40
40 // Calls DeviceAddedInternal. 41 // Calls DeviceAddedInternal.
41 DeviceType DeviceAddedForTesting(int device_id, 42 DeviceType DeviceAddedForTesting(int device_id,
42 const std::string& device_name); 43 const std::string& device_name);
43 // Calls Rewrite. 44 // Calls Rewrite.
44 void RewriteForTesting(XEvent* event); 45 void RewriteForTesting(XEvent* event);
45 46
46 const std::map<int, DeviceType>& device_id_to_type_for_testing() const { 47 const std::map<int, DeviceType>& device_id_to_type_for_testing() const {
47 return device_id_to_type_; 48 return device_id_to_type_;
48 } 49 }
49 void set_last_device_id_for_testing(int device_id) { 50 void set_last_device_id_for_testing(int device_id) {
50 last_device_id_ = device_id; 51 last_device_id_ = device_id;
51 } 52 }
52 void set_pref_service_for_testing(const PrefService* pref_service) { 53 void set_pref_service_for_testing(const PrefService* pref_service) {
53 pref_service_for_testing_ = pref_service; 54 pref_service_for_testing_ = pref_service;
54 } 55 }
55 void set_xkeyboard_for_testing(input_method::XKeyboard* xkeyboard) { 56 void set_keyboard_for_testing(input_method::ImeKeyboard* keyboard) {
56 xkeyboard_for_testing_ = xkeyboard; 57 keyboard_for_testing_ = keyboard;
57 } 58 }
58 59
59 // Gets DeviceType from the |device_name|. 60 // Gets DeviceType from the |device_name|.
60 static DeviceType GetDeviceType(const std::string& device_name); 61 static DeviceType GetDeviceType(const std::string& device_name);
61 62
62 private: 63 private:
63 friend class EventRewriterAshTest; 64 friend class EventRewriterAshTest;
64 friend class EventRewriterTest; 65 friend class EventRewriterTest;
65 66
66 void DeviceKeyPressedOrReleased(int device_id); 67 void DeviceKeyPressedOrReleased(int device_id);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 184
184 std::map<int, DeviceType> device_id_to_type_; 185 std::map<int, DeviceType> device_id_to_type_;
185 int last_device_id_; 186 int last_device_id_;
186 187
187 // A mapping from X11 KeySym keys to KeyCode values. 188 // A mapping from X11 KeySym keys to KeyCode values.
188 base::hash_map<unsigned long, unsigned long> keysym_to_keycode_map_; 189 base::hash_map<unsigned long, unsigned long> keysym_to_keycode_map_;
189 190
190 // A set of device IDs whose press event has been rewritten. 191 // A set of device IDs whose press event has been rewritten.
191 std::set<int> pressed_device_ids_; 192 std::set<int> pressed_device_ids_;
192 193
193 input_method::XKeyboard* xkeyboard_for_testing_; 194 input_method::ImeKeyboard* keyboard_for_testing_;
194 195
195 scoped_ptr<KeyboardDrivenEventRewriter> 196 scoped_ptr<KeyboardDrivenEventRewriter>
196 keyboard_driven_event_rewriter_; 197 keyboard_driven_event_rewriter_;
197 198
198 const PrefService* pref_service_for_testing_; 199 const PrefService* pref_service_for_testing_;
199 200
200 DISALLOW_COPY_AND_ASSIGN(EventRewriter); 201 DISALLOW_COPY_AND_ASSIGN(EventRewriter);
201 }; 202 };
202 203
203 } // namespace chromeos 204 } // namespace chromeos
204 205
205 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_ 206 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.cc ('k') | chrome/browser/chromeos/events/event_rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698