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

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: comments 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
« no previous file with comments | « ash/common/system/chromeos/tray_caps_lock.cc ('k') | ash/common/system/tray/tray_image_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/l10n/l10n_util.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(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_TRACING));
47 tri_view->AddView(TriView::Container::CENTER, label); 44 tri_view->AddView(TriView::Container::CENTER, label);
48 45
49 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { 46 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
50 TrayPopupItemStyle style( 47 style.SetupLabel(label);
51 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 48 image->SetImage(
52 style.SetupLabel(label); 49 gfx::CreateVectorIcon(kSystemMenuTracingIcon, style.GetIconColor()));
53 image->SetImage(
54 gfx::CreateVectorIcon(kSystemMenuTracingIcon, style.GetIconColor()));
55 50
56 SetInkDropMode(InkDropHostView::InkDropMode::ON); 51 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 } 52 }
63 53
64 ~DefaultTracingView() override {} 54 ~DefaultTracingView() override {}
65 55
66 private: 56 private:
67 bool PerformAction(const ui::Event& event) override { 57 bool PerformAction(const ui::Event& event) override {
68 WmShell::Get()->RecordUserMetricsAction( 58 WmShell::Get()->RecordUserMetricsAction(
69 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED); 59 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED);
70 WmShell::Get()->system_tray_controller()->ShowChromeSlow(); 60 WmShell::Get()->system_tray_controller()->ShowChromeSlow();
71 CloseSystemBubble(); 61 CloseSystemBubble();
72 return true; 62 return true;
73 } 63 }
74 64
75 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); 65 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView);
76 }; 66 };
77 67
78 } // namespace tray 68 } // namespace tray
79 69
80 //////////////////////////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////////////////////////
81 // ash::TrayTracing 71 // ash::TrayTracing
82 72
83 TrayTracing::TrayTracing(SystemTray* system_tray) 73 TrayTracing::TrayTracing(SystemTray* system_tray)
84 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING, UMA_TRACING), 74 : TrayImageItem(system_tray, kSystemTrayTracingIcon, UMA_TRACING),
85 default_(nullptr) { 75 default_(nullptr) {
86 DCHECK(system_tray); 76 DCHECK(system_tray);
87 WmShell::Get()->system_tray_notifier()->AddTracingObserver(this); 77 WmShell::Get()->system_tray_notifier()->AddTracingObserver(this);
88 } 78 }
89 79
90 TrayTracing::~TrayTracing() { 80 TrayTracing::~TrayTracing() {
91 WmShell::Get()->system_tray_notifier()->RemoveTracingObserver(this); 81 WmShell::Get()->system_tray_notifier()->RemoveTracingObserver(this);
92 } 82 }
93 83
94 void TrayTracing::SetTrayIconVisible(bool visible) { 84 void TrayTracing::SetTrayIconVisible(bool visible) {
(...skipping 20 matching lines...) Expand all
115 default_ = NULL; 105 default_ = NULL;
116 } 106 }
117 107
118 void TrayTracing::DestroyDetailedView() {} 108 void TrayTracing::DestroyDetailedView() {}
119 109
120 void TrayTracing::OnTracingModeChanged(bool value) { 110 void TrayTracing::OnTracingModeChanged(bool value) {
121 SetTrayIconVisible(value); 111 SetTrayIconVisible(value);
122 } 112 }
123 113
124 } // namespace ash 114 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/tray_caps_lock.cc ('k') | ash/common/system/tray/tray_image_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698