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 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); |
| 20 bubble_widget_->AddObserver(this); |
| 21 |
| 22 bubble_view_->InitializeAndShowBubble(); |
| 23 tray_->InitializeBubbleAnimations(bubble_widget_); |
| 24 |
| 25 tray_event_filter_.reset(new TrayEventFilter(this)); |
| 26 } |
| 27 |
| 28 TrayBubbleWrapper::~TrayBubbleWrapper() { |
| 29 tray_event_filter_.reset(); |
| 30 if (bubble_widget_) { |
| 31 bubble_widget_->RemoveObserver(this); |
| 32 bubble_widget_->Close(); |
| 33 } |
| 34 } |
| 35 |
| 36 void TrayBubbleWrapper::OnWidgetClosing(views::Widget* widget) { |
| 37 CHECK_EQ(bubble_widget_, widget); |
| 38 bubble_widget_ = NULL; |
| 39 tray_->HideBubbleWithView(bubble_view_); // May destroy |bubble_view_| |
| 40 } |
| 41 |
| 42 } // namespace internal |
| 43 } // namespace ash |
OLD | NEW |