Chromium Code Reviews| Index: ash/system/chromeos/tray_caps_lock.cc |
| diff --git a/ash/system/chromeos/tray_caps_lock.cc b/ash/system/chromeos/tray_caps_lock.cc |
| index 7142a8ecb54e6c52d03a07bc19502e73bd3bcab9..c4e0446eae6be8c30737ca28f47ee20da235a31d 100644 |
| --- a/ash/system/chromeos/tray_caps_lock.cc |
| +++ b/ash/system/chromeos/tray_caps_lock.cc |
| @@ -10,6 +10,7 @@ |
| #include "ash/system/tray/fixed_sized_image_view.h" |
| #include "ash/system/tray/system_tray_notifier.h" |
| #include "ash/system/tray/tray_constants.h" |
| +#include "base/sys_info.h" |
| #include "chromeos/ime/input_method_manager.h" |
| #include "chromeos/ime/xkeyboard.h" |
| #include "grit/ash_resources.h" |
| @@ -129,24 +130,39 @@ TrayCapsLock::TrayCapsLock(SystemTray* system_tray) |
| detailed_(NULL), |
| caps_lock_enabled_(CapsLockIsEnabled()), |
| message_shown_(false) { |
| - // Make sure the event is processed by this before the IME. |
| - Shell::GetInstance()->PrependPreTargetHandler(this); |
| + // Since Keyboard handling differes between ChromeOS and Linux we need to |
|
Daniel Erat
2014/04/09 23:39:40
s/Keyboard/keyboard/, s/differes/differs/
Mr4D (OOO till 08-26)
2014/04/09 23:44:47
Done.
|
| + // use different observers depending on the two platforms. |
| + if (base::SysInfo::IsRunningOnChromeOS()) { |
| + chromeos::input_method::XKeyboard* xkeyboard = |
| + chromeos::input_method::InputMethodManager::Get()->GetXKeyboard(); |
| + xkeyboard->AddObserver(this); |
| + } else { |
| + Shell::GetInstance()->PrependPreTargetHandler(this); |
| + } |
| } |
| TrayCapsLock::~TrayCapsLock() { |
| - Shell::GetInstance()->RemovePreTargetHandler(this); |
| + // Since Keyboard handling differes between ChromeOS and Linux we need to |
| + // use different observers depending on the two platforms. |
| + if (base::SysInfo::IsRunningOnChromeOS()) { |
| + chromeos::input_method::XKeyboard* xkeyboard = |
| + chromeos::input_method::InputMethodManager::Get()->GetXKeyboard(); |
| + xkeyboard->RemoveObserver(this); |
| + } else { |
| + Shell::GetInstance()->RemovePreTargetHandler(this); |
| + } |
| } |
| void TrayCapsLock::OnCapsLockChanged(bool enabled) { |
| - if (tray_view()) |
| - tray_view()->SetVisible(enabled); |
| - |
| caps_lock_enabled_ = enabled; |
| + if (tray_view()) |
| + tray_view()->SetVisible(caps_lock_enabled_); |
| + |
| if (default_) { |
| - default_->Update(enabled); |
| + default_->Update(caps_lock_enabled_); |
| } else { |
| - if (enabled) { |
| + if (caps_lock_enabled_) { |
| if (!message_shown_) { |
| Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| ash::UMA_STATUS_AREA_CAPS_LOCK_POPUP); |