Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: ash/system/chromeos/tray_caps_lock.cc

Issue 231753002: Fixing caps lock problems under ChromeOS where the tray does not properly follow the real caps lock… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ash/system/chromeos/tray_caps_lock.h" 5 #include "ash/system/chromeos/tray_caps_lock.h"
6 6
7 #include "ash/metrics/user_metrics_recorder.h" 7 #include "ash/metrics/user_metrics_recorder.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/tray/actionable_view.h" 9 #include "ash/system/tray/actionable_view.h"
10 #include "ash/system/tray/fixed_sized_image_view.h" 10 #include "ash/system/tray/fixed_sized_image_view.h"
11 #include "ash/system/tray/system_tray_notifier.h" 11 #include "ash/system/tray/system_tray_notifier.h"
12 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
13 #include "base/sys_info.h"
13 #include "chromeos/ime/input_method_manager.h" 14 #include "chromeos/ime/input_method_manager.h"
14 #include "chromeos/ime/xkeyboard.h" 15 #include "chromeos/ime/xkeyboard.h"
15 #include "grit/ash_resources.h" 16 #include "grit/ash_resources.h"
16 #include "grit/ash_strings.h" 17 #include "grit/ash_strings.h"
17 #include "ui/accessibility/ax_view_state.h" 18 #include "ui/accessibility/ax_view_state.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
20 #include "ui/views/controls/image_view.h" 21 #include "ui/views/controls/image_view.h"
21 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
22 #include "ui/views/layout/box_layout.h" 23 #include "ui/views/layout/box_layout.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 123
123 DISALLOW_COPY_AND_ASSIGN(CapsLockDefaultView); 124 DISALLOW_COPY_AND_ASSIGN(CapsLockDefaultView);
124 }; 125 };
125 126
126 TrayCapsLock::TrayCapsLock(SystemTray* system_tray) 127 TrayCapsLock::TrayCapsLock(SystemTray* system_tray)
127 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_CAPS_LOCK), 128 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_CAPS_LOCK),
128 default_(NULL), 129 default_(NULL),
129 detailed_(NULL), 130 detailed_(NULL),
130 caps_lock_enabled_(CapsLockIsEnabled()), 131 caps_lock_enabled_(CapsLockIsEnabled()),
131 message_shown_(false) { 132 message_shown_(false) {
132 // Make sure the event is processed by this before the IME. 133 // Since keyboard handling differs between ChromeOS and Linux we need to
133 Shell::GetInstance()->PrependPreTargetHandler(this); 134 // use different observers depending on the two platforms.
135 if (base::SysInfo::IsRunningOnChromeOS()) {
136 chromeos::input_method::XKeyboard* xkeyboard =
137 chromeos::input_method::InputMethodManager::Get()->GetXKeyboard();
138 xkeyboard->AddObserver(this);
139 } else {
140 Shell::GetInstance()->PrependPreTargetHandler(this);
141 }
134 } 142 }
135 143
136 TrayCapsLock::~TrayCapsLock() { 144 TrayCapsLock::~TrayCapsLock() {
137 Shell::GetInstance()->RemovePreTargetHandler(this); 145 // Since keyboard handling differs between ChromeOS and Linux we need to
146 // use different observers depending on the two platforms.
147 if (base::SysInfo::IsRunningOnChromeOS()) {
148 chromeos::input_method::XKeyboard* xkeyboard =
149 chromeos::input_method::InputMethodManager::Get()->GetXKeyboard();
150 xkeyboard->RemoveObserver(this);
151 } else {
152 Shell::GetInstance()->RemovePreTargetHandler(this);
153 }
138 } 154 }
139 155
140 void TrayCapsLock::OnCapsLockChanged(bool enabled) { 156 void TrayCapsLock::OnCapsLockChanged(bool enabled) {
141 if (tray_view())
142 tray_view()->SetVisible(enabled);
143
144 caps_lock_enabled_ = enabled; 157 caps_lock_enabled_ = enabled;
145 158
159 if (tray_view())
160 tray_view()->SetVisible(caps_lock_enabled_);
161
146 if (default_) { 162 if (default_) {
147 default_->Update(enabled); 163 default_->Update(caps_lock_enabled_);
148 } else { 164 } else {
149 if (enabled) { 165 if (caps_lock_enabled_) {
150 if (!message_shown_) { 166 if (!message_shown_) {
151 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 167 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
152 ash::UMA_STATUS_AREA_CAPS_LOCK_POPUP); 168 ash::UMA_STATUS_AREA_CAPS_LOCK_POPUP);
153 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); 169 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false);
154 message_shown_ = true; 170 message_shown_ = true;
155 } 171 }
156 } else if (detailed_) { 172 } else if (detailed_) {
157 detailed_->GetWidget()->Close(); 173 detailed_->GetWidget()->Close();
158 } 174 }
159 } 175 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 224
209 void TrayCapsLock::DestroyDefaultView() { 225 void TrayCapsLock::DestroyDefaultView() {
210 default_ = NULL; 226 default_ = NULL;
211 } 227 }
212 228
213 void TrayCapsLock::DestroyDetailedView() { 229 void TrayCapsLock::DestroyDetailedView() {
214 detailed_ = NULL; 230 detailed_ = NULL;
215 } 231 }
216 232
217 } // namespace ash 233 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698