| 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/common/system/chromeos/tray_caps_lock.h" | 5 #include "ash/common/system/chromeos/tray_caps_lock.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/system/tray/actionable_view.h" | 8 #include "ash/common/system/tray/actionable_view.h" |
| 9 #include "ash/common/system/tray/fixed_sized_image_view.h" | 9 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| 10 #include "ash/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| 11 #include "ash/common/system/tray/tray_constants.h" | 11 #include "ash/common/system/tray/tray_constants.h" |
| 12 #include "ash/common/system/tray/tray_popup_utils.h" |
| 12 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 13 #include "ash/resources/vector_icons/vector_icons.h" | 14 #include "ash/resources/vector_icons/vector_icons.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" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 return (ime && ime->GetImeKeyboard()) | 35 return (ime && ime->GetImeKeyboard()) |
| 35 ? ime->GetImeKeyboard()->CapsLockIsEnabled() | 36 ? ime->GetImeKeyboard()->CapsLockIsEnabled() |
| 36 : false; | 37 : false; |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 class CapsLockDefaultView : public ActionableView { | 41 class CapsLockDefaultView : public ActionableView { |
| 41 public: | 42 public: |
| 42 CapsLockDefaultView() | 43 CapsLockDefaultView() |
| 43 : ActionableView(nullptr), | 44 : ActionableView(nullptr), |
| 44 text_label_(new views::Label), | 45 text_label_(TrayPopupUtils::CreateDefaultLabel()), |
| 45 shortcut_label_(new views::Label) { | 46 shortcut_label_(TrayPopupUtils::CreateDefaultLabel()) { |
| 46 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 47 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 47 kTrayPopupPaddingHorizontal, 0, | 48 kTrayPopupPaddingHorizontal, 0, |
| 48 kTrayPopupPaddingBetweenItems)); | 49 kTrayPopupPaddingBetweenItems)); |
| 49 | 50 |
| 50 FixedSizedImageView* image = | 51 FixedSizedImageView* image = |
| 51 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 52 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
| 52 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { | 53 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { |
| 53 image->SetImage( | 54 image->SetImage( |
| 54 gfx::CreateVectorIcon(kSystemMenuCapsLockIcon, kMenuIconColor)); | 55 gfx::CreateVectorIcon(kSystemMenuCapsLockIcon, kMenuIconColor)); |
| 55 } else { | 56 } else { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 image->SetImage( | 210 image->SetImage( |
| 210 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK).ToImageSkia()); | 211 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK).ToImageSkia()); |
| 211 } | 212 } |
| 212 | 213 |
| 213 detailed_->AddChildView(image); | 214 detailed_->AddChildView(image); |
| 214 | 215 |
| 215 const int string_id = | 216 const int string_id = |
| 216 WmShell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() | 217 WmShell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() |
| 217 ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH | 218 ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH |
| 218 : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; | 219 : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; |
| 219 views::Label* label = new views::Label(bundle.GetLocalizedString(string_id)); | 220 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); |
| 221 label->SetText(bundle.GetLocalizedString(string_id)); |
| 220 label->SetMultiLine(true); | 222 label->SetMultiLine(true); |
| 221 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 223 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 222 detailed_->AddChildView(label); | 224 detailed_->AddChildView(label); |
| 223 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAPS_LOCK_DETAILED); | 225 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAPS_LOCK_DETAILED); |
| 224 | 226 |
| 225 return detailed_; | 227 return detailed_; |
| 226 } | 228 } |
| 227 | 229 |
| 228 void TrayCapsLock::DestroyDefaultView() { | 230 void TrayCapsLock::DestroyDefaultView() { |
| 229 default_ = NULL; | 231 default_ = NULL; |
| 230 } | 232 } |
| 231 | 233 |
| 232 void TrayCapsLock::DestroyDetailedView() { | 234 void TrayCapsLock::DestroyDetailedView() { |
| 233 detailed_ = NULL; | 235 detailed_ = NULL; |
| 234 } | 236 } |
| 235 | 237 |
| 236 } // namespace ash | 238 } // namespace ash |
| OLD | NEW |