OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/common/system/chromeos/tray_tracing.h" | |
6 | |
7 #include "ash/common/metrics/user_metrics_action.h" | |
8 #include "ash/common/system/tray/actionable_view.h" | |
9 #include "ash/common/system/tray/fixed_sized_image_view.h" | |
10 #include "ash/common/system/tray/system_tray.h" | |
11 #include "ash/common/system/tray/system_tray_controller.h" | |
12 #include "ash/common/system/tray/system_tray_notifier.h" | |
13 #include "ash/common/system/tray/tray_constants.h" | |
14 #include "ash/common/system/tray/tray_popup_item_style.h" | |
15 #include "ash/common/system/tray/tray_popup_utils.h" | |
16 #include "ash/common/system/tray/tri_view.h" | |
17 #include "ash/common/wm_shell.h" | |
18 #include "ash/resources/vector_icons/vector_icons.h" | |
19 #include "ash/strings/grit/ash_strings.h" | |
20 #include "ui/base/l10n/l10n_util.h" | |
21 #include "ui/gfx/image/image.h" | |
22 #include "ui/gfx/paint_vector_icon.h" | |
23 #include "ui/views/controls/image_view.h" | |
24 #include "ui/views/controls/label.h" | |
25 #include "ui/views/layout/fill_layout.h" | |
26 | |
27 namespace ash { | |
28 namespace tray { | |
29 | |
30 class DefaultTracingView : public ActionableView { | |
31 public: | |
32 explicit DefaultTracingView(SystemTrayItem* owner) | |
33 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) { | |
34 SetLayoutManager(new views::FillLayout); | |
35 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); | |
36 AddChildView(tri_view); | |
37 | |
38 auto* image = TrayPopupUtils::CreateMainImageView(); | |
39 tri_view->AddView(TriView::Container::START, image); | |
40 | |
41 auto* label = TrayPopupUtils::CreateDefaultLabel(); | |
42 label->SetMultiLine(true); | |
43 label->SetText(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_TRACING)); | |
44 tri_view->AddView(TriView::Container::CENTER, label); | |
45 | |
46 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | |
47 style.SetupLabel(label); | |
48 image->SetImage( | |
49 gfx::CreateVectorIcon(kSystemMenuTracingIcon, style.GetIconColor())); | |
50 | |
51 SetInkDropMode(InkDropHostView::InkDropMode::ON); | |
52 } | |
53 | |
54 ~DefaultTracingView() override {} | |
55 | |
56 private: | |
57 bool PerformAction(const ui::Event& event) override { | |
58 WmShell::Get()->RecordUserMetricsAction( | |
59 UMA_STATUS_AREA_TRACING_DEFAULT_SELECTED); | |
60 WmShell::Get()->system_tray_controller()->ShowChromeSlow(); | |
61 CloseSystemBubble(); | |
62 return true; | |
63 } | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); | |
66 }; | |
67 | |
68 } // namespace tray | |
69 | |
70 //////////////////////////////////////////////////////////////////////////////// | |
71 // ash::TrayTracing | |
72 | |
73 TrayTracing::TrayTracing(SystemTray* system_tray) | |
74 : TrayImageItem(system_tray, kSystemTrayTracingIcon, UMA_TRACING), | |
75 default_(nullptr) { | |
76 DCHECK(system_tray); | |
77 WmShell::Get()->system_tray_notifier()->AddTracingObserver(this); | |
78 } | |
79 | |
80 TrayTracing::~TrayTracing() { | |
81 WmShell::Get()->system_tray_notifier()->RemoveTracingObserver(this); | |
82 } | |
83 | |
84 void TrayTracing::SetTrayIconVisible(bool visible) { | |
85 if (tray_view()) | |
86 tray_view()->SetVisible(visible); | |
87 } | |
88 | |
89 bool TrayTracing::GetInitialVisibility() { | |
90 return false; | |
91 } | |
92 | |
93 views::View* TrayTracing::CreateDefaultView(LoginStatus status) { | |
94 CHECK(default_ == NULL); | |
95 if (tray_view() && tray_view()->visible()) | |
96 default_ = new tray::DefaultTracingView(this); | |
97 return default_; | |
98 } | |
99 | |
100 views::View* TrayTracing::CreateDetailedView(LoginStatus status) { | |
101 return NULL; | |
102 } | |
103 | |
104 void TrayTracing::DestroyDefaultView() { | |
105 default_ = NULL; | |
106 } | |
107 | |
108 void TrayTracing::DestroyDetailedView() {} | |
109 | |
110 void TrayTracing::OnTracingModeChanged(bool value) { | |
111 SetTrayIconVisible(value); | |
112 } | |
113 | |
114 } // namespace ash | |
OLD | NEW |