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

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

Issue 10834338: Move non SystemTray specific code to TrayBackgroundView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test 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 // SetBorder() must be called after all trays have been created. 327 // Initialize() must be called after all trays have been created.
328 web_notification_tray_->SetBorder(); 328 if (system_tray_)
329 system_tray_->SetBorder(); 329 system_tray_->Initialize();
330 if (web_notification_tray_)
331 web_notification_tray_->Initialize();
332 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
330 } 333 }
331 334
332 void StatusAreaWidget::Shutdown() { 335 void StatusAreaWidget::Shutdown() {
333 // Destroy the trays early, causing them to be removed from the view 336 // Destroy the trays early, causing them to be removed from the view
334 // hierarchy. Do not used scoped pointers since we don't want to destroy them 337 // hierarchy. Do not used scoped pointers since we don't want to destroy them
335 // in the destructor if Shutdown() is not called (e.g. in tests). 338 // in the destructor if Shutdown() is not called (e.g. in tests).
336 system_tray_delegate_.reset(); 339 system_tray_delegate_.reset();
337 delete system_tray_; 340 delete system_tray_;
338 system_tray_ = NULL; 341 system_tray_ = NULL;
339 delete web_notification_tray_; 342 delete web_notification_tray_;
340 web_notification_tray_ = NULL; 343 web_notification_tray_ = NULL;
341 } 344 }
342 345
343 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) { 346 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) {
344 system_tray_ = new SystemTray(this); 347 system_tray_ = new SystemTray(this);
345 status_area_widget_delegate_->AddTray(system_tray_); 348 status_area_widget_delegate_->AddTray(system_tray_);
346 system_tray_->Initialize(); // Called after added to widget.
347 349
348 if (shell_delegate) { 350 if (shell_delegate) {
349 system_tray_delegate_.reset( 351 system_tray_delegate_.reset(
350 shell_delegate->CreateSystemTrayDelegate(system_tray_)); 352 shell_delegate->CreateSystemTrayDelegate(system_tray_));
351 } 353 }
352 if (!system_tray_delegate_.get()) 354 if (!system_tray_delegate_.get())
353 system_tray_delegate_.reset(new DummySystemTrayDelegate()); 355 system_tray_delegate_.reset(new DummySystemTrayDelegate());
354
355 system_tray_->CreateItems(); // Called after delegate is created.
356 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
357 } 356 }
358 357
359 void StatusAreaWidget::AddWebNotificationTray() { 358 void StatusAreaWidget::AddWebNotificationTray() {
360 web_notification_tray_ = new WebNotificationTray(this); 359 web_notification_tray_ = new WebNotificationTray(this);
361 status_area_widget_delegate_->AddTray(web_notification_tray_); 360 status_area_widget_delegate_->AddTray(web_notification_tray_);
362 } 361 }
363 362
364 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 363 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
365 status_area_widget_delegate_->set_alignment(alignment); 364 status_area_widget_delegate_->set_alignment(alignment);
366 if (system_tray_) 365 if (system_tray_)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 return; 398 return;
400 login_status_ = login_status; 399 login_status_ = login_status;
401 if (system_tray_) 400 if (system_tray_)
402 system_tray_->UpdateAfterLoginStatusChange(login_status); 401 system_tray_->UpdateAfterLoginStatusChange(login_status);
403 if (web_notification_tray_) 402 if (web_notification_tray_)
404 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 403 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
405 } 404 }
406 405
407 } // namespace internal 406 } // namespace internal
408 } // namespace ash 407 } // 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