| 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/common/system/tray/actionable_view.h" | 7 #include "ash/common/system/tray/actionable_view.h" |
| 8 #include "ash/common/system/tray/fixed_sized_image_view.h" | 8 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| 9 #include "ash/common/system/tray/system_tray_delegate.h" | 9 #include "ash/common/system/tray/system_tray_delegate.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/metrics/user_metrics_recorder.h" | |
| 13 #include "ash/shell.h" | |
| 14 #include "ash/system/tray/system_tray_notifier.h" | 12 #include "ash/system/tray/system_tray_notifier.h" |
| 15 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 16 #include "grit/ash_resources.h" | 14 #include "grit/ash_resources.h" |
| 17 #include "grit/ash_strings.h" | 15 #include "grit/ash_strings.h" |
| 18 #include "ui/accessibility/ax_view_state.h" | 16 #include "ui/accessibility/ax_view_state.h" |
| 19 #include "ui/base/ime/chromeos/ime_keyboard.h" | 17 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 20 #include "ui/base/ime/chromeos/input_method_manager.h" | 18 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 23 #include "ui/views/controls/image_view.h" | 21 #include "ui/views/controls/image_view.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void GetAccessibleState(ui::AXViewState* state) override { | 105 void GetAccessibleState(ui::AXViewState* state) override { |
| 108 state->role = ui::AX_ROLE_BUTTON; | 106 state->role = ui::AX_ROLE_BUTTON; |
| 109 state->name = text_label_->text(); | 107 state->name = text_label_->text(); |
| 110 } | 108 } |
| 111 | 109 |
| 112 // Overridden from ActionableView: | 110 // Overridden from ActionableView: |
| 113 bool PerformAction(const ui::Event& event) override { | 111 bool PerformAction(const ui::Event& event) override { |
| 114 chromeos::input_method::ImeKeyboard* keyboard = | 112 chromeos::input_method::ImeKeyboard* keyboard = |
| 115 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 113 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 116 if (keyboard) { | 114 if (keyboard) { |
| 117 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 115 WmShell::Get()->RecordUserMetricsAction( |
| 118 keyboard->CapsLockIsEnabled() ? | 116 keyboard->CapsLockIsEnabled() ? |
| 119 ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK : | 117 UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK : |
| 120 ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK); | 118 UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK); |
| 121 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | 119 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
| 122 } | 120 } |
| 123 return true; | 121 return true; |
| 124 } | 122 } |
| 125 | 123 |
| 126 views::Label* text_label_; | 124 views::Label* text_label_; |
| 127 views::Label* shortcut_label_; | 125 views::Label* shortcut_label_; |
| 128 | 126 |
| 129 DISALLOW_COPY_AND_ASSIGN(CapsLockDefaultView); | 127 DISALLOW_COPY_AND_ASSIGN(CapsLockDefaultView); |
| 130 }; | 128 }; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 152 caps_lock_enabled_ = enabled; | 150 caps_lock_enabled_ = enabled; |
| 153 | 151 |
| 154 if (tray_view()) | 152 if (tray_view()) |
| 155 tray_view()->SetVisible(caps_lock_enabled_); | 153 tray_view()->SetVisible(caps_lock_enabled_); |
| 156 | 154 |
| 157 if (default_) { | 155 if (default_) { |
| 158 default_->Update(caps_lock_enabled_); | 156 default_->Update(caps_lock_enabled_); |
| 159 } else { | 157 } else { |
| 160 if (caps_lock_enabled_) { | 158 if (caps_lock_enabled_) { |
| 161 if (!message_shown_) { | 159 if (!message_shown_) { |
| 162 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 160 WmShell::Get()->RecordUserMetricsAction( |
| 163 ash::UMA_STATUS_AREA_CAPS_LOCK_POPUP); | 161 UMA_STATUS_AREA_CAPS_LOCK_POPUP); |
| 164 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 162 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); |
| 165 message_shown_ = true; | 163 message_shown_ = true; |
| 166 } | 164 } |
| 167 } else if (detailed_) { | 165 } else if (detailed_) { |
| 168 detailed_->GetWidget()->Close(); | 166 detailed_->GetWidget()->Close(); |
| 169 } | 167 } |
| 170 } | 168 } |
| 171 } | 169 } |
| 172 | 170 |
| 173 bool TrayCapsLock::GetInitialVisibility() { | 171 bool TrayCapsLock::GetInitialVisibility() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 199 detailed_->AddChildView(image); | 197 detailed_->AddChildView(image); |
| 200 | 198 |
| 201 const int string_id = | 199 const int string_id = |
| 202 WmShell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() | 200 WmShell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() |
| 203 ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH | 201 ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH |
| 204 : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; | 202 : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; |
| 205 views::Label* label = new views::Label(bundle.GetLocalizedString(string_id)); | 203 views::Label* label = new views::Label(bundle.GetLocalizedString(string_id)); |
| 206 label->SetMultiLine(true); | 204 label->SetMultiLine(true); |
| 207 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 205 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 208 detailed_->AddChildView(label); | 206 detailed_->AddChildView(label); |
| 209 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 207 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAPS_LOCK_DETAILED); |
| 210 ash::UMA_STATUS_AREA_CAPS_LOCK_DETAILED); | |
| 211 | 208 |
| 212 return detailed_; | 209 return detailed_; |
| 213 } | 210 } |
| 214 | 211 |
| 215 void TrayCapsLock::DestroyDefaultView() { | 212 void TrayCapsLock::DestroyDefaultView() { |
| 216 default_ = NULL; | 213 default_ = NULL; |
| 217 } | 214 } |
| 218 | 215 |
| 219 void TrayCapsLock::DestroyDetailedView() { | 216 void TrayCapsLock::DestroyDetailedView() { |
| 220 detailed_ = NULL; | 217 detailed_ = NULL; |
| 221 } | 218 } |
| 222 | 219 |
| 223 } // namespace ash | 220 } // namespace ash |
| OLD | NEW |