| 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/fixed_sized_image_view.h" | 7 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| 8 #include "ash/common/system/tray/system_tray_delegate.h" | 8 #include "ash/common/system/tray/system_tray_delegate.h" |
| 9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
| 10 #include "ash/common/wm_shell.h" |
| 10 #include "ash/metrics/user_metrics_recorder.h" | 11 #include "ash/metrics/user_metrics_recorder.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/system/tray/actionable_view.h" | 13 #include "ash/system/tray/actionable_view.h" |
| 13 #include "ash/system/tray/system_tray_notifier.h" | 14 #include "ash/system/tray/system_tray_notifier.h" |
| 14 #include "base/sys_info.h" | 15 #include "base/sys_info.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/ime/chromeos/ime_keyboard.h" | 19 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 19 #include "ui/base/ime/chromeos/input_method_manager.h" | 20 #include "ui/base/ime/chromeos/input_method_manager.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 66 |
| 66 // Updates the label text and the shortcut text. | 67 // Updates the label text and the shortcut text. |
| 67 void Update(bool caps_lock_enabled) { | 68 void Update(bool caps_lock_enabled) { |
| 68 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 69 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 69 const int text_string_id = caps_lock_enabled ? | 70 const int text_string_id = caps_lock_enabled ? |
| 70 IDS_ASH_STATUS_TRAY_CAPS_LOCK_ENABLED : | 71 IDS_ASH_STATUS_TRAY_CAPS_LOCK_ENABLED : |
| 71 IDS_ASH_STATUS_TRAY_CAPS_LOCK_DISABLED; | 72 IDS_ASH_STATUS_TRAY_CAPS_LOCK_DISABLED; |
| 72 text_label_->SetText(bundle.GetLocalizedString(text_string_id)); | 73 text_label_->SetText(bundle.GetLocalizedString(text_string_id)); |
| 73 | 74 |
| 74 int shortcut_string_id = 0; | 75 int shortcut_string_id = 0; |
| 75 bool search_mapped_to_caps_lock = Shell::GetInstance()-> | 76 bool search_mapped_to_caps_lock = |
| 76 system_tray_delegate()->IsSearchKeyMappedToCapsLock(); | 77 WmShell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock(); |
| 77 if (caps_lock_enabled) { | 78 if (caps_lock_enabled) { |
| 78 shortcut_string_id = search_mapped_to_caps_lock ? | 79 shortcut_string_id = search_mapped_to_caps_lock ? |
| 79 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH_OR_SHIFT : | 80 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH_OR_SHIFT : |
| 80 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH_OR_SHIFT; | 81 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH_OR_SHIFT; |
| 81 } else { | 82 } else { |
| 82 shortcut_string_id = search_mapped_to_caps_lock ? | 83 shortcut_string_id = search_mapped_to_caps_lock ? |
| 83 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH : | 84 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH : |
| 84 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH; | 85 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH; |
| 85 } | 86 } |
| 86 shortcut_label_->SetText(bundle.GetLocalizedString(shortcut_string_id)); | 87 shortcut_label_->SetText(bundle.GetLocalizedString(shortcut_string_id)); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 views::BoxLayout(views::BoxLayout::kHorizontal, | 191 views::BoxLayout(views::BoxLayout::kHorizontal, |
| 191 kTrayPopupPaddingHorizontal, 10, kTrayPopupPaddingBetweenItems)); | 192 kTrayPopupPaddingHorizontal, 10, kTrayPopupPaddingBetweenItems)); |
| 192 | 193 |
| 193 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 194 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 194 views::ImageView* image = new views::ImageView; | 195 views::ImageView* image = new views::ImageView; |
| 195 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK). | 196 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK). |
| 196 ToImageSkia()); | 197 ToImageSkia()); |
| 197 | 198 |
| 198 detailed_->AddChildView(image); | 199 detailed_->AddChildView(image); |
| 199 | 200 |
| 200 const int string_id = Shell::GetInstance()->system_tray_delegate()-> | 201 const int string_id = |
| 201 IsSearchKeyMappedToCapsLock() ? | 202 WmShell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() |
| 202 IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH : | 203 ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH |
| 203 IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; | 204 : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; |
| 204 views::Label* label = new views::Label(bundle.GetLocalizedString(string_id)); | 205 views::Label* label = new views::Label(bundle.GetLocalizedString(string_id)); |
| 205 label->SetMultiLine(true); | 206 label->SetMultiLine(true); |
| 206 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 207 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 207 detailed_->AddChildView(label); | 208 detailed_->AddChildView(label); |
| 208 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 209 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 209 ash::UMA_STATUS_AREA_CAPS_LOCK_DETAILED); | 210 ash::UMA_STATUS_AREA_CAPS_LOCK_DETAILED); |
| 210 | 211 |
| 211 return detailed_; | 212 return detailed_; |
| 212 } | 213 } |
| 213 | 214 |
| 214 void TrayCapsLock::DestroyDefaultView() { | 215 void TrayCapsLock::DestroyDefaultView() { |
| 215 default_ = NULL; | 216 default_ = NULL; |
| 216 } | 217 } |
| 217 | 218 |
| 218 void TrayCapsLock::DestroyDetailedView() { | 219 void TrayCapsLock::DestroyDetailedView() { |
| 219 detailed_ = NULL; | 220 detailed_ = NULL; |
| 220 } | 221 } |
| 221 | 222 |
| 222 } // namespace ash | 223 } // namespace ash |
| OLD | NEW |