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

Side by Side Diff: ash/system/tray_update.cc

Issue 11415014: Stop using shell::GetInstance()->system_tray() in system tray items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified CL to provide TrayItems and Tray*Views with parent pointers instead. Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tray_update.h" 5 #include "ash/system/tray_update.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/status_area_widget.h" 9 #include "ash/system/status_area_widget.h"
10 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 } 93 }
94 94
95 namespace ash { 95 namespace ash {
96 namespace internal { 96 namespace internal {
97 97
98 namespace tray { 98 namespace tray {
99 99
100 class UpdateNagger : public ui::LayerAnimationObserver { 100 class UpdateNagger : public ui::LayerAnimationObserver {
101 public: 101 public:
102 explicit UpdateNagger(SystemTrayItem* owner) 102 explicit UpdateNagger(SystemTrayItem* tray)
103 : owner_(owner) { 103 : tray_(tray) {
104 RestartTimer(); 104 RestartTimer();
105 Shell::GetInstance()->system_tray()->GetWidget()->GetNativeView()->layer()-> 105 tray_->system_tray()->GetWidget()->GetNativeView()->layer()->GetAnimator()->
106 GetAnimator()->AddObserver(this); 106 AddObserver(this);
107 } 107 }
108 108
109 virtual ~UpdateNagger() { 109 virtual ~UpdateNagger() {
110 internal::StatusAreaWidget* status_area = 110 internal::StatusAreaWidget* status_area =
111 ash::Shell::GetInstance()->status_area_widget(); 111 ash::Shell::GetInstance()->status_area_widget();
112 if (status_area) { 112 if (status_area) {
113 status_area->system_tray()->GetWidget()->GetNativeView()->layer()-> 113 status_area->system_tray()->GetWidget()->GetNativeView()->layer()->
114 GetAnimator()->RemoveObserver(this); 114 GetAnimator()->RemoveObserver(this);
115 } 115 }
116 } 116 }
117 117
118 void RestartTimer() { 118 void RestartTimer() {
119 timer_.Stop(); 119 timer_.Stop();
120 timer_.Start(FROM_HERE, 120 timer_.Start(FROM_HERE,
121 base::TimeDelta::FromSeconds(kUpdateNaggingTimeSeconds), 121 base::TimeDelta::FromSeconds(kUpdateNaggingTimeSeconds),
122 this, 122 this,
123 &UpdateNagger::Nag); 123 &UpdateNagger::Nag);
124 } 124 }
125 125
126 private: 126 private:
127 void Nag() { 127 void Nag() {
128 owner_->PopupDetailedView(kShowUpdateNaggerForSeconds, false); 128 tray_->PopupDetailedView(kShowUpdateNaggerForSeconds, false);
129 } 129 }
130 130
131 // Overridden from ui::LayerAnimationObserver. 131 // Overridden from ui::LayerAnimationObserver.
132 virtual void OnLayerAnimationEnded( 132 virtual void OnLayerAnimationEnded(
133 ui::LayerAnimationSequence* sequence) OVERRIDE { 133 ui::LayerAnimationSequence* sequence) OVERRIDE {
134 // TODO(oshima): Find out if the updator will be shown on non 134 // TODO(oshima): Find out if the updator will be shown on non
135 // primary display. 135 // primary display.
136 if (Shell::GetPrimaryRootWindowController()->shelf()->IsVisible()) 136 if (Shell::GetPrimaryRootWindowController()->shelf()->IsVisible())
137 timer_.Stop(); 137 timer_.Stop();
138 else if (!timer_.IsRunning()) 138 else if (!timer_.IsRunning())
139 RestartTimer(); 139 RestartTimer();
140 } 140 }
141 141
142 virtual void OnLayerAnimationAborted( 142 virtual void OnLayerAnimationAborted(
143 ui::LayerAnimationSequence* sequence) OVERRIDE {} 143 ui::LayerAnimationSequence* sequence) OVERRIDE {}
144 144
145 virtual void OnLayerAnimationScheduled( 145 virtual void OnLayerAnimationScheduled(
146 ui::LayerAnimationSequence* sequence) OVERRIDE {} 146 ui::LayerAnimationSequence* sequence) OVERRIDE {}
147 147
148 SystemTrayItem* owner_; 148 SystemTrayItem* tray_;
149 base::OneShotTimer<UpdateNagger> timer_; 149 base::OneShotTimer<UpdateNagger> timer_;
150 150
151 DISALLOW_COPY_AND_ASSIGN(UpdateNagger); 151 DISALLOW_COPY_AND_ASSIGN(UpdateNagger);
152 }; 152 };
153 153
154 } // namespace tray 154 } // namespace tray
155 155
156 TrayUpdate::TrayUpdate() 156 TrayUpdate::TrayUpdate(SystemTray* system_tray)
157 : TrayImageItem(IDR_AURA_UBER_TRAY_UPDATE), 157 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE),
158 severity_(UpdateObserver::UPDATE_NORMAL) { 158 severity_(UpdateObserver::UPDATE_NORMAL) {
159 } 159 }
160 160
161 TrayUpdate::~TrayUpdate() {} 161 TrayUpdate::~TrayUpdate() {}
162 162
163 bool TrayUpdate::GetInitialVisibility() { 163 bool TrayUpdate::GetInitialVisibility() {
164 return Shell::GetInstance()->tray_delegate()->SystemShouldUpgrade(); 164 return Shell::GetInstance()->tray_delegate()->SystemShouldUpgrade();
165 } 165 }
166 166
167 views::View* TrayUpdate::CreateDefaultView(user::LoginStatus status) { 167 views::View* TrayUpdate::CreateDefaultView(user::LoginStatus status) {
(...skipping 22 matching lines...) Expand all
190 tray_view()->SetVisible(true); 190 tray_view()->SetVisible(true);
191 if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() && 191 if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() &&
192 !nagger_.get()) { 192 !nagger_.get()) {
193 // The shelf is not visible, and there is no nagger scheduled. 193 // The shelf is not visible, and there is no nagger scheduled.
194 nagger_.reset(new tray::UpdateNagger(this)); 194 nagger_.reset(new tray::UpdateNagger(this));
195 } 195 }
196 } 196 }
197 197
198 } // namespace internal 198 } // namespace internal
199 } // namespace ash 199 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698