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.
5 #include "ash/system/chromeos/tray_tracing.h"
8 #include "ash/system/tray/actionable_view.h"
9 #include "ash/system/tray/fixed_sized_image_view.h"
10 #include "ash/system/tray/system_tray.h"
11 #include "ash/system/tray/system_tray_delegate.h"
12 #include "ash/system/tray/system_tray_notifier.h"
13 #include "ash/system/tray/tray_constants.h"
14 #include "grit/ash_resources.h"
15 #include "grit/ash_strings.h"
16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/image/image.h"
18 #include "ui/views/controls/image_view.h"
19 #include "ui/views/controls/label.h"
20 #include "ui/views/layout/box_layout.h"
25 class DefaultTracingView
: public ActionableView
{
27 DefaultTracingView() {
28 SetLayoutManager(new views::BoxLayout(
29 views::BoxLayout::kHorizontal
,
30 kTrayPopupPaddingHorizontal
, 0,
31 kTrayPopupPaddingBetweenItems
));
33 ui::ResourceBundle
& bundle
= ui::ResourceBundle::GetSharedInstance();
34 image_
= new FixedSizedImageView(0, kTrayPopupItemHeight
);
36 bundle
.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING
).ToImageSkia());
39 label_
= new views::Label();
40 label_
->SetMultiLine(true);
41 label_
->SetHorizontalAlignment(gfx::ALIGN_LEFT
);
42 label_
->SetText(bundle
.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING
));
46 virtual ~DefaultTracingView() {}
49 // Overridden from ActionableView.
50 virtual bool PerformAction(const ui::Event
& event
) OVERRIDE
{
51 Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow();
55 views::ImageView
* image_
;
58 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView
);
63 ////////////////////////////////////////////////////////////////////////////////
66 TrayTracing::TrayTracing(SystemTray
* system_tray
)
67 : TrayImageItem(system_tray
, IDR_AURA_UBER_TRAY_TRACING
),
69 DCHECK(Shell::GetInstance()->delegate());
71 Shell::GetInstance()->system_tray_notifier()->AddTracingObserver(this);
74 TrayTracing::~TrayTracing() {
75 Shell::GetInstance()->system_tray_notifier()->RemoveTracingObserver(this);
78 void TrayTracing::SetTrayIconVisible(bool visible
) {
80 tray_view()->SetVisible(visible
);
83 bool TrayTracing::GetInitialVisibility() {
87 views::View
* TrayTracing::CreateDefaultView(user::LoginStatus status
) {
88 CHECK(default_
== NULL
);
89 if (tray_view() && tray_view()->visible())
90 default_
= new tray::DefaultTracingView();
94 views::View
* TrayTracing::CreateDetailedView(user::LoginStatus status
) {
98 void TrayTracing::DestroyDefaultView() {
102 void TrayTracing::DestroyDetailedView() {
105 void TrayTracing::OnTracingModeChanged(bool value
) {
106 SetTrayIconVisible(value
);