| 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 11 matching lines...) Expand all Loading... |
| 22 #include <X11/XF86keysym.h> | 22 #include <X11/XF86keysym.h> |
| 23 #include <X11/Xlib.h> | 23 #include <X11/Xlib.h> |
| 24 | 24 |
| 25 // Get rid of a macro from Xlib.h that conflicts with OwnershipService class. | 25 // Get rid of a macro from Xlib.h that conflicts with OwnershipService class. |
| 26 #undef Status | 26 #undef Status |
| 27 | 27 |
| 28 #include "base/chromeos/chromeos_version.h" | 28 #include "base/chromeos/chromeos_version.h" |
| 29 #include "base/command_line.h" | 29 #include "base/command_line.h" |
| 30 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 30 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
| 31 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 31 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 32 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 32 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 33 #include "chrome/browser/chromeos/login/user_manager.h" | 33 #include "chrome/browser/chromeos/login/user_manager.h" |
| 34 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h" | 34 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h" |
| 35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
| 37 #include "chromeos/ime/xkeyboard.h" | 37 #include "chromeos/ime/xkeyboard.h" |
| 38 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 38 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
| 39 #include "ui/base/x/x11_util.h" | 39 #include "ui/base/x/x11_util.h" |
| 40 | 40 |
| 41 using chromeos::input_method::GetInputMethodManager; | 41 using chromeos::input_method::GetInputMethodManager; |
| 42 #endif | 42 #endif |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 381 |
| 382 void EventRewriter::GetRemappedModifierMasks( | 382 void EventRewriter::GetRemappedModifierMasks( |
| 383 int original_flags, | 383 int original_flags, |
| 384 unsigned int original_native_modifiers, | 384 unsigned int original_native_modifiers, |
| 385 int* remapped_flags, | 385 int* remapped_flags, |
| 386 unsigned int* remapped_native_modifiers) const { | 386 unsigned int* remapped_native_modifiers) const { |
| 387 #if defined(OS_CHROMEOS) | 387 #if defined(OS_CHROMEOS) |
| 388 // TODO(glotov): remove the following condition when we do not restart chrome | 388 // TODO(glotov): remove the following condition when we do not restart chrome |
| 389 // when user logs in as guest. See Rewrite() for details. | 389 // when user logs in as guest. See Rewrite() for details. |
| 390 if (chromeos::UserManager::Get()->IsLoggedInAsGuest() && | 390 if (chromeos::UserManager::Get()->IsLoggedInAsGuest() && |
| 391 chromeos::BaseLoginDisplayHost::default_host()) { | 391 chromeos::LoginDisplayHostImpl::default_host()) { |
| 392 return; | 392 return; |
| 393 } | 393 } |
| 394 | 394 |
| 395 const PrefService* pref_service = | 395 const PrefService* pref_service = |
| 396 pref_service_ ? pref_service_ : GetPrefService(); | 396 pref_service_ ? pref_service_ : GetPrefService(); |
| 397 if (!pref_service) | 397 if (!pref_service) |
| 398 return; | 398 return; |
| 399 | 399 |
| 400 // When a diamond key is not available, a Mod2Mask should not treated as a | 400 // When a diamond key is not available, a Mod2Mask should not treated as a |
| 401 // configurable modifier because Mod2Mask may be worked as NumLock mask. | 401 // configurable modifier because Mod2Mask may be worked as NumLock mask. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 bool EventRewriter::RewriteModifiers(ui::KeyEvent* event) { | 450 bool EventRewriter::RewriteModifiers(ui::KeyEvent* event) { |
| 451 // Do nothing if we have just logged in as guest but have not restarted chrome | 451 // Do nothing if we have just logged in as guest but have not restarted chrome |
| 452 // process yet (so we are still on the login screen). In this situations we | 452 // process yet (so we are still on the login screen). In this situations we |
| 453 // have no user profile so can not do anything useful. | 453 // have no user profile so can not do anything useful. |
| 454 // Note that currently, unlike other accounts, when user logs in as guest, we | 454 // Note that currently, unlike other accounts, when user logs in as guest, we |
| 455 // restart chrome process. In future this is to be changed. | 455 // restart chrome process. In future this is to be changed. |
| 456 // TODO(glotov): remove the following condition when we do not restart chrome | 456 // TODO(glotov): remove the following condition when we do not restart chrome |
| 457 // when user logs in as guest. | 457 // when user logs in as guest. |
| 458 #if defined(OS_CHROMEOS) | 458 #if defined(OS_CHROMEOS) |
| 459 if (chromeos::UserManager::Get()->IsLoggedInAsGuest() && | 459 if (chromeos::UserManager::Get()->IsLoggedInAsGuest() && |
| 460 chromeos::BaseLoginDisplayHost::default_host()) | 460 chromeos::LoginDisplayHostImpl::default_host()) |
| 461 return false; | 461 return false; |
| 462 #endif // defined(OS_CHROMEOS) | 462 #endif // defined(OS_CHROMEOS) |
| 463 const PrefService* pref_service = | 463 const PrefService* pref_service = |
| 464 pref_service_ ? pref_service_ : GetPrefService(); | 464 pref_service_ ? pref_service_ : GetPrefService(); |
| 465 if (!pref_service) | 465 if (!pref_service) |
| 466 return false; | 466 return false; |
| 467 | 467 |
| 468 #if defined(OS_CHROMEOS) | 468 #if defined(OS_CHROMEOS) |
| 469 DCHECK_EQ(chromeos::input_method::kControlKey, | 469 DCHECK_EQ(chromeos::input_method::kControlKey, |
| 470 kModifierRemappingCtrl->remap_to); | 470 kModifierRemappingCtrl->remap_to); |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 const DeviceType type = EventRewriter::GetDeviceType(device_name); | 1014 const DeviceType type = EventRewriter::GetDeviceType(device_name); |
| 1015 if (type == kDeviceAppleKeyboard) { | 1015 if (type == kDeviceAppleKeyboard) { |
| 1016 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " | 1016 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " |
| 1017 << "id=" << device_id; | 1017 << "id=" << device_id; |
| 1018 } | 1018 } |
| 1019 // Always overwrite the existing device_id since the X server may reuse a | 1019 // Always overwrite the existing device_id since the X server may reuse a |
| 1020 // device id for an unattached device. | 1020 // device id for an unattached device. |
| 1021 device_id_to_type_[device_id] = type; | 1021 device_id_to_type_[device_id] = type; |
| 1022 return type; | 1022 return type; |
| 1023 } | 1023 } |
| OLD | NEW |