Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: ash/system/chromeos/tray_tracing.cc

Issue 22654003: Create system tray item for accessing chrome://slow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix non-chromeos build Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/chromeos/tray_tracing.h ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "ash/system/chromeos/tray_tracing.h"
6
7 #include "ash/system/tray/actionable_view.h"
8 #include "ash/system/tray/fixed_sized_image_view.h"
9 #include "ash/system/tray/system_tray.h"
10 #include "ash/system/tray/system_tray_delegate.h"
11 #include "ash/system/tray/system_tray_notifier.h"
12 #include "ash/system/tray/tray_constants.h"
13 #include "grit/ash_resources.h"
14 #include "grit/ash_strings.h"
15 #include "ui/base/l10n/l10n_util.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"
21
22 namespace ash {
23 namespace internal {
24
25 namespace tray {
26
27 class DefaultTracingView : public ash::internal::ActionableView {
28 public:
29 DefaultTracingView() {
30 SetLayoutManager(new views::BoxLayout(
31 views::BoxLayout::kHorizontal,
32 ash::kTrayPopupPaddingHorizontal, 0,
33 ash::kTrayPopupPaddingBetweenItems));
34
35 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
36 image_ =
37 new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight);
38 image_->SetImage(
39 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia());
40 AddChildView(image_);
41
42 label_ = new views::Label();
43 label_->SetMultiLine(true);
44 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
45 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING));
46 AddChildView(label_);
47 }
48
49 virtual ~DefaultTracingView() {}
50
51 private:
52 // Overridden from ActionableView.
53 virtual bool PerformAction(const ui::Event& event) OVERRIDE {
54 ash::Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow();
55 return true;
56 }
57
58 views::ImageView* image_;
59 views::Label* label_;
60
61 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView);
62 };
63
64 } // namespace tray
65
66 ////////////////////////////////////////////////////////////////////////////////
67 // ash::internal::TrayTracing
68
69 TrayTracing::TrayTracing(SystemTray* system_tray)
70 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING),
71 default_(NULL) {
72 DCHECK(Shell::GetInstance()->delegate());
73 DCHECK(system_tray);
74 Shell::GetInstance()->system_tray_notifier()->AddTracingObserver(this);
75 }
76
77 TrayTracing::~TrayTracing() {
78 Shell::GetInstance()->system_tray_notifier()->RemoveTracingObserver(this);
79 }
80
81 void TrayTracing::SetTrayIconVisible(bool visible) {
82 if (tray_view())
83 tray_view()->SetVisible(visible);
84 }
85
86 bool TrayTracing::GetInitialVisibility() {
87 return false;
88 }
89
90 views::View* TrayTracing::CreateDefaultView(user::LoginStatus status) {
91 CHECK(default_ == NULL);
92 default_ = new tray::DefaultTracingView();
93 return default_;
94 }
95
96 views::View* TrayTracing::CreateDetailedView(user::LoginStatus status) {
97 return NULL;
98 }
99
100 void TrayTracing::DestroyDefaultView() {
101 default_ = NULL;
102 }
103
104 void TrayTracing::DestroyDetailedView() {
105 }
106
107 void TrayTracing::OnTracingModeChanged(bool value) {
108 SetTrayIconVisible(value);
109 }
110
111 } // namespace internal
112 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/tray_tracing.h ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698