OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/system/tray/tray_bubble_wrapper.h" |
| 6 |
| 7 #include "ash/system/tray/tray_background_view.h" |
| 8 #include "ash/system/tray/tray_bubble_view.h" |
| 9 #include "ash/system/tray/tray_event_filter.h" |
| 10 #include "ui/views/widget/widget.h" |
| 11 |
| 12 namespace ash { |
| 13 namespace internal { |
| 14 |
| 15 TrayBubbleWrapper::TrayBubbleWrapper(TrayBackgroundView* tray, |
| 16 TrayBubbleView* bubble_view) |
| 17 : tray_(tray), |
| 18 bubble_view_(bubble_view), |
| 19 tray_event_filter_(new TrayEventFilter(this)) { |
| 20 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); |
| 21 bubble_widget_->AddObserver(this); |
| 22 |
| 23 bubble_view_->InitializeAndShowBubble(bubble_widget_); |
| 24 tray_->InitializeBubbleAnimations(bubble_widget_); |
| 25 } |
| 26 |
| 27 TrayBubbleWrapper::~TrayBubbleWrapper() { |
| 28 tray_event_filter_.reset(); |
| 29 if (bubble_widget_) { |
| 30 bubble_widget_->RemoveObserver(this); |
| 31 bubble_widget_->Close(); |
| 32 } |
| 33 } |
| 34 |
| 35 void TrayBubbleWrapper::OnWidgetClosing(views::Widget* widget) { |
| 36 CHECK_EQ(bubble_widget_, widget); |
| 37 bubble_widget_ = NULL; |
| 38 tray_->HideBubble(bubble_view_); // May destroy |bubble_view_| |
| 39 } |
| 40 |
| 41 } // namespace internal |
| 42 } // namespace ash |
OLD | NEW |