Video Player: Remove unnecessary script file
[chromium-blink-merge.git] / ash / system / chromeos / tray_tracing.cc
blob907b51bfd7ccd018c525039e80bf1f5cc96e27d8
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/l10n/l10n_util.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"
23 namespace ash {
24 namespace tray {
26 class DefaultTracingView : public ActionableView {
27 public:
28 DefaultTracingView() {
29 SetLayoutManager(new views::BoxLayout(
30 views::BoxLayout::kHorizontal,
31 kTrayPopupPaddingHorizontal, 0,
32 kTrayPopupPaddingBetweenItems));
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_);
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_);
47 virtual ~DefaultTracingView() {}
49 private:
50 // Overridden from ActionableView.
51 virtual bool PerformAction(const ui::Event& event) OVERRIDE {
52 Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow();
53 return true;
56 views::ImageView* image_;
57 views::Label* label_;
59 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView);
62 } // namespace tray
64 ////////////////////////////////////////////////////////////////////////////////
65 // ash::TrayTracing
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);
75 TrayTracing::~TrayTracing() {
76 Shell::GetInstance()->system_tray_notifier()->RemoveTracingObserver(this);
79 void TrayTracing::SetTrayIconVisible(bool visible) {
80 if (tray_view())
81 tray_view()->SetVisible(visible);
84 bool TrayTracing::GetInitialVisibility() {
85 return false;
88 views::View* TrayTracing::CreateDefaultView(user::LoginStatus status) {
89 CHECK(default_ == NULL);
90 if (tray_view() && tray_view()->visible())
91 default_ = new tray::DefaultTracingView();
92 return default_;
95 views::View* TrayTracing::CreateDetailedView(user::LoginStatus status) {
96 return NULL;
99 void TrayTracing::DestroyDefaultView() {
100 default_ = NULL;
103 void TrayTracing::DestroyDetailedView() {
106 void TrayTracing::OnTracingModeChanged(bool value) {
107 SetTrayIconVisible(value);
110 } // namespace ash