summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 17:55:53 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 17:55:53 +0000
commitf8ef310be3f196ae5df2ed39e8b1057c5dddf782 (patch)
tree5e74b8935ad8a36e303a0c72c3e9d438f93e136a /ash
parentc754b8be87432da6e382b8348d6e60670afd2b21 (diff)
downloadchromium_src-f8ef310be3f196ae5df2ed39e8b1057c5dddf782.zip
chromium_src-f8ef310be3f196ae5df2ed39e8b1057c5dddf782.tar.gz
chromium_src-f8ef310be3f196ae5df2ed39e8b1057c5dddf782.tar.bz2
Fixing caps lock problems under ChromeOS where the tray does not properly follow the real caps lock change
BUG=356393 TEST=visual with chromebooks internal keyboard, external keyboard and with linux Review URL: https://codereview.chromium.org/231753002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263025 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/chromeos/tray_caps_lock.cc32
-rw-r--r--ash/system/chromeos/tray_caps_lock.h7
2 files changed, 29 insertions, 10 deletions
diff --git a/ash/system/chromeos/tray_caps_lock.cc b/ash/system/chromeos/tray_caps_lock.cc
index 7142a8e..d6a457d 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 differs 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->AddObserver(this);
+ } else {
+ Shell::GetInstance()->PrependPreTargetHandler(this);
+ }
}
TrayCapsLock::~TrayCapsLock() {
- Shell::GetInstance()->RemovePreTargetHandler(this);
+ // Since keyboard handling differs 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);
diff --git a/ash/system/chromeos/tray_caps_lock.h b/ash/system/chromeos/tray_caps_lock.h
index f24ad6b..49251d2 100644
--- a/ash/system/chromeos/tray_caps_lock.h
+++ b/ash/system/chromeos/tray_caps_lock.h
@@ -6,6 +6,7 @@
#define ASH_SYSTEM_CHROMEOS_TRAY_CAPS_LOCK_H_
#include "ash/system/tray/tray_image_item.h"
+#include "chromeos/ime/xkeyboard.h"
#include "ui/events/event_handler.h"
namespace views {
@@ -17,13 +18,15 @@ namespace ash {
class CapsLockDefaultView;
class TrayCapsLock : public TrayImageItem,
- public ui::EventHandler {
+ public ui::EventHandler,
+ public chromeos::input_method::XKeyboard::Observer {
public:
explicit TrayCapsLock(SystemTray* system_tray);
virtual ~TrayCapsLock();
private:
- void OnCapsLockChanged(bool enabled);
+ // Overriden from chromeos::input_method::XKeyboard::Observer:
+ virtual void OnCapsLockChanged(bool enabled) OVERRIDE;
// ui::EventHandler:
virtual void OnKeyEvent(ui::KeyEvent* key) OVERRIDE;