Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: ash/common/system/chromeos/tray_tracing.cc

Issue 2700653002: [Ash MD] Remove pre-MD code from TrayImageItem and subclasses (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "ash/common/metrics/user_metrics_action.h" 7 #include "ash/common/metrics/user_metrics_action.h"
9 #include "ash/common/system/tray/actionable_view.h" 8 #include "ash/common/system/tray/actionable_view.h"
10 #include "ash/common/system/tray/fixed_sized_image_view.h" 9 #include "ash/common/system/tray/fixed_sized_image_view.h"
11 #include "ash/common/system/tray/system_tray.h" 10 #include "ash/common/system/tray/system_tray.h"
12 #include "ash/common/system/tray/system_tray_controller.h" 11 #include "ash/common/system/tray/system_tray_controller.h"
13 #include "ash/common/system/tray/system_tray_notifier.h" 12 #include "ash/common/system/tray/system_tray_notifier.h"
14 #include "ash/common/system/tray/tray_constants.h" 13 #include "ash/common/system/tray/tray_constants.h"
15 #include "ash/common/system/tray/tray_popup_item_style.h" 14 #include "ash/common/system/tray/tray_popup_item_style.h"
16 #include "ash/common/system/tray/tray_popup_utils.h" 15 #include "ash/common/system/tray/tray_popup_utils.h"
17 #include "ash/common/system/tray/tri_view.h" 16 #include "ash/common/system/tray/tri_view.h"
18 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
19 #include "ash/resources/vector_icons/vector_icons.h" 18 #include "ash/resources/vector_icons/vector_icons.h"
20 #include "grit/ash_resources.h"
21 #include "grit/ash_strings.h" 19 #include "grit/ash_strings.h"
22 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
24 #include "ui/gfx/paint_vector_icon.h" 22 #include "ui/gfx/paint_vector_icon.h"
25 #include "ui/views/controls/image_view.h" 23 #include "ui/views/controls/image_view.h"
26 #include "ui/views/controls/label.h" 24 #include "ui/views/controls/label.h"
27 #include "ui/views/layout/fill_layout.h" 25 #include "ui/views/layout/fill_layout.h"
28 26
29 namespace ash { 27 namespace ash {
30 namespace tray { 28 namespace tray {
31 29
32 class DefaultTracingView : public ActionableView { 30 class DefaultTracingView : public ActionableView {
33 public: 31 public:
34 explicit DefaultTracingView(SystemTrayItem* owner) 32 explicit DefaultTracingView(SystemTrayItem* owner)
35 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) { 33 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) {
36 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
37
38 SetLayoutManager(new views::FillLayout); 34 SetLayoutManager(new views::FillLayout);
39 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); 35 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
40 AddChildView(tri_view); 36 AddChildView(tri_view);
37
41 auto image = TrayPopupUtils::CreateMainImageView(); 38 auto image = TrayPopupUtils::CreateMainImageView();
42 tri_view->AddView(TriView::Container::START, image); 39 tri_view->AddView(TriView::Container::START, image);
43 40
44 auto label = TrayPopupUtils::CreateDefaultLabel(); 41 auto label = TrayPopupUtils::CreateDefaultLabel();
45 label->SetMultiLine(true); 42 label->SetMultiLine(true);
46 label->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); 43 label->SetText(ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
44 IDS_ASH_STATUS_TRAY_TRACING));
47 tri_view->AddView(TriView::Container::CENTER, label); 45 tri_view->AddView(TriView::Container::CENTER, label);
48 46
49 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { 47 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
50 TrayPopupItemStyle style( 48 style.SetupLabel(label);
51 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 49 image->SetImage(
52 style.SetupLabel(label); 50 gfx::CreateVectorIcon(kSystemMenuTracingIcon, style.GetIconColor()));
53 image->SetImage(
54 gfx::CreateVectorIcon(kSystemMenuTracingIcon, style.GetIconColor()));
55 51
56 SetInkDropMode(InkDropHostView::InkDropMode::ON); 52 SetInkDropMode(InkDropHostView::InkDropMode::ON);
57 } else {
58 // The icon doesn't change in non-md.
59 image->SetImage(
60 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia());
61 }
62 } 53 }
63 54
64 ~DefaultTracingView() override {} 55 ~DefaultTracingView() override {}
65 56
66 private: 57 private:
67 bool PerformAction(const ui::Event& event) override { 58 bool PerformAction(const ui::Event& event) override {
68 WmShell::Get()->RecordUserMetricsAction( 59 WmShell::Get()->RecordUserMetricsAction(
69 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED); 60 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED);
70 WmShell::Get()->system_tray_controller()->ShowChromeSlow(); 61 WmShell::Get()->system_tray_controller()->ShowChromeSlow();
71 CloseSystemBubble(); 62 CloseSystemBubble();
72 return true; 63 return true;
73 } 64 }
74 65
75 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); 66 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView);
76 }; 67 };
77 68
78 } // namespace tray 69 } // namespace tray
79 70
80 //////////////////////////////////////////////////////////////////////////////// 71 ////////////////////////////////////////////////////////////////////////////////
81 // ash::TrayTracing 72 // ash::TrayTracing
82 73
83 TrayTracing::TrayTracing(SystemTray* system_tray) 74 TrayTracing::TrayTracing(SystemTray* system_tray)
84 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING, UMA_TRACING), 75 : TrayImageItem(system_tray, kSystemTrayTracingIcon, UMA_TRACING),
85 default_(nullptr) { 76 default_(nullptr) {
86 DCHECK(system_tray); 77 DCHECK(system_tray);
87 WmShell::Get()->system_tray_notifier()->AddTracingObserver(this); 78 WmShell::Get()->system_tray_notifier()->AddTracingObserver(this);
88 } 79 }
89 80
90 TrayTracing::~TrayTracing() { 81 TrayTracing::~TrayTracing() {
91 WmShell::Get()->system_tray_notifier()->RemoveTracingObserver(this); 82 WmShell::Get()->system_tray_notifier()->RemoveTracingObserver(this);
92 } 83 }
93 84
94 void TrayTracing::SetTrayIconVisible(bool visible) { 85 void TrayTracing::SetTrayIconVisible(bool visible) {
(...skipping 20 matching lines...) Expand all
115 default_ = NULL; 106 default_ = NULL;
116 } 107 }
117 108
118 void TrayTracing::DestroyDetailedView() {} 109 void TrayTracing::DestroyDetailedView() {}
119 110
120 void TrayTracing::OnTracingModeChanged(bool value) { 111 void TrayTracing::OnTracingModeChanged(bool value) {
121 SetTrayIconVisible(value); 112 SetTrayIconVisible(value);
122 } 113 }
123 114
124 } // namespace ash 115 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698