| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/system/chromeos/tray_tracing.h" | 5 #include "ash/system/chromeos/tray_tracing.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/actionable_view.h" | 8 #include "ash/system/tray/actionable_view.h" |
| 9 #include "ash/system/tray/fixed_sized_image_view.h" | 9 #include "ash/system/tray/fixed_sized_image_view.h" |
| 10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| 11 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
| 12 #include "ash/system/tray/system_tray_notifier.h" | 12 #include "ash/system/tray/system_tray_notifier.h" |
| 13 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
| 14 #include "grit/ash_resources.h" | 14 #include "grit/ash_resources.h" |
| 15 #include "grit/ash_strings.h" | 15 #include "grit/ash_strings.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 19 #include "ui/views/controls/image_view.h" | 19 #include "ui/views/controls/image_view.h" |
| 20 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| 21 #include "ui/views/layout/box_layout.h" | 21 #include "ui/views/layout/box_layout.h" |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 namespace internal { | |
| 25 | |
| 26 namespace tray { | 24 namespace tray { |
| 27 | 25 |
| 28 class DefaultTracingView : public internal::ActionableView { | 26 class DefaultTracingView : public ActionableView { |
| 29 public: | 27 public: |
| 30 DefaultTracingView() { | 28 DefaultTracingView() { |
| 31 SetLayoutManager(new views::BoxLayout( | 29 SetLayoutManager(new views::BoxLayout( |
| 32 views::BoxLayout::kHorizontal, | 30 views::BoxLayout::kHorizontal, |
| 33 kTrayPopupPaddingHorizontal, 0, | 31 kTrayPopupPaddingHorizontal, 0, |
| 34 kTrayPopupPaddingBetweenItems)); | 32 kTrayPopupPaddingBetweenItems)); |
| 35 | 33 |
| 36 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 34 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 37 image_ = new internal::FixedSizedImageView(0, kTrayPopupItemHeight); | 35 image_ = new FixedSizedImageView(0, kTrayPopupItemHeight); |
| 38 image_->SetImage( | 36 image_->SetImage( |
| 39 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); | 37 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); |
| 40 AddChildView(image_); | 38 AddChildView(image_); |
| 41 | 39 |
| 42 label_ = new views::Label(); | 40 label_ = new views::Label(); |
| 43 label_->SetMultiLine(true); | 41 label_->SetMultiLine(true); |
| 44 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 42 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 45 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); | 43 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); |
| 46 AddChildView(label_); | 44 AddChildView(label_); |
| 47 } | 45 } |
| 48 | 46 |
| 49 virtual ~DefaultTracingView() {} | 47 virtual ~DefaultTracingView() {} |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 // Overridden from ActionableView. | 50 // Overridden from ActionableView. |
| 53 virtual bool PerformAction(const ui::Event& event) OVERRIDE { | 51 virtual bool PerformAction(const ui::Event& event) OVERRIDE { |
| 54 Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow(); | 52 Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow(); |
| 55 return true; | 53 return true; |
| 56 } | 54 } |
| 57 | 55 |
| 58 views::ImageView* image_; | 56 views::ImageView* image_; |
| 59 views::Label* label_; | 57 views::Label* label_; |
| 60 | 58 |
| 61 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); | 59 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); |
| 62 }; | 60 }; |
| 63 | 61 |
| 64 } // namespace tray | 62 } // namespace tray |
| 65 | 63 |
| 66 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 67 // ash::internal::TrayTracing | 65 // ash::TrayTracing |
| 68 | 66 |
| 69 TrayTracing::TrayTracing(SystemTray* system_tray) | 67 TrayTracing::TrayTracing(SystemTray* system_tray) |
| 70 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING), | 68 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING), |
| 71 default_(NULL) { | 69 default_(NULL) { |
| 72 DCHECK(Shell::GetInstance()->delegate()); | 70 DCHECK(Shell::GetInstance()->delegate()); |
| 73 DCHECK(system_tray); | 71 DCHECK(system_tray); |
| 74 Shell::GetInstance()->system_tray_notifier()->AddTracingObserver(this); | 72 Shell::GetInstance()->system_tray_notifier()->AddTracingObserver(this); |
| 75 } | 73 } |
| 76 | 74 |
| 77 TrayTracing::~TrayTracing() { | 75 TrayTracing::~TrayTracing() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 102 default_ = NULL; | 100 default_ = NULL; |
| 103 } | 101 } |
| 104 | 102 |
| 105 void TrayTracing::DestroyDetailedView() { | 103 void TrayTracing::DestroyDetailedView() { |
| 106 } | 104 } |
| 107 | 105 |
| 108 void TrayTracing::OnTracingModeChanged(bool value) { | 106 void TrayTracing::OnTracingModeChanged(bool value) { |
| 109 SetTrayIconVisible(value); | 107 SetTrayIconVisible(value); |
| 110 } | 108 } |
| 111 | 109 |
| 112 } // namespace internal | |
| 113 } // namespace ash | 110 } // namespace ash |
| OLD | NEW |