| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 GetNativeView()->SetName("StatusAreaWidget"); | 39 GetNativeView()->SetName("StatusAreaWidget"); |
| 40 GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true); | 40 GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true); |
| 41 } | 41 } |
| 42 | 42 |
| 43 StatusAreaWidget::~StatusAreaWidget() { | 43 StatusAreaWidget::~StatusAreaWidget() { |
| 44 } | 44 } |
| 45 | 45 |
| 46 void StatusAreaWidget::CreateTrayViews() { | 46 void StatusAreaWidget::CreateTrayViews() { |
| 47 AddSystemTray(); | 47 AddSystemTray(); |
| 48 AddWebNotificationTray(); | 48 AddWebNotificationTray(); |
| 49 // Initialize() must be called after all trays have been created. | 49 SystemTrayDelegate* delegate = ash::Shell::GetInstance()->tray_delegate(); |
| 50 DCHECK(delegate); |
| 51 // Initialize after all trays have been created. |
| 50 if (system_tray_) | 52 if (system_tray_) |
| 51 system_tray_->Initialize(); | 53 system_tray_->InitializeTrayItems(delegate); |
| 52 if (web_notification_tray_) | 54 if (web_notification_tray_) |
| 53 web_notification_tray_->Initialize(); | 55 web_notification_tray_->Initialize(); |
| 54 UpdateAfterLoginStatusChange( | 56 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus()); |
| 55 ash::Shell::GetInstance()->tray_delegate()->GetUserLoginStatus()); | |
| 56 } | 57 } |
| 57 | 58 |
| 58 void StatusAreaWidget::Shutdown() { | 59 void StatusAreaWidget::Shutdown() { |
| 59 // Destroy the trays early, causing them to be removed from the view | 60 // Destroy the trays early, causing them to be removed from the view |
| 60 // hierarchy. Do not used scoped pointers since we don't want to destroy them | 61 // hierarchy. Do not used scoped pointers since we don't want to destroy them |
| 61 // in the destructor if Shutdown() is not called (e.g. in tests). | 62 // in the destructor if Shutdown() is not called (e.g. in tests). |
| 62 delete web_notification_tray_; | 63 delete web_notification_tray_; |
| 63 web_notification_tray_ = NULL; | 64 web_notification_tray_ = NULL; |
| 64 delete system_tray_; | 65 delete system_tray_; |
| 65 system_tray_ = NULL; | 66 system_tray_ = NULL; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return; | 136 return; |
| 136 login_status_ = login_status; | 137 login_status_ = login_status; |
| 137 if (system_tray_) | 138 if (system_tray_) |
| 138 system_tray_->UpdateAfterLoginStatusChange(login_status); | 139 system_tray_->UpdateAfterLoginStatusChange(login_status); |
| 139 if (web_notification_tray_) | 140 if (web_notification_tray_) |
| 140 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); | 141 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); |
| 141 } | 142 } |
| 142 | 143 |
| 143 } // namespace internal | 144 } // namespace internal |
| 144 } // namespace ash | 145 } // namespace ash |
| OLD | NEW |