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

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

Issue 2091953002: mash: Move TrayTracing to //ash/common/system/chromeos (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 6 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/system/chromeos/tray_tracing.h ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/system/chromeos/tray_tracing.h"
6
7 #include "ash/common/system/tray/actionable_view.h"
8 #include "ash/common/system/tray/fixed_sized_image_view.h"
9 #include "ash/common/system/tray/system_tray_delegate.h"
10 #include "ash/common/system/tray/tray_constants.h"
11 #include "ash/common/wm_shell.h"
12 #include "ash/shell.h"
13 #include "ash/system/tray/system_tray.h"
14 #include "ash/system/tray/system_tray_notifier.h"
15 #include "grit/ash_resources.h"
16 #include "grit/ash_strings.h"
17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/image/image.h"
19 #include "ui/views/controls/image_view.h"
20 #include "ui/views/controls/label.h"
21 #include "ui/views/layout/box_layout.h"
22
23 namespace ash {
24 namespace tray {
25
26 class DefaultTracingView : public ActionableView {
27 public:
28 DefaultTracingView() {
29 SetLayoutManager(new views::BoxLayout(
30 views::BoxLayout::kHorizontal,
31 kTrayPopupPaddingHorizontal, 0,
32 kTrayPopupPaddingBetweenItems));
33
34 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
35 image_ = new FixedSizedImageView(0, kTrayPopupItemHeight);
36 image_->SetImage(
37 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia());
38 AddChildView(image_);
39
40 label_ = new views::Label();
41 label_->SetMultiLine(true);
42 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
43 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING));
44 AddChildView(label_);
45 }
46
47 ~DefaultTracingView() override {}
48
49 private:
50 // Overridden from ActionableView.
51 bool PerformAction(const ui::Event& event) override {
52 WmShell::Get()->system_tray_delegate()->ShowChromeSlow();
53 return true;
54 }
55
56 views::ImageView* image_;
57 views::Label* label_;
58
59 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView);
60 };
61
62 } // namespace tray
63
64 ////////////////////////////////////////////////////////////////////////////////
65 // ash::TrayTracing
66
67 TrayTracing::TrayTracing(SystemTray* system_tray)
68 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING),
69 default_(NULL) {
70 DCHECK(Shell::GetInstance()->delegate());
71 DCHECK(system_tray);
72 Shell::GetInstance()->system_tray_notifier()->AddTracingObserver(this);
73 }
74
75 TrayTracing::~TrayTracing() {
76 Shell::GetInstance()->system_tray_notifier()->RemoveTracingObserver(this);
77 }
78
79 void TrayTracing::SetTrayIconVisible(bool visible) {
80 if (tray_view())
81 tray_view()->SetVisible(visible);
82 }
83
84 bool TrayTracing::GetInitialVisibility() {
85 return false;
86 }
87
88 views::View* TrayTracing::CreateDefaultView(LoginStatus status) {
89 CHECK(default_ == NULL);
90 if (tray_view() && tray_view()->visible())
91 default_ = new tray::DefaultTracingView();
92 return default_;
93 }
94
95 views::View* TrayTracing::CreateDetailedView(LoginStatus status) {
96 return NULL;
97 }
98
99 void TrayTracing::DestroyDefaultView() {
100 default_ = NULL;
101 }
102
103 void TrayTracing::DestroyDetailedView() {
104 }
105
106 void TrayTracing::OnTracingModeChanged(bool value) {
107 SetTrayIconVisible(value);
108 }
109
110 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/tray_tracing.h ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698