| 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/tray_caps_lock.h" | 5 #include "ash/system/tray_caps_lock.h" | 
| 6 | 6 | 
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" | 
| 8 #include "ash/resources/grit/ash_resources.h" | 8 #include "ash/resources/grit/ash_resources.h" | 
| 9 #include "ash/resources/vector_icons/vector_icons.h" | 9 #include "ash/resources/vector_icons/vector_icons.h" | 
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" | 
|  | 11 #include "ash/shell_port.h" | 
| 11 #include "ash/strings/grit/ash_strings.h" | 12 #include "ash/strings/grit/ash_strings.h" | 
| 12 #include "ash/system/tray/actionable_view.h" | 13 #include "ash/system/tray/actionable_view.h" | 
| 13 #include "ash/system/tray/system_tray_delegate.h" | 14 #include "ash/system/tray/system_tray_delegate.h" | 
| 14 #include "ash/system/tray/tray_constants.h" | 15 #include "ash/system/tray/tray_constants.h" | 
| 15 #include "ash/system/tray/tray_popup_item_style.h" | 16 #include "ash/system/tray/tray_popup_item_style.h" | 
| 16 #include "ash/system/tray/tray_popup_utils.h" | 17 #include "ash/system/tray/tray_popup_utils.h" | 
| 17 #include "ash/system/tray/tri_view.h" | 18 #include "ash/system/tray/tri_view.h" | 
| 18 #include "ash/wm_shell.h" |  | 
| 19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" | 
| 20 #include "ui/accessibility/ax_node_data.h" | 20 #include "ui/accessibility/ax_node_data.h" | 
| 21 #include "ui/base/ime/chromeos/ime_keyboard.h" | 21 #include "ui/base/ime/chromeos/ime_keyboard.h" | 
| 22 #include "ui/base/ime/chromeos/input_method_manager.h" | 22 #include "ui/base/ime/chromeos/input_method_manager.h" | 
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" | 
| 24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" | 
| 25 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" | 
| 26 #include "ui/gfx/paint_vector_icon.h" | 26 #include "ui/gfx/paint_vector_icon.h" | 
| 27 #include "ui/views/border.h" | 27 #include "ui/views/border.h" | 
| 28 #include "ui/views/controls/image_view.h" | 28 #include "ui/views/controls/image_view.h" | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 111   void GetAccessibleNodeData(ui::AXNodeData* node_data) override { | 111   void GetAccessibleNodeData(ui::AXNodeData* node_data) override { | 
| 112     node_data->role = ui::AX_ROLE_BUTTON; | 112     node_data->role = ui::AX_ROLE_BUTTON; | 
| 113     node_data->SetName(text_label_->text()); | 113     node_data->SetName(text_label_->text()); | 
| 114   } | 114   } | 
| 115 | 115 | 
| 116   // ActionableView: | 116   // ActionableView: | 
| 117   bool PerformAction(const ui::Event& event) override { | 117   bool PerformAction(const ui::Event& event) override { | 
| 118     chromeos::input_method::ImeKeyboard* keyboard = | 118     chromeos::input_method::ImeKeyboard* keyboard = | 
| 119         chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 119         chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 
| 120     if (keyboard) { | 120     if (keyboard) { | 
| 121       WmShell::Get()->RecordUserMetricsAction( | 121       ShellPort::Get()->RecordUserMetricsAction( | 
| 122           keyboard->CapsLockIsEnabled() | 122           keyboard->CapsLockIsEnabled() | 
| 123               ? UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK | 123               ? UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK | 
| 124               : UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK); | 124               : UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK); | 
| 125       keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | 125       keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | 
| 126     } | 126     } | 
| 127     return true; | 127     return true; | 
| 128   } | 128   } | 
| 129 | 129 | 
| 130   // It indicates whether the Caps Lock is on or off. | 130   // It indicates whether the Caps Lock is on or off. | 
| 131   views::Label* text_label_; | 131   views::Label* text_label_; | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 163       enabled ? A11Y_ALERT_CAPS_ON : A11Y_ALERT_CAPS_OFF); | 163       enabled ? A11Y_ALERT_CAPS_ON : A11Y_ALERT_CAPS_OFF); | 
| 164 | 164 | 
| 165   if (tray_view()) | 165   if (tray_view()) | 
| 166     tray_view()->SetVisible(caps_lock_enabled_); | 166     tray_view()->SetVisible(caps_lock_enabled_); | 
| 167 | 167 | 
| 168   if (default_) { | 168   if (default_) { | 
| 169     default_->Update(caps_lock_enabled_); | 169     default_->Update(caps_lock_enabled_); | 
| 170   } else { | 170   } else { | 
| 171     if (caps_lock_enabled_) { | 171     if (caps_lock_enabled_) { | 
| 172       if (!message_shown_) { | 172       if (!message_shown_) { | 
| 173         WmShell::Get()->RecordUserMetricsAction( | 173         ShellPort::Get()->RecordUserMetricsAction( | 
| 174             UMA_STATUS_AREA_CAPS_LOCK_POPUP); | 174             UMA_STATUS_AREA_CAPS_LOCK_POPUP); | 
| 175         ShowDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 175         ShowDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 
| 176         message_shown_ = true; | 176         message_shown_ = true; | 
| 177       } | 177       } | 
| 178     } else if (detailed_) { | 178     } else if (detailed_) { | 
| 179       detailed_->GetWidget()->Close(); | 179       detailed_->GetWidget()->Close(); | 
| 180     } | 180     } | 
| 181   } | 181   } | 
| 182 } | 182 } | 
| 183 | 183 | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 210 | 210 | 
| 211   const int string_id = | 211   const int string_id = | 
| 212       Shell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() | 212       Shell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() | 
| 213           ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH | 213           ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH | 
| 214           : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; | 214           : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; | 
| 215   views::Label* label = TrayPopupUtils::CreateDefaultLabel(); | 215   views::Label* label = TrayPopupUtils::CreateDefaultLabel(); | 
| 216   label->SetText(bundle.GetLocalizedString(string_id)); | 216   label->SetText(bundle.GetLocalizedString(string_id)); | 
| 217   label->SetMultiLine(true); | 217   label->SetMultiLine(true); | 
| 218   label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 218   label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 
| 219   detailed_->AddChildView(label); | 219   detailed_->AddChildView(label); | 
| 220   WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAPS_LOCK_DETAILED); | 220   ShellPort::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAPS_LOCK_DETAILED); | 
| 221 | 221 | 
| 222   return detailed_; | 222   return detailed_; | 
| 223 } | 223 } | 
| 224 | 224 | 
| 225 void TrayCapsLock::DestroyDefaultView() { | 225 void TrayCapsLock::DestroyDefaultView() { | 
| 226   default_ = nullptr; | 226   default_ = nullptr; | 
| 227 } | 227 } | 
| 228 | 228 | 
| 229 void TrayCapsLock::DestroyDetailedView() { | 229 void TrayCapsLock::DestroyDetailedView() { | 
| 230   detailed_ = nullptr; | 230   detailed_ = nullptr; | 
| 231 } | 231 } | 
| 232 | 232 | 
| 233 }  // namespace ash | 233 }  // namespace ash | 
| OLD | NEW | 
|---|