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

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

Issue 10854175: Revert 151752 - Move non SystemTray specific code to TrayBackgroundView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | « no previous file | ash/system/tray/system_tray.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/status_area_widget.h" 5 #include "ash/system/status_area_widget.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/shell_delegate.h" 9 #include "ash/shell_delegate.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 SetContentsView(status_area_widget_delegate_); 317 SetContentsView(status_area_widget_delegate_);
318 GetNativeView()->SetName("StatusAreaWidget"); 318 GetNativeView()->SetName("StatusAreaWidget");
319 } 319 }
320 320
321 StatusAreaWidget::~StatusAreaWidget() { 321 StatusAreaWidget::~StatusAreaWidget() {
322 } 322 }
323 323
324 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) { 324 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) {
325 AddWebNotificationTray(); 325 AddWebNotificationTray();
326 AddSystemTray(shell_delegate); 326 AddSystemTray(shell_delegate);
327 // Initialize() must be called after all trays have been created. 327 // SetBorder() must be called after all trays have been created.
328 if (system_tray_) 328 web_notification_tray_->SetBorder();
329 system_tray_->Initialize(); 329 system_tray_->SetBorder();
330 if (web_notification_tray_)
331 web_notification_tray_->Initialize();
332 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
333 } 330 }
334 331
335 void StatusAreaWidget::Shutdown() { 332 void StatusAreaWidget::Shutdown() {
336 // Destroy the trays early, causing them to be removed from the view 333 // Destroy the trays early, causing them to be removed from the view
337 // hierarchy. Do not used scoped pointers since we don't want to destroy them 334 // hierarchy. Do not used scoped pointers since we don't want to destroy them
338 // in the destructor if Shutdown() is not called (e.g. in tests). 335 // in the destructor if Shutdown() is not called (e.g. in tests).
339 system_tray_delegate_.reset(); 336 system_tray_delegate_.reset();
340 delete system_tray_; 337 delete system_tray_;
341 system_tray_ = NULL; 338 system_tray_ = NULL;
342 delete web_notification_tray_; 339 delete web_notification_tray_;
343 web_notification_tray_ = NULL; 340 web_notification_tray_ = NULL;
344 } 341 }
345 342
346 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) { 343 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) {
347 system_tray_ = new SystemTray(this); 344 system_tray_ = new SystemTray(this);
348 status_area_widget_delegate_->AddTray(system_tray_); 345 status_area_widget_delegate_->AddTray(system_tray_);
346 system_tray_->Initialize(); // Called after added to widget.
349 347
350 if (shell_delegate) { 348 if (shell_delegate) {
351 system_tray_delegate_.reset( 349 system_tray_delegate_.reset(
352 shell_delegate->CreateSystemTrayDelegate(system_tray_)); 350 shell_delegate->CreateSystemTrayDelegate(system_tray_));
353 } 351 }
354 if (!system_tray_delegate_.get()) 352 if (!system_tray_delegate_.get())
355 system_tray_delegate_.reset(new DummySystemTrayDelegate()); 353 system_tray_delegate_.reset(new DummySystemTrayDelegate());
354
355 system_tray_->CreateItems(); // Called after delegate is created.
356 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
356 } 357 }
357 358
358 void StatusAreaWidget::AddWebNotificationTray() { 359 void StatusAreaWidget::AddWebNotificationTray() {
359 web_notification_tray_ = new WebNotificationTray(this); 360 web_notification_tray_ = new WebNotificationTray(this);
360 status_area_widget_delegate_->AddTray(web_notification_tray_); 361 status_area_widget_delegate_->AddTray(web_notification_tray_);
361 } 362 }
362 363
363 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 364 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
364 status_area_widget_delegate_->set_alignment(alignment); 365 status_area_widget_delegate_->set_alignment(alignment);
365 if (system_tray_) 366 if (system_tray_)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 return; 399 return;
399 login_status_ = login_status; 400 login_status_ = login_status;
400 if (system_tray_) 401 if (system_tray_)
401 system_tray_->UpdateAfterLoginStatusChange(login_status); 402 system_tray_->UpdateAfterLoginStatusChange(login_status);
402 if (web_notification_tray_) 403 if (web_notification_tray_)
403 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 404 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
404 } 405 }
405 406
406 } // namespace internal 407 } // namespace internal
407 } // namespace ash 408 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/system_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698