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/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell/panel_window.h" | 8 #include "ash/shell/panel_window.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/system/audio/tray_volume.h" | 10 #include "ash/system/audio/tray_volume.h" |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 SystemTrayBubble::SystemTrayBubble( | 468 SystemTrayBubble::SystemTrayBubble( |
469 ash::SystemTray* tray, | 469 ash::SystemTray* tray, |
470 const std::vector<ash::SystemTrayItem*>& items, | 470 const std::vector<ash::SystemTrayItem*>& items, |
471 bool detailed) | 471 bool detailed) |
472 : tray_(tray), | 472 : tray_(tray), |
473 bubble_view_(NULL), | 473 bubble_view_(NULL), |
474 bubble_widget_(NULL), | 474 bubble_widget_(NULL), |
475 items_(items), | 475 items_(items), |
476 detailed_(detailed), | 476 detailed_(detailed), |
477 autoclose_delay_(0) { | 477 autoclose_delay_(0) { |
478 MessageLoopForUI::current()->AddObserver(this); | |
479 } | 478 } |
480 | 479 |
481 SystemTrayBubble::~SystemTrayBubble() { | 480 SystemTrayBubble::~SystemTrayBubble() { |
| 481 // The bubble may be closing without having been hidden first. So it may still |
| 482 // be in the message-loop's observer list. |
482 MessageLoopForUI::current()->RemoveObserver(this); | 483 MessageLoopForUI::current()->RemoveObserver(this); |
| 484 |
483 DestroyItemViews(); | 485 DestroyItemViews(); |
484 // Reset the host pointer in bubble_view_ in case its destruction is deferred. | 486 // Reset the host pointer in bubble_view_ in case its destruction is deferred. |
485 if (bubble_view_) | 487 if (bubble_view_) |
486 bubble_view_->reset_host(); | 488 bubble_view_->reset_host(); |
487 if (bubble_widget_) { | 489 if (bubble_widget_) { |
488 bubble_widget_->RemoveObserver(this); | 490 bubble_widget_->RemoveObserver(this); |
489 // This triggers the destruction of bubble_view_. | 491 // This triggers the destruction of bubble_view_. |
490 bubble_widget_->Close(); | 492 bubble_widget_->Close(); |
491 } | 493 } |
492 } | 494 } |
(...skipping 10 matching lines...) Expand all Loading... |
503 views::View* view = detailed_ ? | 505 views::View* view = detailed_ ? |
504 (*it)->CreateDetailedView(login_status) : | 506 (*it)->CreateDetailedView(login_status) : |
505 (*it)->CreateDefaultView(login_status); | 507 (*it)->CreateDefaultView(login_status); |
506 if (view) | 508 if (view) |
507 bubble_view_->AddChildView(new TrayPopupItemContainer(view)); | 509 bubble_view_->AddChildView(new TrayPopupItemContainer(view)); |
508 } | 510 } |
509 | 511 |
510 DCHECK(bubble_widget_ == NULL); | 512 DCHECK(bubble_widget_ == NULL); |
511 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); | 513 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); |
512 | 514 |
513 | |
514 // Must occur after call to CreateBubble() | 515 // Must occur after call to CreateBubble() |
515 bubble_view_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 516 bubble_view_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
516 bubble_widget_->non_client_view()->frame_view()->set_background(NULL); | 517 bubble_widget_->non_client_view()->frame_view()->set_background(NULL); |
517 bubble_view_->SetBubbleBorder(new SystemTrayBubbleBorder(bubble_view_)); | 518 bubble_view_->SetBubbleBorder(new SystemTrayBubbleBorder(bubble_view_)); |
518 | 519 |
519 bubble_widget_->AddObserver(this); | 520 bubble_widget_->AddObserver(this); |
520 | 521 |
521 // Setup animation. | 522 // Setup animation. |
522 ash::SetWindowVisibilityAnimationType( | 523 ash::SetWindowVisibilityAnimationType( |
523 bubble_widget_->GetNativeWindow(), | 524 bubble_widget_->GetNativeWindow(), |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 canvas->DrawFocusRect(container_->bounds()); | 874 canvas->DrawFocusRect(container_->bounds()); |
874 } | 875 } |
875 | 876 |
876 void SystemTray::UpdateBackground(int alpha) { | 877 void SystemTray::UpdateBackground(int alpha) { |
877 background_->set_alpha(hide_background_animator_.alpha() + | 878 background_->set_alpha(hide_background_animator_.alpha() + |
878 hover_background_animator_.alpha()); | 879 hover_background_animator_.alpha()); |
879 SchedulePaint(); | 880 SchedulePaint(); |
880 } | 881 } |
881 | 882 |
882 } // namespace ash | 883 } // namespace ash |
OLD | NEW |