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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 gfx::ImageSkia null_image_; | 269 gfx::ImageSkia null_image_; |
270 | 270 |
271 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); | 271 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); |
272 }; | 272 }; |
273 | 273 |
274 } // namespace | 274 } // namespace |
275 | 275 |
276 namespace internal { | 276 namespace internal { |
277 | 277 |
278 StatusAreaWidget::StatusAreaWidget() | 278 StatusAreaWidget::StatusAreaWidget() |
279 : widget_delegate_(new internal::StatusAreaWidgetDelegate), | 279 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), |
280 system_tray_(NULL), | 280 system_tray_(NULL), |
281 web_notification_tray_(NULL), | 281 web_notification_tray_(NULL), |
282 login_status_(user::LOGGED_IN_NONE) { | 282 login_status_(user::LOGGED_IN_NONE) { |
283 views::Widget::InitParams params( | 283 views::Widget::InitParams params( |
284 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 284 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
285 params.delegate = widget_delegate_; | 285 params.delegate = status_area_widget_delegate_; |
286 params.parent = | 286 params.parent = |
287 Shell::GetPrimaryRootWindowController()->GetContainer( | 287 Shell::GetPrimaryRootWindowController()->GetContainer( |
288 ash::internal::kShellWindowId_StatusContainer); | 288 ash::internal::kShellWindowId_StatusContainer); |
289 params.transparent = true; | 289 params.transparent = true; |
290 Init(params); | 290 Init(params); |
291 set_focus_on_creation(false); | 291 set_focus_on_creation(false); |
292 SetContentsView(widget_delegate_); | 292 SetContentsView(status_area_widget_delegate_); |
293 GetNativeView()->SetName("StatusAreaWidget"); | 293 GetNativeView()->SetName("StatusAreaWidget"); |
294 } | 294 } |
295 | 295 |
296 StatusAreaWidget::~StatusAreaWidget() { | 296 StatusAreaWidget::~StatusAreaWidget() { |
297 } | 297 } |
298 | 298 |
299 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) { | 299 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) { |
300 AddWebNotificationTray(new WebNotificationTray(this)); | 300 AddWebNotificationTray(new WebNotificationTray(this)); |
301 AddSystemTray(new SystemTray(this), shell_delegate); | 301 AddSystemTray(new SystemTray(this), shell_delegate); |
302 } | 302 } |
303 | 303 |
304 void StatusAreaWidget::Shutdown() { | 304 void StatusAreaWidget::Shutdown() { |
305 // Destroy the trays early, causing them to be removed from the view | 305 // Destroy the trays early, causing them to be removed from the view |
306 // hierarchy. Do not used scoped pointers since we don't want to destroy them | 306 // hierarchy. Do not used scoped pointers since we don't want to destroy them |
307 // in the destructor if Shutdown() is not called (e.g. in tests). | 307 // in the destructor if Shutdown() is not called (e.g. in tests). |
308 system_tray_delegate_.reset(); | 308 system_tray_delegate_.reset(); |
309 delete system_tray_; | 309 delete system_tray_; |
310 system_tray_ = NULL; | 310 system_tray_ = NULL; |
311 delete web_notification_tray_; | 311 delete web_notification_tray_; |
312 web_notification_tray_ = NULL; | 312 web_notification_tray_ = NULL; |
313 } | 313 } |
314 | 314 |
315 void StatusAreaWidget::AddSystemTray(SystemTray* system_tray, | 315 void StatusAreaWidget::AddSystemTray(SystemTray* system_tray, |
316 ShellDelegate* shell_delegate) { | 316 ShellDelegate* shell_delegate) { |
317 system_tray_ = system_tray; | 317 system_tray_ = system_tray; |
318 widget_delegate_->AddTray(system_tray); | 318 status_area_widget_delegate_->AddTray(system_tray); |
319 system_tray_->Initialize(); // Called after added to widget. | 319 system_tray_->Initialize(); // Called after added to widget. |
320 | 320 |
321 if (shell_delegate) { | 321 if (shell_delegate) { |
322 system_tray_delegate_.reset( | 322 system_tray_delegate_.reset( |
323 shell_delegate->CreateSystemTrayDelegate(system_tray)); | 323 shell_delegate->CreateSystemTrayDelegate(system_tray)); |
324 } | 324 } |
325 if (!system_tray_delegate_.get()) | 325 if (!system_tray_delegate_.get()) |
326 system_tray_delegate_.reset(new DummySystemTrayDelegate()); | 326 system_tray_delegate_.reset(new DummySystemTrayDelegate()); |
327 | 327 |
328 system_tray->CreateItems(); // Called after delegate is created. | 328 system_tray->CreateItems(); // Called after delegate is created. |
329 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus()); | 329 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus()); |
330 } | 330 } |
331 | 331 |
332 void StatusAreaWidget::AddWebNotificationTray( | 332 void StatusAreaWidget::AddWebNotificationTray( |
333 WebNotificationTray* web_notification_tray) { | 333 WebNotificationTray* web_notification_tray) { |
334 web_notification_tray_ = web_notification_tray; | 334 web_notification_tray_ = web_notification_tray; |
335 widget_delegate_->AddTray(web_notification_tray); | 335 status_area_widget_delegate_->AddTray(web_notification_tray); |
336 } | 336 } |
337 | 337 |
338 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { | 338 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { |
339 widget_delegate_->set_alignment(alignment); | 339 status_area_widget_delegate_->set_alignment(alignment); |
340 if (system_tray_) | 340 if (system_tray_) |
341 system_tray_->SetShelfAlignment(alignment); | 341 system_tray_->SetShelfAlignment(alignment); |
342 if (web_notification_tray_) | 342 if (web_notification_tray_) |
343 web_notification_tray_->SetShelfAlignment(alignment); | 343 web_notification_tray_->SetShelfAlignment(alignment); |
344 widget_delegate_->UpdateLayout(); | 344 status_area_widget_delegate_->UpdateLayout(); |
345 } | 345 } |
346 | 346 |
347 void StatusAreaWidget::SetPaintsBackground( | 347 void StatusAreaWidget::SetPaintsBackground( |
348 bool value, | 348 bool value, |
349 internal::BackgroundAnimator::ChangeType change_type) { | 349 internal::BackgroundAnimator::ChangeType change_type) { |
350 if (system_tray_) | 350 if (system_tray_) |
351 system_tray_->SetPaintsBackground(value, change_type); | 351 system_tray_->SetPaintsBackground(value, change_type); |
352 if (web_notification_tray_) | 352 if (web_notification_tray_) |
353 web_notification_tray_->SetPaintsBackground(value, change_type); | 353 web_notification_tray_->SetPaintsBackground(value, change_type); |
354 } | 354 } |
(...skipping 18 matching lines...) Expand all Loading... |
373 return; | 373 return; |
374 login_status_ = login_status; | 374 login_status_ = login_status; |
375 if (system_tray_) | 375 if (system_tray_) |
376 system_tray_->UpdateAfterLoginStatusChange(login_status); | 376 system_tray_->UpdateAfterLoginStatusChange(login_status); |
377 if (web_notification_tray_) | 377 if (web_notification_tray_) |
378 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); | 378 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); |
379 } | 379 } |
380 | 380 |
381 } // namespace internal | 381 } // namespace internal |
382 } // namespace ash | 382 } // namespace ash |
OLD | NEW |