OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
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/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 explicit DefaultTracingView() { | |
James Cook
2013/08/09 20:06:02
not explicit
Zachary Kuznia
2013/08/09 20:58:04
Done.
| |
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() { | |
James Cook
2013/08/09 20:06:02
optional nit: {} on same line?
Zachary Kuznia
2013/08/09 20:58:04
Done.
| |
50 } | |
51 | |
52 private: | |
53 // Overridden from ActionableView. | |
54 virtual bool PerformAction(const ui::Event& event) OVERRIDE { | |
55 ash::Shell::GetInstance()->system_tray_delegate()->ShowSlow(); | |
56 return true; | |
57 } | |
58 | |
59 views::ImageView* image_; | |
60 views::Label* label_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); | |
63 }; | |
64 | |
65 } // namespace tray | |
66 | |
67 //////////////////////////////////////////////////////////////////////////////// | |
68 // ash::internal::TrayTracing | |
69 | |
70 TrayTracing::TrayTracing(SystemTray* system_tray) | |
71 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING), | |
72 default_(NULL) { | |
73 DCHECK(Shell::GetInstance()->delegate()); | |
74 DCHECK(system_tray); | |
75 Shell::GetInstance()->system_tray_notifier()->AddTracingObserver(this); | |
76 } | |
77 | |
78 TrayTracing::~TrayTracing() { | |
79 Shell::GetInstance()->system_tray_notifier()->RemoveTracingObserver(this); | |
80 } | |
81 | |
82 void TrayTracing::SetTrayIconVisible(bool visible) { | |
83 if (tray_view()) | |
84 tray_view()->SetVisible(visible); | |
85 } | |
86 | |
87 bool TrayTracing::GetInitialVisibility() { | |
88 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.
| |
89 } | |
90 | |
91 views::View* TrayTracing::CreateDefaultView(user::LoginStatus status) { | |
92 CHECK(default_ == NULL); | |
93 default_ = new tray::DefaultTracingView(); | |
94 return default_; | |
95 } | |
96 | |
97 views::View* TrayTracing::CreateDetailedView(user::LoginStatus status) { | |
98 return NULL; | |
99 } | |
100 | |
101 void TrayTracing::DestroyDefaultView() { | |
102 default_ = NULL; | |
103 } | |
104 | |
105 void TrayTracing::DestroyDetailedView() { | |
106 } | |
107 | |
108 void TrayTracing::OnTracingModeChanged(bool value) { | |
109 SetTrayIconVisible(value); | |
110 } | |
111 | |
112 } // namespace internal | |
113 } // namespace ash | |
OLD | NEW |