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 "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" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH : | 83 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH : |
84 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH; | 84 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH; |
85 } | 85 } |
86 shortcut_label_->SetText(bundle.GetLocalizedString(shortcut_string_id)); | 86 shortcut_label_->SetText(bundle.GetLocalizedString(shortcut_string_id)); |
87 | 87 |
88 Layout(); | 88 Layout(); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 // Overridden from views::View: | 92 // Overridden from views::View: |
93 virtual void Layout() OVERRIDE { | 93 virtual void Layout() override { |
94 views::View::Layout(); | 94 views::View::Layout(); |
95 | 95 |
96 // Align the shortcut text with the right end | 96 // Align the shortcut text with the right end |
97 const int old_x = shortcut_label_->x(); | 97 const int old_x = shortcut_label_->x(); |
98 const int new_x = | 98 const int new_x = |
99 width() - shortcut_label_->width() - kTrayPopupPaddingHorizontal; | 99 width() - shortcut_label_->width() - kTrayPopupPaddingHorizontal; |
100 shortcut_label_->SetX(new_x); | 100 shortcut_label_->SetX(new_x); |
101 const gfx::Size text_size = text_label_->size(); | 101 const gfx::Size text_size = text_label_->size(); |
102 text_label_->SetSize(gfx::Size(text_size.width() + new_x - old_x, | 102 text_label_->SetSize(gfx::Size(text_size.width() + new_x - old_x, |
103 text_size.height())); | 103 text_size.height())); |
104 } | 104 } |
105 | 105 |
106 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE { | 106 virtual void GetAccessibleState(ui::AXViewState* state) override { |
107 state->role = ui::AX_ROLE_BUTTON; | 107 state->role = ui::AX_ROLE_BUTTON; |
108 state->name = text_label_->text(); | 108 state->name = text_label_->text(); |
109 } | 109 } |
110 | 110 |
111 // Overridden from ActionableView: | 111 // Overridden from ActionableView: |
112 virtual bool PerformAction(const ui::Event& event) OVERRIDE { | 112 virtual bool PerformAction(const ui::Event& event) override { |
113 chromeos::input_method::ImeKeyboard* keyboard = | 113 chromeos::input_method::ImeKeyboard* keyboard = |
114 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 114 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
115 if (keyboard) { | 115 if (keyboard) { |
116 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 116 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
117 keyboard->CapsLockIsEnabled() ? | 117 keyboard->CapsLockIsEnabled() ? |
118 ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK : | 118 ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK : |
119 ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK); | 119 ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK); |
120 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | 120 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
121 } | 121 } |
122 return true; | 122 return true; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 void TrayCapsLock::DestroyDefaultView() { | 214 void TrayCapsLock::DestroyDefaultView() { |
215 default_ = NULL; | 215 default_ = NULL; |
216 } | 216 } |
217 | 217 |
218 void TrayCapsLock::DestroyDetailedView() { | 218 void TrayCapsLock::DestroyDetailedView() { |
219 detailed_ = NULL; | 219 detailed_ = NULL; |
220 } | 220 } |
221 | 221 |
222 } // namespace ash | 222 } // namespace ash |
OLD | NEW |