| 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/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "ash/resources/vector_icons/vector_icons.h" |
| 13 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
| 14 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| 15 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
| 16 #include "ui/accessibility/ax_view_state.h" | 17 #include "ui/accessibility/ax_view_state.h" |
| 17 #include "ui/base/ime/chromeos/ime_keyboard.h" | 18 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 18 #include "ui/base/ime/chromeos/input_method_manager.h" | 19 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
| 21 #include "ui/gfx/paint_vector_icon.h" | 22 #include "ui/gfx/paint_vector_icon.h" |
| 22 #include "ui/gfx/vector_icons_public.h" | |
| 23 #include "ui/views/controls/image_view.h" | 23 #include "ui/views/controls/image_view.h" |
| 24 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 25 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
| 26 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
| 27 | 27 |
| 28 namespace ash { | 28 namespace ash { |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 bool CapsLockIsEnabled() { | 31 bool CapsLockIsEnabled() { |
| 32 chromeos::input_method::InputMethodManager* ime = | 32 chromeos::input_method::InputMethodManager* ime = |
| 33 chromeos::input_method::InputMethodManager::Get(); | 33 chromeos::input_method::InputMethodManager::Get(); |
| 34 return (ime && ime->GetImeKeyboard()) | 34 return (ime && ime->GetImeKeyboard()) |
| 35 ? ime->GetImeKeyboard()->CapsLockIsEnabled() | 35 ? ime->GetImeKeyboard()->CapsLockIsEnabled() |
| 36 : false; | 36 : false; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 class CapsLockDefaultView : public ActionableView { | 40 class CapsLockDefaultView : public ActionableView { |
| 41 public: | 41 public: |
| 42 CapsLockDefaultView() | 42 CapsLockDefaultView() |
| 43 : text_label_(new views::Label), shortcut_label_(new views::Label) { | 43 : text_label_(new views::Label), shortcut_label_(new views::Label) { |
| 44 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 44 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 45 kTrayPopupPaddingHorizontal, 0, | 45 kTrayPopupPaddingHorizontal, 0, |
| 46 kTrayPopupPaddingBetweenItems)); | 46 kTrayPopupPaddingBetweenItems)); |
| 47 | 47 |
| 48 FixedSizedImageView* image = | 48 FixedSizedImageView* image = |
| 49 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 49 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
| 50 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { | 50 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { |
| 51 image->SetImage(gfx::CreateVectorIcon( | 51 image->SetImage( |
| 52 gfx::VectorIconId::SYSTEM_MENU_CAPS_LOCK, kMenuIconColor)); | 52 gfx::CreateVectorIcon(kSystemMenuCapsLockIcon, kMenuIconColor)); |
| 53 } else { | 53 } else { |
| 54 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 54 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 55 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK) | 55 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK) |
| 56 .ToImageSkia()); | 56 .ToImageSkia()); |
| 57 } | 57 } |
| 58 AddChildView(image); | 58 AddChildView(image); |
| 59 | 59 |
| 60 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 60 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 61 AddChildView(text_label_); | 61 AddChildView(text_label_); |
| 62 | 62 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 DCHECK(detailed_ == NULL); | 191 DCHECK(detailed_ == NULL); |
| 192 detailed_ = new views::View; | 192 detailed_ = new views::View; |
| 193 | 193 |
| 194 detailed_->SetLayoutManager(new views::BoxLayout( | 194 detailed_->SetLayoutManager(new views::BoxLayout( |
| 195 views::BoxLayout::kHorizontal, kTrayPopupPaddingHorizontal, 10, | 195 views::BoxLayout::kHorizontal, kTrayPopupPaddingHorizontal, 10, |
| 196 kTrayPopupPaddingBetweenItems)); | 196 kTrayPopupPaddingBetweenItems)); |
| 197 | 197 |
| 198 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 198 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 199 views::ImageView* image = new views::ImageView; | 199 views::ImageView* image = new views::ImageView; |
| 200 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { | 200 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { |
| 201 image->SetImage(CreateVectorIcon(gfx::VectorIconId::SYSTEM_MENU_CAPS_LOCK, | 201 image->SetImage(CreateVectorIcon(kSystemMenuCapsLockIcon, kMenuIconSize, |
| 202 kMenuIconSize, kMenuIconColor)); | 202 kMenuIconColor)); |
| 203 } else { | 203 } else { |
| 204 image->SetImage( | 204 image->SetImage( |
| 205 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK).ToImageSkia()); | 205 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK).ToImageSkia()); |
| 206 } | 206 } |
| 207 | 207 |
| 208 detailed_->AddChildView(image); | 208 detailed_->AddChildView(image); |
| 209 | 209 |
| 210 const int string_id = | 210 const int string_id = |
| 211 WmShell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() | 211 WmShell::Get()->system_tray_delegate()->IsSearchKeyMappedToCapsLock() |
| 212 ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH | 212 ? IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_SEARCH |
| 213 : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; | 213 : IDS_ASH_STATUS_TRAY_CAPS_LOCK_CANCEL_BY_ALT_SEARCH; |
| 214 views::Label* label = new views::Label(bundle.GetLocalizedString(string_id)); | 214 views::Label* label = new views::Label(bundle.GetLocalizedString(string_id)); |
| 215 label->SetMultiLine(true); | 215 label->SetMultiLine(true); |
| 216 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 216 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 217 detailed_->AddChildView(label); | 217 detailed_->AddChildView(label); |
| 218 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAPS_LOCK_DETAILED); | 218 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAPS_LOCK_DETAILED); |
| 219 | 219 |
| 220 return detailed_; | 220 return detailed_; |
| 221 } | 221 } |
| 222 | 222 |
| 223 void TrayCapsLock::DestroyDefaultView() { | 223 void TrayCapsLock::DestroyDefaultView() { |
| 224 default_ = NULL; | 224 default_ = NULL; |
| 225 } | 225 } |
| 226 | 226 |
| 227 void TrayCapsLock::DestroyDetailedView() { | 227 void TrayCapsLock::DestroyDetailedView() { |
| 228 detailed_ = NULL; | 228 detailed_ = NULL; |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace ash | 231 } // namespace ash |
| OLD | NEW |