Chromium Code Reviews| Index: ash/system/tray_tracing.cc |
| diff --git a/ash/system/tray_tracing.cc b/ash/system/tray_tracing.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5718fe1536049d287678d56b552ac426c4ed0a7d |
| --- /dev/null |
| +++ b/ash/system/tray_tracing.cc |
| @@ -0,0 +1,113 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
|
James Cook
2013/08/09 20:06:02
nit: "(c)" is no longer required in the copyright
Zachary Kuznia
2013/08/09 20:58:04
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ash/system/tray_tracing.h" |
| + |
| +#include "ash/system/tray/actionable_view.h" |
| +#include "ash/system/tray/fixed_sized_image_view.h" |
| +#include "ash/system/tray/system_tray.h" |
| +#include "ash/system/tray/system_tray_delegate.h" |
| +#include "ash/system/tray/system_tray_notifier.h" |
| +#include "ash/system/tray/tray_constants.h" |
| +#include "grit/ash_resources.h" |
| +#include "grit/ash_strings.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| +#include "ui/gfx/image/image.h" |
| +#include "ui/views/controls/image_view.h" |
| +#include "ui/views/controls/label.h" |
| +#include "ui/views/layout/box_layout.h" |
| + |
| +namespace ash { |
| +namespace internal { |
| + |
| +namespace tray { |
| + |
| +class DefaultTracingView : public ash::internal::ActionableView { |
| + public: |
| + explicit DefaultTracingView() { |
|
James Cook
2013/08/09 20:06:02
not explicit
Zachary Kuznia
2013/08/09 20:58:04
Done.
|
| + SetLayoutManager(new views::BoxLayout( |
| + views::BoxLayout::kHorizontal, |
| + ash::kTrayPopupPaddingHorizontal, 0, |
| + ash::kTrayPopupPaddingBetweenItems)); |
| + |
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| + image_ = |
| + new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight); |
| + image_->SetImage( |
| + bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); |
| + AddChildView(image_); |
| + |
| + label_ = new views::Label(); |
| + label_->SetMultiLine(true); |
| + label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| + label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); |
| + AddChildView(label_); |
| + } |
| + |
| + virtual ~DefaultTracingView() { |
|
James Cook
2013/08/09 20:06:02
optional nit: {} on same line?
Zachary Kuznia
2013/08/09 20:58:04
Done.
|
| + } |
| + |
| + private: |
| + // Overridden from ActionableView. |
| + virtual bool PerformAction(const ui::Event& event) OVERRIDE { |
| + ash::Shell::GetInstance()->system_tray_delegate()->ShowSlow(); |
| + return true; |
| + } |
| + |
| + views::ImageView* image_; |
| + views::Label* label_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); |
| +}; |
| + |
| +} // namespace tray |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// ash::internal::TrayTracing |
| + |
| +TrayTracing::TrayTracing(SystemTray* system_tray) |
| + : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING), |
| + default_(NULL) { |
| + DCHECK(Shell::GetInstance()->delegate()); |
| + DCHECK(system_tray); |
| + Shell::GetInstance()->system_tray_notifier()->AddTracingObserver(this); |
| +} |
| + |
| +TrayTracing::~TrayTracing() { |
| + Shell::GetInstance()->system_tray_notifier()->RemoveTracingObserver(this); |
| +} |
| + |
| +void TrayTracing::SetTrayIconVisible(bool visible) { |
| + if (tray_view()) |
| + tray_view()->SetVisible(visible); |
| +} |
| + |
| +bool TrayTracing::GetInitialVisibility() { |
| + return true; |
|
sadrul
2013/08/09 04:56:44
Should this get the setting from somewhere?
Zachary Kuznia
2013/08/09 20:58:04
I'm relying on the initial state being set when th
James Cook
2013/08/09 21:16:51
Maybe it should default to false?
Zachary Kuznia
2013/08/09 22:22:33
Done.
|
| +} |
| + |
| +views::View* TrayTracing::CreateDefaultView(user::LoginStatus status) { |
| + CHECK(default_ == NULL); |
| + default_ = new tray::DefaultTracingView(); |
| + return default_; |
| +} |
| + |
| +views::View* TrayTracing::CreateDetailedView(user::LoginStatus status) { |
| + return NULL; |
| +} |
| + |
| +void TrayTracing::DestroyDefaultView() { |
| + default_ = NULL; |
| +} |
| + |
| +void TrayTracing::DestroyDetailedView() { |
| +} |
| + |
| +void TrayTracing::OnTracingModeChanged(bool value) { |
| + SetTrayIconVisible(value); |
| +} |
| + |
| +} // namespace internal |
| +} // namespace ash |