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

Side by Side Diff: chrome/browser/notifications/notification_ui_manager_impl.cc

Issue 11958025: Start delegating notifications to MessageCenter on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix androif build Created 7 years, 11 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
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 "chrome/browser/notifications/notification_ui_manager_impl.h" 5 #include "chrome/browser/notifications/notification_ui_manager_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 NotificationUIManagerImpl::~NotificationUIManagerImpl() { 59 NotificationUIManagerImpl::~NotificationUIManagerImpl() {
60 STLDeleteElements(&show_queue_); 60 STLDeleteElements(&show_queue_);
61 #if defined(OS_MACOSX) 61 #if defined(OS_MACOSX)
62 StopIdleMonitor(); 62 StopIdleMonitor();
63 StopFullScreenMonitor(); 63 StopFullScreenMonitor();
64 #endif 64 #endif
65 } 65 }
66 66
67 void NotificationUIManagerImpl::Add(const Notification& notification, 67 void NotificationUIManagerImpl::Add(const Notification& notification,
68 Profile* profile) { 68 Profile* profile) {
69 if (TryReplacement(notification)) { 69 if (TryReplacement(notification, profile)) {
70 return; 70 return;
71 } 71 }
72 72
73 VLOG(1) << "Added notification. URL: " 73 VLOG(1) << "Added notification. URL: "
74 << notification.content_url().spec(); 74 << notification.content_url().spec();
75 show_queue_.push_back( 75 show_queue_.push_back(
76 new QueuedNotification(notification, profile)); 76 new QueuedNotification(notification, profile));
77 CheckAndShowNotifications(); 77 CheckAndShowNotifications();
78 } 78 }
79 79
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (!ShowNotification(queued_notification->notification(), 154 if (!ShowNotification(queued_notification->notification(),
155 queued_notification->profile())) { 155 queued_notification->profile())) {
156 // Subclass could not show notification, put it back in the queue. 156 // Subclass could not show notification, put it back in the queue.
157 show_queue_.push_front(queued_notification.release()); 157 show_queue_.push_front(queued_notification.release());
158 return; 158 return;
159 } 159 }
160 } 160 }
161 } 161 }
162 162
163 bool NotificationUIManagerImpl::TryReplacement( 163 bool NotificationUIManagerImpl::TryReplacement(
164 const Notification& notification) { 164 const Notification& notification, Profile* profile) {
165 const GURL& origin = notification.origin_url(); 165 const GURL& origin = notification.origin_url();
166 const string16& replace_id = notification.replace_id(); 166 const string16& replace_id = notification.replace_id();
167 167
168 if (replace_id.empty()) 168 if (replace_id.empty())
169 return false; 169 return false;
170 170
171 // First check the queue of pending notifications for replacement. 171 // First check the queue of pending notifications for replacement.
172 // Then check the list of notifications already being shown. 172 // Then check the list of notifications already being shown.
173 for (NotificationDeque::const_iterator iter = show_queue_.begin(); 173 for (NotificationDeque::const_iterator iter = show_queue_.begin();
174 iter != show_queue_.end(); ++iter) { 174 iter != show_queue_.end(); ++iter) {
175 if (origin == (*iter)->notification().origin_url() && 175 if (profile == (*iter)->profile() &&
176 origin == (*iter)->notification().origin_url() &&
176 replace_id == (*iter)->notification().replace_id()) { 177 replace_id == (*iter)->notification().replace_id()) {
177 (*iter)->Replace(notification); 178 (*iter)->Replace(notification);
178 return true; 179 return true;
179 } 180 }
180 } 181 }
181 182
182 // Give the subclass the opportunity to update existing notification. 183 // Give the subclass the opportunity to update existing notification.
183 return UpdateNotification(notification); 184 return UpdateNotification(notification, profile);
184 } 185 }
185 186
186 void NotificationUIManagerImpl::GetQueuedNotificationsForTesting( 187 void NotificationUIManagerImpl::GetQueuedNotificationsForTesting(
187 std::vector<const Notification*>* notifications) { 188 std::vector<const Notification*>* notifications) {
188 for (NotificationDeque::const_iterator iter = show_queue_.begin(); 189 for (NotificationDeque::const_iterator iter = show_queue_.begin();
189 iter != show_queue_.end(); ++iter) { 190 iter != show_queue_.end(); ++iter) {
190 notifications->push_back(&(*iter)->notification()); 191 notifications->push_back(&(*iter)->notification());
191 } 192 }
192 } 193 }
193 194
194 void NotificationUIManagerImpl::Observe( 195 void NotificationUIManagerImpl::Observe(
195 int type, 196 int type,
196 const content::NotificationSource& source, 197 const content::NotificationSource& source,
197 const content::NotificationDetails& details) { 198 const content::NotificationDetails& details) {
198 if (type == chrome::NOTIFICATION_APP_TERMINATING) { 199 if (type == chrome::NOTIFICATION_APP_TERMINATING) {
199 CancelAll(); 200 CancelAll();
200 } else { 201 } else {
201 NOTREACHED(); 202 NOTREACHED();
202 } 203 }
203 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698