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

Side by Side Diff: ash/system/user/tray_user.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/user/tray_user.h ('k') | no next file » | 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/user/tray_user.h" 5 #include "ash/system/user/tray_user.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/tray_constants.h" 9 #include "ash/system/tray/tray_constants.h"
10 #include "ash/system/tray/tray_item_view.h" 10 #include "ash/system/tray/tray_item_view.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 SkBitmap image_; 247 SkBitmap image_;
248 SkBitmap resized_; 248 SkBitmap resized_;
249 gfx::Size image_size_; 249 gfx::Size image_size_;
250 int corner_radius_; 250 int corner_radius_;
251 251
252 DISALLOW_COPY_AND_ASSIGN(RoundedImageView); 252 DISALLOW_COPY_AND_ASSIGN(RoundedImageView);
253 }; 253 };
254 254
255 } // namespace tray 255 } // namespace tray
256 256
257 TrayUser::TrayUser() { 257 TrayUser::TrayUser()
258 : user_(NULL),
259 avatar_(NULL) {
258 } 260 }
259 261
260 TrayUser::~TrayUser() { 262 TrayUser::~TrayUser() {
261 } 263 }
262 264
263 views::View* TrayUser::CreateTrayView(user::LoginStatus status) { 265 views::View* TrayUser::CreateTrayView(user::LoginStatus status) {
264 avatar_.reset(new tray::RoundedImageView(kTrayRoundedBorderRadius)); 266 CHECK(avatar_ == NULL);
267 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius);
265 avatar_->set_border(views::Border::CreateEmptyBorder(0, 6, 0, 0)); 268 avatar_->set_border(views::Border::CreateEmptyBorder(0, 6, 0, 0));
266 UpdateAfterLoginStatusChange(status); 269 UpdateAfterLoginStatusChange(status);
267 return avatar_.get(); 270 return avatar_;
268 } 271 }
269 272
270 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { 273 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) {
271 if (status == user::LOGGED_IN_NONE) 274 if (status == user::LOGGED_IN_NONE)
272 return NULL; 275 return NULL;
273 276
274 user_.reset(new tray::UserView(status)); 277 CHECK(user_ == NULL);
275 return user_.get(); 278 user_ = new tray::UserView(status);
279 return user_;
276 } 280 }
277 281
278 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) { 282 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) {
279 return NULL; 283 return NULL;
280 } 284 }
281 285
282 void TrayUser::DestroyTrayView() { 286 void TrayUser::DestroyTrayView() {
283 avatar_.reset(); 287 avatar_ = NULL;
284 } 288 }
285 289
286 void TrayUser::DestroyDefaultView() { 290 void TrayUser::DestroyDefaultView() {
287 user_.reset(); 291 user_ = NULL;
288 } 292 }
289 293
290 void TrayUser::DestroyDetailedView() { 294 void TrayUser::DestroyDetailedView() {
291 } 295 }
292 296
293 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) { 297 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
294 if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_KIOSK && 298 if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_KIOSK &&
295 status != user::LOGGED_IN_GUEST) { 299 status != user::LOGGED_IN_GUEST) {
296 avatar_->SetImage( 300 avatar_->SetImage(
297 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), 301 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
298 gfx::Size(kUserIconSize, kUserIconSize)); 302 gfx::Size(kUserIconSize, kUserIconSize));
299 avatar_->SetVisible(true); 303 avatar_->SetVisible(true);
300 } else { 304 } else {
301 avatar_->SetVisible(false); 305 avatar_->SetVisible(false);
302 } 306 }
303 } 307 }
304 308
305 void TrayUser::OnUserUpdate() { 309 void TrayUser::OnUserUpdate() {
306 avatar_->SetImage( 310 avatar_->SetImage(
307 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), 311 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
308 gfx::Size(kUserIconSize, kUserIconSize)); 312 gfx::Size(kUserIconSize, kUserIconSize));
309 } 313 }
310 314
311 } // namespace internal 315 } // namespace internal
312 } // namespace ash 316 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/tray_user.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698