OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/notifications/balloon_collection_impl.h" | 5 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // There may be no listener in a unit test. | 131 // There may be no listener in a unit test. |
132 if (space_change_listener_) | 132 if (space_change_listener_) |
133 space_change_listener_->OnBalloonSpaceChanged(); | 133 space_change_listener_->OnBalloonSpaceChanged(); |
134 } | 134 } |
135 | 135 |
136 void BalloonCollectionImpl::Observe(NotificationType type, | 136 void BalloonCollectionImpl::Observe(NotificationType type, |
137 const NotificationSource& source, | 137 const NotificationSource& source, |
138 const NotificationDetails& details) { | 138 const NotificationDetails& details) { |
139 DCHECK(type == NotificationType::BROWSER_CLOSED); | 139 DCHECK(type == NotificationType::BROWSER_CLOSED); |
140 bool app_closing = *Details<bool>(details).ptr(); | 140 bool app_closing = *Details<bool>(details).ptr(); |
141 // When exitting, we need to shutdown all renderers in | 141 // When exiting, we need to shutdown all renderers in |
142 // BalloonViewImpl before IO thread gets deleted in the | 142 // BalloonViewImpl before IO thread gets deleted in the |
143 // BrowserProcessImpl's destructor. See http://crbug.com/40810 | 143 // BrowserProcessImpl's destructor. See http://crbug.com/40810 |
144 // for details. | 144 // for details. |
145 if (app_closing) | 145 if (app_closing) |
146 Shutdown(); | 146 RemoveAll(); |
147 } | 147 } |
148 | 148 |
149 void BalloonCollectionImpl::Shutdown() { | 149 void BalloonCollectionImpl::Shutdown() { |
150 // We need to remove the panel first because deleting | 150 // We need to remove the panel first because deleting |
151 // views that are not owned by parent will not remove | 151 // views that are not owned by parent will not remove |
152 // themselves from the parent. | 152 // themselves from the parent. |
153 DVLOG(1) << "Shutting down notification UI"; | 153 DVLOG(1) << "Shutting down notification UI"; |
154 notification_ui_.reset(); | 154 notification_ui_.reset(); |
155 } | 155 } |
156 | 156 |
157 Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification, | 157 Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification, |
158 Profile* profile) { | 158 Profile* profile) { |
159 Balloon* new_balloon = new Balloon(notification, profile, this); | 159 Balloon* new_balloon = new Balloon(notification, profile, this); |
160 new_balloon->set_view(new chromeos::BalloonViewImpl(false, true, false)); | 160 new_balloon->set_view(new chromeos::BalloonViewImpl(false, true, false)); |
161 return new_balloon; | 161 return new_balloon; |
162 } | 162 } |
163 | 163 |
164 } // namespace chromeos | 164 } // namespace chromeos |
165 | 165 |
166 // static | 166 // static |
167 BalloonCollection* BalloonCollection::Create() { | 167 BalloonCollection* BalloonCollection::Create() { |
168 return new chromeos::BalloonCollectionImpl(); | 168 return new chromeos::BalloonCollectionImpl(); |
169 } | 169 } |
OLD | NEW |