| 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/views/ash/key_rewriter.h" | 5 #include "chrome/browser/ui/views/ash/key_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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const int kBadDeviceId = -1; | 29 const int kBadDeviceId = -1; |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 KeyRewriter::KeyRewriter() : last_device_id_(kBadDeviceId) { | 33 KeyRewriter::KeyRewriter() : last_device_id_(kBadDeviceId) { |
| 34 // The ash shell isn't instantiated for our unit tests. | 34 // The ash shell isn't instantiated for our unit tests. |
| 35 if (ash::Shell::HasInstance()) | 35 if (ash::Shell::HasInstance()) |
| 36 ash::Shell::GetInstance()->GetRootWindow()->AddRootWindowObserver(this); | 36 ash::Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); |
| 37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 38 if (base::chromeos::IsRunningOnChromeOS()) { | 38 if (base::chromeos::IsRunningOnChromeOS()) { |
| 39 chromeos::XInputHierarchyChangedEventListener::GetInstance() | 39 chromeos::XInputHierarchyChangedEventListener::GetInstance() |
| 40 ->AddObserver(this); | 40 ->AddObserver(this); |
| 41 } | 41 } |
| 42 RefreshKeycodes(); | 42 RefreshKeycodes(); |
| 43 #endif | 43 #endif |
| 44 } | 44 } |
| 45 | 45 |
| 46 KeyRewriter::~KeyRewriter() { | 46 KeyRewriter::~KeyRewriter() { |
| 47 if (ash::Shell::HasInstance()) | 47 if (ash::Shell::HasInstance()) |
| 48 ash::Shell::GetInstance()->GetRootWindow()->RemoveRootWindowObserver(this); | 48 ash::Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); |
| 49 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
| 50 if (base::chromeos::IsRunningOnChromeOS()) { | 50 if (base::chromeos::IsRunningOnChromeOS()) { |
| 51 chromeos::XInputHierarchyChangedEventListener::GetInstance() | 51 chromeos::XInputHierarchyChangedEventListener::GetInstance() |
| 52 ->RemoveObserver(this); | 52 ->RemoveObserver(this); |
| 53 } | 53 } |
| 54 #endif | 54 #endif |
| 55 } | 55 } |
| 56 | 56 |
| 57 KeyRewriter::DeviceType KeyRewriter::DeviceAddedForTesting( | 57 KeyRewriter::DeviceType KeyRewriter::DeviceAddedForTesting( |
| 58 int device_id, | 58 int device_id, |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 const DeviceType type = KeyRewriter::GetDeviceType(device_name); | 339 const DeviceType type = KeyRewriter::GetDeviceType(device_name); |
| 340 if (type == kDeviceAppleKeyboard) { | 340 if (type == kDeviceAppleKeyboard) { |
| 341 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " | 341 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " |
| 342 << "id=" << device_id; | 342 << "id=" << device_id; |
| 343 } | 343 } |
| 344 // Always overwrite the existing device_id since the X server may reuse a | 344 // Always overwrite the existing device_id since the X server may reuse a |
| 345 // device id for an unattached device. | 345 // device id for an unattached device. |
| 346 device_id_to_type_[device_id] = type; | 346 device_id_to_type_[device_id] = type; |
| 347 return type; | 347 return type; |
| 348 } | 348 } |
| OLD | NEW |