OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/notifications/balloon_view.h" | 5 #include "chrome/browser/ui/views/notifications/balloon_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/bind.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/notifications/balloon.h" | 13 #include "chrome/browser/notifications/balloon.h" |
13 #include "chrome/browser/notifications/balloon_collection.h" | 14 #include "chrome/browser/notifications/balloon_collection.h" |
14 #include "chrome/browser/notifications/desktop_notification_service.h" | 15 #include "chrome/browser/notifications/desktop_notification_service.h" |
15 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
16 #include "chrome/browser/notifications/notification_options_menu_model.h" | 17 #include "chrome/browser/notifications/notification_options_menu_model.h" |
17 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" | 18 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" |
18 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
19 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 views::BubbleBorder* bubble_border = | 110 views::BubbleBorder* bubble_border = |
110 new views::BubbleBorder(views::BubbleBorder::FLOAT); | 111 new views::BubbleBorder(views::BubbleBorder::FLOAT); |
111 set_border(bubble_border); | 112 set_border(bubble_border); |
112 } | 113 } |
113 | 114 |
114 BalloonViewImpl::~BalloonViewImpl() { | 115 BalloonViewImpl::~BalloonViewImpl() { |
115 } | 116 } |
116 | 117 |
117 void BalloonViewImpl::Close(bool by_user) { | 118 void BalloonViewImpl::Close(bool by_user) { |
118 MessageLoop::current()->PostTask(FROM_HERE, | 119 MessageLoop::current()->PostTask(FROM_HERE, |
119 method_factory_.NewRunnableMethod( | 120 base::Bind(&BalloonViewImpl::DelayedClose, |
120 &BalloonViewImpl::DelayedClose, by_user)); | 121 method_factory_.GetWeakPtr(), |
| 122 by_user)); |
121 } | 123 } |
122 | 124 |
123 gfx::Size BalloonViewImpl::GetSize() const { | 125 gfx::Size BalloonViewImpl::GetSize() const { |
124 // BalloonView has no size if it hasn't been shown yet (which is when | 126 // BalloonView has no size if it hasn't been shown yet (which is when |
125 // balloon_ is set). | 127 // balloon_ is set). |
126 if (!balloon_) | 128 if (!balloon_) |
127 return gfx::Size(0, 0); | 129 return gfx::Size(0, 0); |
128 | 130 |
129 return gfx::Size(GetTotalWidth(), GetTotalHeight()); | 131 return gfx::Size(GetTotalWidth(), GetTotalHeight()); |
130 } | 132 } |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 return; | 510 return; |
509 } | 511 } |
510 | 512 |
511 // If the renderer process attached to this balloon is disconnected | 513 // If the renderer process attached to this balloon is disconnected |
512 // (e.g., because of a crash), we want to close the balloon. | 514 // (e.g., because of a crash), we want to close the balloon. |
513 notification_registrar_.Remove( | 515 notification_registrar_.Remove( |
514 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, | 516 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
515 Source<Balloon>(balloon_)); | 517 Source<Balloon>(balloon_)); |
516 Close(false); | 518 Close(false); |
517 } | 519 } |
OLD | NEW |