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/tray_bubble_wrapper.h" | 5 #include "ash/system/tray/tray_bubble_wrapper.h" |
6 | 6 |
7 #include "ash/system/tray/tray_background_view.h" | 7 #include "ash/system/tray/tray_background_view.h" |
8 #include "ash/system/tray/tray_bubble_view.h" | 8 #include "ash/system/tray/tray_bubble_view.h" |
9 #include "ash/system/tray/tray_event_filter.h" | 9 #include "ash/system/tray/tray_event_filter.h" |
10 #include "ash/wm/window_properties.h" | 10 #include "ash/wm/window_properties.h" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
12 | 12 |
13 using message_center::TrayBubbleView; | 13 using message_center::TrayBubbleView; |
14 | 14 |
15 namespace ash { | 15 namespace ash { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 TrayBubbleWrapper::TrayBubbleWrapper(TrayBackgroundView* tray, | 18 TrayBubbleWrapper::TrayBubbleWrapper(TrayBackgroundView* tray, |
19 TrayBubbleView* bubble_view) | 19 TrayBubbleView* bubble_view) |
20 : tray_(tray), | 20 : tray_(tray), |
21 bubble_view_(bubble_view) { | 21 bubble_view_(bubble_view) { |
22 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); | 22 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); |
23 bubble_widget_->AddObserver(this); | 23 bubble_widget_->AddObserver(this); |
24 bubble_widget_->GetNativeView()-> | 24 bubble_widget_->GetNativeView()-> |
25 SetProperty(internal::kStayInSameRootWindowKey, true); | 25 SetProperty(internal::kStayInSameRootWindowKey, true); |
26 | 26 |
27 tray_->InitializeBubbleAnimations(bubble_widget_); | |
Harry McCleave
2012/10/30 01:48:12
Am I missing something of importance here as to wh
xiyuan
2012/10/30 16:49:00
Can you be more specific? You mean it is called af
| |
27 bubble_view_->InitializeAndShowBubble(); | 28 bubble_view_->InitializeAndShowBubble(); |
28 tray_->InitializeBubbleAnimations(bubble_widget_); | |
29 | 29 |
30 tray_event_filter_.reset(new TrayEventFilter(this)); | 30 tray_event_filter_.reset(new TrayEventFilter(this)); |
31 } | 31 } |
32 | 32 |
33 TrayBubbleWrapper::~TrayBubbleWrapper() { | 33 TrayBubbleWrapper::~TrayBubbleWrapper() { |
34 tray_event_filter_.reset(); | 34 tray_event_filter_.reset(); |
35 if (bubble_widget_) { | 35 if (bubble_widget_) { |
36 bubble_widget_->RemoveObserver(this); | 36 bubble_widget_->RemoveObserver(this); |
37 bubble_widget_->Close(); | 37 bubble_widget_->Close(); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 void TrayBubbleWrapper::OnWidgetClosing(views::Widget* widget) { | 41 void TrayBubbleWrapper::OnWidgetClosing(views::Widget* widget) { |
42 CHECK_EQ(bubble_widget_, widget); | 42 CHECK_EQ(bubble_widget_, widget); |
43 bubble_widget_ = NULL; | 43 bubble_widget_ = NULL; |
44 tray_->HideBubbleWithView(bubble_view_); // May destroy |bubble_view_| | 44 tray_->HideBubbleWithView(bubble_view_); // May destroy |bubble_view_| |
45 } | 45 } |
46 | 46 |
47 } // namespace internal | 47 } // namespace internal |
48 } // namespace ash | 48 } // namespace ash |
OLD | NEW |