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 "chrome/browser/ui/ash/event_rewriter.h" | 5 #include "chrome/browser/ui/ash/event_rewriter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 EventRewriter::EventRewriter() | 164 EventRewriter::EventRewriter() |
165 : last_device_id_(kBadDeviceId), | 165 : last_device_id_(kBadDeviceId), |
166 #if defined(OS_CHROMEOS) | 166 #if defined(OS_CHROMEOS) |
167 xkeyboard_(NULL), | 167 xkeyboard_(NULL), |
168 keyboard_driven_event_rewritter_( | 168 keyboard_driven_event_rewritter_( |
169 new chromeos::KeyboardDrivenEventRewriter), | 169 new chromeos::KeyboardDrivenEventRewriter), |
170 #endif | 170 #endif |
171 pref_service_(NULL) { | 171 pref_service_(NULL) { |
172 // The ash shell isn't instantiated for our unit tests. | 172 // The ash shell isn't instantiated for our unit tests. |
173 if (ash::Shell::HasInstance()) | 173 if (ash::Shell::HasInstance()) { |
174 ash::Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); | 174 ash::Shell::GetPrimaryRootWindow()->GetDispatcher()-> |
| 175 AddRootWindowObserver(this); |
| 176 } |
175 #if defined(OS_CHROMEOS) | 177 #if defined(OS_CHROMEOS) |
176 if (base::SysInfo::IsRunningOnChromeOS()) { | 178 if (base::SysInfo::IsRunningOnChromeOS()) { |
177 chromeos::XInputHierarchyChangedEventListener::GetInstance() | 179 chromeos::XInputHierarchyChangedEventListener::GetInstance() |
178 ->AddObserver(this); | 180 ->AddObserver(this); |
179 } | 181 } |
180 RefreshKeycodes(); | 182 RefreshKeycodes(); |
181 #endif | 183 #endif |
182 } | 184 } |
183 | 185 |
184 EventRewriter::~EventRewriter() { | 186 EventRewriter::~EventRewriter() { |
185 if (ash::Shell::HasInstance()) | 187 if (ash::Shell::HasInstance()) { |
186 ash::Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); | 188 ash::Shell::GetPrimaryRootWindow()->GetDispatcher()-> |
| 189 RemoveRootWindowObserver(this); |
| 190 } |
187 #if defined(OS_CHROMEOS) | 191 #if defined(OS_CHROMEOS) |
188 if (base::SysInfo::IsRunningOnChromeOS()) { | 192 if (base::SysInfo::IsRunningOnChromeOS()) { |
189 chromeos::XInputHierarchyChangedEventListener::GetInstance() | 193 chromeos::XInputHierarchyChangedEventListener::GetInstance() |
190 ->RemoveObserver(this); | 194 ->RemoveObserver(this); |
191 } | 195 } |
192 #endif | 196 #endif |
193 } | 197 } |
194 | 198 |
195 EventRewriter::DeviceType EventRewriter::DeviceAddedForTesting( | 199 EventRewriter::DeviceType EventRewriter::DeviceAddedForTesting( |
196 int device_id, | 200 int device_id, |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 const DeviceType type = EventRewriter::GetDeviceType(device_name); | 1050 const DeviceType type = EventRewriter::GetDeviceType(device_name); |
1047 if (type == kDeviceAppleKeyboard) { | 1051 if (type == kDeviceAppleKeyboard) { |
1048 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " | 1052 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " |
1049 << "id=" << device_id; | 1053 << "id=" << device_id; |
1050 } | 1054 } |
1051 // Always overwrite the existing device_id since the X server may reuse a | 1055 // Always overwrite the existing device_id since the X server may reuse a |
1052 // device id for an unattached device. | 1056 // device id for an unattached device. |
1053 device_id_to_type_[device_id] = type; | 1057 device_id_to_type_[device_id] = type; |
1054 return type; | 1058 return type; |
1055 } | 1059 } |
OLD | NEW |