OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_tracing.h" | 5 #include "ash/common/system/chromeos/tray_tracing.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/metrics/user_metrics_action.h" | 8 #include "ash/common/metrics/user_metrics_action.h" |
9 #include "ash/common/system/tray/actionable_view.h" | 9 #include "ash/common/system/tray/actionable_view.h" |
10 #include "ash/common/system/tray/fixed_sized_image_view.h" | 10 #include "ash/common/system/tray/fixed_sized_image_view.h" |
11 #include "ash/common/system/tray/system_tray.h" | 11 #include "ash/common/system/tray/system_tray.h" |
12 #include "ash/common/system/tray/system_tray_delegate.h" | 12 #include "ash/common/system/tray/system_tray_delegate.h" |
13 #include "ash/common/system/tray/system_tray_notifier.h" | 13 #include "ash/common/system/tray/system_tray_notifier.h" |
14 #include "ash/common/system/tray/tray_constants.h" | 14 #include "ash/common/system/tray/tray_constants.h" |
| 15 #include "ash/common/system/tray/tray_popup_item_style.h" |
15 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
16 #include "grit/ash_resources.h" | 17 #include "grit/ash_resources.h" |
17 #include "grit/ash_strings.h" | 18 #include "grit/ash_strings.h" |
18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
20 #include "ui/gfx/paint_vector_icon.h" | 21 #include "ui/gfx/paint_vector_icon.h" |
21 #include "ui/gfx/vector_icons_public.h" | 22 #include "ui/gfx/vector_icons_public.h" |
22 #include "ui/views/controls/image_view.h" | 23 #include "ui/views/controls/image_view.h" |
23 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
24 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
25 | 26 |
26 namespace ash { | 27 namespace ash { |
27 namespace tray { | 28 namespace tray { |
28 | 29 |
29 class DefaultTracingView : public ActionableView { | 30 class DefaultTracingView : public ActionableView { |
30 public: | 31 public: |
31 DefaultTracingView() { | 32 DefaultTracingView() { |
32 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 33 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
33 kTrayPopupPaddingHorizontal, 0, | 34 kTrayPopupPaddingHorizontal, 0, |
34 kTrayPopupPaddingBetweenItems)); | 35 kTrayPopupPaddingBetweenItems)); |
35 | 36 |
36 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 37 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
37 image_ = | 38 image_ = |
38 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 39 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
39 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { | 40 if (!MaterialDesignController::UseMaterialDesignSystemIcons()) { |
40 // TODO(tdanderson): Update the icon used for tracing or remove it from | 41 // The icon doesn't change in non-md. |
41 // the system menu. See crbug.com/625691. | |
42 image_->SetImage(CreateVectorIcon(gfx::VectorIconId::CODE, kMenuIconSize, | |
43 kMenuIconColor)); | |
44 } else { | |
45 image_->SetImage( | 42 image_->SetImage( |
46 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); | 43 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); |
47 } | 44 } |
48 AddChildView(image_); | 45 AddChildView(image_); |
49 | 46 |
50 label_ = new views::Label(); | 47 label_ = new views::Label(); |
51 label_->SetMultiLine(true); | 48 label_->SetMultiLine(true); |
52 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 49 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
53 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); | 50 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); |
54 AddChildView(label_); | 51 AddChildView(label_); |
55 } | 52 } |
56 | 53 |
57 ~DefaultTracingView() override {} | 54 ~DefaultTracingView() override {} |
58 | 55 |
59 private: | 56 private: |
60 // Overridden from ActionableView. | 57 // ActionableView: |
| 58 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
| 59 ActionableView::OnNativeThemeChanged(theme); |
| 60 |
| 61 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 62 return; |
| 63 |
| 64 TrayPopupItemStyle style(GetNativeTheme(), |
| 65 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
| 66 style.SetupLabel(label_); |
| 67 |
| 68 // TODO(tdanderson): Update the icon used for tracing or remove it from |
| 69 // the system menu. See crbug.com/625691. |
| 70 image_->SetImage(CreateVectorIcon(gfx::VectorIconId::CODE, kMenuIconSize, |
| 71 style.GetForegroundColor())); |
| 72 } |
| 73 |
61 bool PerformAction(const ui::Event& event) override { | 74 bool PerformAction(const ui::Event& event) override { |
62 WmShell::Get()->RecordUserMetricsAction( | 75 WmShell::Get()->RecordUserMetricsAction( |
63 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED); | 76 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED); |
64 WmShell::Get()->system_tray_delegate()->ShowChromeSlow(); | 77 WmShell::Get()->system_tray_delegate()->ShowChromeSlow(); |
65 return true; | 78 return true; |
66 } | 79 } |
67 | 80 |
68 views::ImageView* image_; | 81 views::ImageView* image_; |
69 views::Label* label_; | 82 views::Label* label_; |
70 | 83 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 default_ = NULL; | 124 default_ = NULL; |
112 } | 125 } |
113 | 126 |
114 void TrayTracing::DestroyDetailedView() {} | 127 void TrayTracing::DestroyDetailedView() {} |
115 | 128 |
116 void TrayTracing::OnTracingModeChanged(bool value) { | 129 void TrayTracing::OnTracingModeChanged(bool value) { |
117 SetTrayIconVisible(value); | 130 SetTrayIconVisible(value); |
118 } | 131 } |
119 | 132 |
120 } // namespace ash | 133 } // namespace ash |
OLD | NEW |