Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: ash/system/tray/tray_bubble_wrapper.cc

Issue 12510005: Remove close_on_deactivate=false for tray bubbles (2nd) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | ash/system/web_notification/web_notification_tray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_event_filter.h" 8 #include "ash/system/tray/tray_event_filter.h"
9 #include "ash/wm/window_properties.h" 9 #include "ash/wm/window_properties.h"
10 #include "base/bind.h"
11 #include "base/message_loop.h"
12 #include "base/time.h"
10 #include "ui/views/bubble/tray_bubble_view.h" 13 #include "ui/views/bubble/tray_bubble_view.h"
11 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
12 15
13 namespace ash { 16 namespace ash {
14 namespace internal { 17 namespace internal {
15 18
16 TrayBubbleWrapper::TrayBubbleWrapper(TrayBackgroundView* tray, 19 TrayBubbleWrapper::TrayBubbleWrapper(TrayBackgroundView* tray,
17 views::TrayBubbleView* bubble_view) 20 views::TrayBubbleView* bubble_view)
18 : tray_(tray), 21 : tray_(tray),
19 bubble_view_(bubble_view) { 22 bubble_view_(bubble_view) {
23 DCHECK(tray_);
20 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); 24 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_);
21 bubble_widget_->AddObserver(this); 25 bubble_widget_->AddObserver(this);
22 bubble_widget_->GetNativeView()-> 26 bubble_widget_->GetNativeView()->
23 SetProperty(internal::kStayInSameRootWindowKey, true); 27 SetProperty(internal::kStayInSameRootWindowKey, true);
24 28
25 tray_->InitializeBubbleAnimations(bubble_widget_); 29 tray_->InitializeBubbleAnimations(bubble_widget_);
26 tray_->UpdateBubbleViewArrow(bubble_view_); 30 tray_->UpdateBubbleViewArrow(bubble_view_);
27 bubble_view_->InitializeAndShowBubble(); 31 bubble_view_->InitializeAndShowBubble();
28 32
29 tray->tray_event_filter()->AddWrapper(this); 33 tray->tray_event_filter()->AddWrapper(this);
30 } 34 }
31 35
32 TrayBubbleWrapper::~TrayBubbleWrapper() { 36 TrayBubbleWrapper::~TrayBubbleWrapper() {
33 tray_->tray_event_filter()->RemoveWrapper(this); 37 tray_->tray_event_filter()->RemoveWrapper(this);
34 if (bubble_widget_) { 38 if (bubble_widget_) {
35 bubble_widget_->RemoveObserver(this); 39 bubble_widget_->RemoveObserver(this);
36 bubble_widget_->Close(); 40 bubble_widget_->Close();
37 } 41 }
38 } 42 }
39 43
40 void TrayBubbleWrapper::OnWidgetDestroying(views::Widget* widget) { 44 void TrayBubbleWrapper::OnWidgetDestroying(views::Widget* widget) {
41 CHECK_EQ(bubble_widget_, widget); 45 CHECK_EQ(bubble_widget_, widget);
42 bubble_widget_ = NULL; 46 bubble_widget_ = NULL;
43 tray_->HideBubbleWithView(bubble_view_); // May destroy |bubble_view_| 47
48 // Do not call HideBubbleWithView directly but post the task to ensure that
49 // HideBubbleWithView is called after the click event on the tray button is
50 // handled. See crbug.com/177075 and crbug.com/169940
51 MessageLoopForUI::current()->PostTask(
52 FROM_HERE,
53 base::Bind(&TrayBackgroundView::HideBubbleWithView,
54 base::Unretained(tray_), base::Unretained(bubble_view_)));
stevenjb 2013/03/06 02:35:26 Is there any possibility that tray_ or bubble_view
Jun Mukai 2013/03/06 04:36:57 Good catch. It's really unlikely but it may happen
44 } 55 }
45 56
46 } // namespace internal 57 } // namespace internal
47 } // namespace ash 58 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | ash/system/web_notification/web_notification_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698