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

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

Issue 232333002: ozone: Rename XKeyboard to KeyboardController & use fake under ozone (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 "chromeos/ime/input_method_manager.h" 13 #include "chromeos/ime/input_method_manager.h"
14 #include "chromeos/ime/xkeyboard.h" 14 #include "chromeos/ime/keyboard_controller.h"
15 #include "grit/ash_resources.h" 15 #include "grit/ash_resources.h"
16 #include "grit/ash_strings.h" 16 #include "grit/ash_strings.h"
17 #include "ui/accessibility/ax_view_state.h" 17 #include "ui/accessibility/ax_view_state.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
20 #include "ui/views/controls/image_view.h" 20 #include "ui/views/controls/image_view.h"
21 #include "ui/views/controls/label.h" 21 #include "ui/views/controls/label.h"
22 #include "ui/views/layout/box_layout.h" 22 #include "ui/views/layout/box_layout.h"
23 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
24 24
25 namespace ash { 25 namespace ash {
26 namespace internal { 26 namespace internal {
27 27
28 namespace { 28 namespace {
29 29
30 bool CapsLockIsEnabled() { 30 bool CapsLockIsEnabled() {
31 chromeos::input_method::InputMethodManager* ime = 31 chromeos::input_method::InputMethodManager* ime =
32 chromeos::input_method::InputMethodManager::Get(); 32 chromeos::input_method::InputMethodManager::Get();
33 return (ime && ime->GetXKeyboard()) ? ime->GetXKeyboard()->CapsLockIsEnabled() 33 return (ime && ime->GetKeyboardController())
34 : false; 34 ? ime->GetKeyboardController()->CapsLockIsEnabled()
35 : false;
35 } 36 }
36 37
37 } 38 }
38 39
39 class CapsLockDefaultView : public ActionableView { 40 class CapsLockDefaultView : public ActionableView {
40 public: 41 public:
41 CapsLockDefaultView() 42 CapsLockDefaultView()
42 : text_label_(new views::Label), 43 : text_label_(new views::Label),
43 shortcut_label_(new views::Label) { 44 shortcut_label_(new views::Label) {
44 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 45 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 text_size.height())); 103 text_size.height()));
103 } 104 }
104 105
105 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE { 106 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE {
106 state->role = ui::AX_ROLE_BUTTON; 107 state->role = ui::AX_ROLE_BUTTON;
107 state->name = text_label_->text(); 108 state->name = text_label_->text();
108 } 109 }
109 110
110 // Overridden from ActionableView: 111 // Overridden from ActionableView:
111 virtual bool PerformAction(const ui::Event& event) OVERRIDE { 112 virtual bool PerformAction(const ui::Event& event) OVERRIDE {
112 chromeos::input_method::XKeyboard* xkeyboard = 113 chromeos::input_method::KeyboardController* xkeyboard =
113 chromeos::input_method::InputMethodManager::Get()->GetXKeyboard(); 114 chromeos::input_method::InputMethodManager::Get()
115 ->GetKeyboardController();
114 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 116 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
115 xkeyboard->CapsLockIsEnabled() ? 117 xkeyboard->CapsLockIsEnabled() ?
116 ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK : 118 ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK :
117 ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK); 119 ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK);
118 xkeyboard->SetCapsLockEnabled(!xkeyboard->CapsLockIsEnabled()); 120 xkeyboard->SetCapsLockEnabled(!xkeyboard->CapsLockIsEnabled());
119 return true; 121 return true;
120 } 122 }
121 123
122 views::Label* text_label_; 124 views::Label* text_label_;
123 views::Label* shortcut_label_; 125 views::Label* shortcut_label_;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 void TrayCapsLock::DestroyDefaultView() { 213 void TrayCapsLock::DestroyDefaultView() {
212 default_ = NULL; 214 default_ = NULL;
213 } 215 }
214 216
215 void TrayCapsLock::DestroyDetailedView() { 217 void TrayCapsLock::DestroyDetailedView() {
216 detailed_ = NULL; 218 detailed_ = NULL;
217 } 219 }
218 220
219 } // namespace internal 221 } // namespace internal
220 } // namespace ash 222 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698