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

Side by Side Diff: ash/system/brightness/tray_brightness.cc

Issue 10269017: Remove scoped_ptr for system tray views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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/brightness/tray_brightness.h ('k') | ash/system/date/tray_date.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/brightness/tray_brightness.h" 5 #include "ash/system/brightness/tray_brightness.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/brightness/brightness_control_delegate.h" 9 #include "ash/system/brightness/brightness_control_delegate.h"
10 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Last brightness level that we observed, in the range [0.0, 100.0]. 118 // Last brightness level that we observed, in the range [0.0, 100.0].
119 double last_percent_; 119 double last_percent_;
120 120
121 DISALLOW_COPY_AND_ASSIGN(BrightnessView); 121 DISALLOW_COPY_AND_ASSIGN(BrightnessView);
122 }; 122 };
123 123
124 } // namespace tray 124 } // namespace tray
125 125
126 TrayBrightness::TrayBrightness() 126 TrayBrightness::TrayBrightness()
127 : weak_ptr_factory_(this), 127 : weak_ptr_factory_(this),
128 brightness_view_(NULL),
128 is_default_view_(false), 129 is_default_view_(false),
129 current_percent_(100.0), 130 current_percent_(100.0),
130 got_current_percent_(false) { 131 got_current_percent_(false) {
131 // Post a task to get the initial brightness; the BrightnessControlDelegate 132 // Post a task to get the initial brightness; the BrightnessControlDelegate
132 // isn't created yet. 133 // isn't created yet.
133 MessageLoopForUI::current()->PostTask( 134 MessageLoopForUI::current()->PostTask(
134 FROM_HERE, 135 FROM_HERE,
135 base::Bind(&TrayBrightness::GetInitialBrightness, 136 base::Bind(&TrayBrightness::GetInitialBrightness,
136 weak_ptr_factory_.GetWeakPtr())); 137 weak_ptr_factory_.GetWeakPtr()));
137 } 138 }
(...skipping 15 matching lines...) Expand all
153 void TrayBrightness::HandleInitialBrightness(double percent) { 154 void TrayBrightness::HandleInitialBrightness(double percent) {
154 if (!got_current_percent_) 155 if (!got_current_percent_)
155 OnBrightnessChanged(percent, false); 156 OnBrightnessChanged(percent, false);
156 } 157 }
157 158
158 views::View* TrayBrightness::CreateTrayView(user::LoginStatus status) { 159 views::View* TrayBrightness::CreateTrayView(user::LoginStatus status) {
159 return NULL; 160 return NULL;
160 } 161 }
161 162
162 views::View* TrayBrightness::CreateDefaultView(user::LoginStatus status) { 163 views::View* TrayBrightness::CreateDefaultView(user::LoginStatus status) {
163 brightness_view_.reset(new tray::BrightnessView(current_percent_)); 164 CHECK(brightness_view_ == NULL);
165 brightness_view_ = new tray::BrightnessView(current_percent_);
164 is_default_view_ = true; 166 is_default_view_ = true;
165 return brightness_view_.get(); 167 return brightness_view_;
166 } 168 }
167 169
168 views::View* TrayBrightness::CreateDetailedView(user::LoginStatus status) { 170 views::View* TrayBrightness::CreateDetailedView(user::LoginStatus status) {
169 brightness_view_.reset(new tray::BrightnessView(current_percent_)); 171 CHECK(brightness_view_ == NULL);
172 brightness_view_ = new tray::BrightnessView(current_percent_);
170 is_default_view_ = false; 173 is_default_view_ = false;
171 return brightness_view_.get(); 174 return brightness_view_;
172 } 175 }
173 176
174 void TrayBrightness::DestroyTrayView() { 177 void TrayBrightness::DestroyTrayView() {
175 } 178 }
176 179
177 void TrayBrightness::DestroyDefaultView() { 180 void TrayBrightness::DestroyDefaultView() {
178 if (is_default_view_) 181 if (is_default_view_)
179 brightness_view_.reset(); 182 brightness_view_ = NULL;
180 } 183 }
181 184
182 void TrayBrightness::DestroyDetailedView() { 185 void TrayBrightness::DestroyDetailedView() {
183 if (!is_default_view_) 186 if (!is_default_view_)
184 brightness_view_.reset(); 187 brightness_view_ = NULL;
185 } 188 }
186 189
187 void TrayBrightness::UpdateAfterLoginStatusChange(user::LoginStatus status) { 190 void TrayBrightness::UpdateAfterLoginStatusChange(user::LoginStatus status) {
188 } 191 }
189 192
190 void TrayBrightness::OnBrightnessChanged(double percent, bool user_initiated) { 193 void TrayBrightness::OnBrightnessChanged(double percent, bool user_initiated) {
191 current_percent_ = percent; 194 current_percent_ = percent;
192 got_current_percent_ = true; 195 got_current_percent_ = true;
193 196
194 if (brightness_view_.get()) 197 if (brightness_view_)
195 brightness_view_->SetBrightnessPercent(percent); 198 brightness_view_->SetBrightnessPercent(percent);
196 if (!user_initiated) 199 if (!user_initiated)
197 return; 200 return;
198 201
199 if (brightness_view_.get()) 202 if (brightness_view_)
200 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); 203 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds);
201 else 204 else
202 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); 205 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
203 } 206 }
204 207
205 } // namespace internal 208 } // namespace internal
206 } // namespace ash 209 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/brightness/tray_brightness.h ('k') | ash/system/date/tray_date.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698