Elim cr-checkbox
[chromium-blink-merge.git] / ash / system / chromeos / tray_tracing.cc
blobb74bc5ae93fce20c8c7a65a7ba54d736832fb48a
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"
7 #include "ash/shell.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"
22 namespace ash {
23 namespace tray {
25 class DefaultTracingView : public ActionableView {
26 public:
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);
35 image_->SetImage(
36 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia());
37 AddChildView(image_);
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));
43 AddChildView(label_);
46 ~DefaultTracingView() override {}
48 private:
49 // Overridden from ActionableView.
50 bool PerformAction(const ui::Event& event) override {
51 Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow();
52 return true;
55 views::ImageView* image_;
56 views::Label* label_;
58 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView);
61 } // namespace tray
63 ////////////////////////////////////////////////////////////////////////////////
64 // ash::TrayTracing
66 TrayTracing::TrayTracing(SystemTray* system_tray)
67 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING),
68 default_(NULL) {
69 DCHECK(Shell::GetInstance()->delegate());
70 DCHECK(system_tray);
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) {
79 if (tray_view())
80 tray_view()->SetVisible(visible);
83 bool TrayTracing::GetInitialVisibility() {
84 return false;
87 views::View* TrayTracing::CreateDefaultView(user::LoginStatus status) {
88 CHECK(default_ == NULL);
89 if (tray_view() && tray_view()->visible())
90 default_ = new tray::DefaultTracingView();
91 return default_;
94 views::View* TrayTracing::CreateDetailedView(user::LoginStatus status) {
95 return NULL;
98 void TrayTracing::DestroyDefaultView() {
99 default_ = NULL;
102 void TrayTracing::DestroyDetailedView() {
105 void TrayTracing::OnTracingModeChanged(bool value) {
106 SetTrayIconVisible(value);
109 } // namespace ash