| 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 #include "chrome/browser/chromeos/events/event_rewriter.h" | 5 #include "chrome/browser/chromeos/events/event_rewriter.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
| 8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
| 9 #include <X11/XF86keysym.h> | 9 #include <X11/XF86keysym.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 namespace chromeos { | 137 namespace chromeos { |
| 138 | 138 |
| 139 EventRewriter::EventRewriter() | 139 EventRewriter::EventRewriter() |
| 140 : last_device_id_(kBadDeviceId), | 140 : last_device_id_(kBadDeviceId), |
| 141 xkeyboard_for_testing_(NULL), | 141 xkeyboard_for_testing_(NULL), |
| 142 keyboard_driven_event_rewriter_(new KeyboardDrivenEventRewriter), | 142 keyboard_driven_event_rewriter_(new KeyboardDrivenEventRewriter), |
| 143 pref_service_for_testing_(NULL) { | 143 pref_service_for_testing_(NULL) { |
| 144 // The ash shell isn't instantiated for our unit tests. | 144 // The ash shell isn't instantiated for our unit tests. |
| 145 if (ash::Shell::HasInstance()) { | 145 if (ash::Shell::HasInstance()) { |
| 146 ash::Shell::GetPrimaryRootWindow()->GetDispatcher()-> | 146 ash::Shell::GetPrimaryRootWindow()->GetHost()->dispatcher()-> |
| 147 AddRootWindowObserver(this); | 147 AddRootWindowObserver(this); |
| 148 } | 148 } |
| 149 base::MessageLoopForUI::current()->AddObserver(this); | 149 base::MessageLoopForUI::current()->AddObserver(this); |
| 150 if (base::SysInfo::IsRunningOnChromeOS()) { | 150 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 151 XInputHierarchyChangedEventListener::GetInstance()->AddObserver(this); | 151 XInputHierarchyChangedEventListener::GetInstance()->AddObserver(this); |
| 152 } | 152 } |
| 153 RefreshKeycodes(); | 153 RefreshKeycodes(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 EventRewriter::~EventRewriter() { | 156 EventRewriter::~EventRewriter() { |
| 157 base::MessageLoopForUI::current()->RemoveObserver(this); | 157 base::MessageLoopForUI::current()->RemoveObserver(this); |
| 158 if (ash::Shell::HasInstance()) { | 158 if (ash::Shell::HasInstance()) { |
| 159 ash::Shell::GetPrimaryRootWindow()->GetDispatcher()-> | 159 ash::Shell::GetPrimaryRootWindow()->GetHost()->dispatcher()-> |
| 160 RemoveRootWindowObserver(this); | 160 RemoveRootWindowObserver(this); |
| 161 } | 161 } |
| 162 if (base::SysInfo::IsRunningOnChromeOS()) { | 162 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 163 XInputHierarchyChangedEventListener::GetInstance()->RemoveObserver(this); | 163 XInputHierarchyChangedEventListener::GetInstance()->RemoveObserver(this); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 EventRewriter::DeviceType EventRewriter::DeviceAddedForTesting( | 167 EventRewriter::DeviceType EventRewriter::DeviceAddedForTesting( |
| 168 int device_id, | 168 int device_id, |
| 169 const std::string& device_name) { | 169 const std::string& device_name) { |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " | 899 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " |
| 900 << "id=" << device_id; | 900 << "id=" << device_id; |
| 901 } | 901 } |
| 902 // Always overwrite the existing device_id since the X server may reuse a | 902 // Always overwrite the existing device_id since the X server may reuse a |
| 903 // device id for an unattached device. | 903 // device id for an unattached device. |
| 904 device_id_to_type_[device_id] = type; | 904 device_id_to_type_[device_id] = type; |
| 905 return type; | 905 return type; |
| 906 } | 906 } |
| 907 | 907 |
| 908 } // namespace chromeos | 908 } // namespace chromeos |
| OLD | NEW |