| 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/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/chromeos/notifications/balloon_view.h" | 10 #include "chrome/browser/chromeos/notifications/balloon_view.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // Margin from the edge of the work area | 22 // Margin from the edge of the work area |
| 23 const int kVerticalEdgeMargin = 5; | 23 const int kVerticalEdgeMargin = 5; |
| 24 const int kHorizontalEdgeMargin = 5; | 24 const int kHorizontalEdgeMargin = 5; |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 namespace chromeos { | 28 namespace chromeos { |
| 29 | 29 |
| 30 BalloonCollectionImpl::BalloonCollectionImpl() | 30 BalloonCollectionImpl::BalloonCollectionImpl() |
| 31 : notification_ui_(new NotificationPanel()) { | 31 : notification_ui_(new NotificationPanel()) { |
| 32 registrar_.Add(this, NotificationType::BROWSER_CLOSED, | 32 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
| 33 NotificationService::AllSources()); | 33 NotificationService::AllSources()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 BalloonCollectionImpl::~BalloonCollectionImpl() { | 36 BalloonCollectionImpl::~BalloonCollectionImpl() { |
| 37 Shutdown(); | 37 Shutdown(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void BalloonCollectionImpl::Add(const Notification& notification, | 40 void BalloonCollectionImpl::Add(const Notification& notification, |
| 41 Profile* profile) { | 41 Profile* profile) { |
| 42 Balloon* new_balloon = MakeBalloon(notification, profile); | 42 Balloon* new_balloon = MakeBalloon(notification, profile); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // This is used only for testing. | 139 // This is used only for testing. |
| 140 if (on_collection_changed_callback_.get()) | 140 if (on_collection_changed_callback_.get()) |
| 141 on_collection_changed_callback_->Run(); | 141 on_collection_changed_callback_->Run(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 const BalloonCollectionImpl::Balloons& | 144 const BalloonCollectionImpl::Balloons& |
| 145 BalloonCollectionImpl::GetActiveBalloons() { | 145 BalloonCollectionImpl::GetActiveBalloons() { |
| 146 return base_.balloons(); | 146 return base_.balloons(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void BalloonCollectionImpl::Observe(NotificationType type, | 149 void BalloonCollectionImpl::Observe(int type, |
| 150 const NotificationSource& source, | 150 const NotificationSource& source, |
| 151 const NotificationDetails& details) { | 151 const NotificationDetails& details) { |
| 152 DCHECK(type == NotificationType::BROWSER_CLOSED); | 152 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED); |
| 153 bool app_closing = *Details<bool>(details).ptr(); | 153 bool app_closing = *Details<bool>(details).ptr(); |
| 154 // When exiting, we need to shutdown all renderers in | 154 // When exiting, we need to shutdown all renderers in |
| 155 // BalloonViewImpl before IO thread gets deleted in the | 155 // BalloonViewImpl before IO thread gets deleted in the |
| 156 // BrowserProcessImpl's destructor. See http://crbug.com/40810 | 156 // BrowserProcessImpl's destructor. See http://crbug.com/40810 |
| 157 // for details. | 157 // for details. |
| 158 if (app_closing) | 158 if (app_closing) |
| 159 RemoveAll(); | 159 RemoveAll(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void BalloonCollectionImpl::Shutdown() { | 162 void BalloonCollectionImpl::Shutdown() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 173 new_balloon->set_view(new chromeos::BalloonViewImpl(false, true, false)); | 173 new_balloon->set_view(new chromeos::BalloonViewImpl(false, true, false)); |
| 174 return new_balloon; | 174 return new_balloon; |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace chromeos | 177 } // namespace chromeos |
| 178 | 178 |
| 179 // static | 179 // static |
| 180 BalloonCollection* BalloonCollection::Create() { | 180 BalloonCollection* BalloonCollection::Create() { |
| 181 return new chromeos::BalloonCollectionImpl(); | 181 return new chromeos::BalloonCollectionImpl(); |
| 182 } | 182 } |
| OLD | NEW |