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

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

Issue 15582004: Move NotificationDelegate into message_center. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win browsertests. Created 7 years, 7 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
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/message_center_notification_manager.h" 5 #include "chrome/browser/notifications/message_center_notification_manager.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/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/extensions/extension_info_map.h" 10 #include "chrome/browser/extensions/extension_info_map.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 bool by_user) { 235 bool by_user) {
236 // Do not call FindProfileNotification(). Some tests create notifications 236 // Do not call FindProfileNotification(). Some tests create notifications
237 // directly to MessageCenter, but this method will be called for the removals 237 // directly to MessageCenter, but this method will be called for the removals
238 // of such notifications. 238 // of such notifications.
239 NotificationMap::const_iterator iter = 239 NotificationMap::const_iterator iter =
240 profile_notifications_.find(notification_id); 240 profile_notifications_.find(notification_id);
241 if (iter != profile_notifications_.end()) 241 if (iter != profile_notifications_.end())
242 RemoveProfileNotification(iter->second, by_user); 242 RemoveProfileNotification(iter->second, by_user);
243 } 243 }
244 244
245 void MessageCenterNotificationManager::OnNotificationClicked(
246 const std::string& notification_id) {
247 ProfileNotification* profile_notification =
248 FindProfileNotification(notification_id);
249 if (!profile_notification)
250 return;
251 profile_notification->notification().Click();
252 }
253
254 void MessageCenterNotificationManager::OnNotificationButtonClicked(
255 const std::string& notification_id,
256 int button_index) {
257 ProfileNotification* profile_notification =
258 FindProfileNotification(notification_id);
259 if (!profile_notification)
260 return;
261 profile_notification->notification().ButtonClick(button_index);
262 }
263
264 void MessageCenterNotificationManager::OnNotificationDisplayed(
265 const std::string& notification_id) {
266 FindProfileNotification(notification_id)->notification().Display();
267 }
268
269 //////////////////////////////////////////////////////////////////////////////// 245 ////////////////////////////////////////////////////////////////////////////////
270 // ImageDownloads 246 // ImageDownloads
271 247
272 MessageCenterNotificationManager::ImageDownloads::ImageDownloads( 248 MessageCenterNotificationManager::ImageDownloads::ImageDownloads(
273 message_center::MessageCenter* message_center, 249 message_center::MessageCenter* message_center,
274 ImageDownloadsObserver* observer) 250 ImageDownloadsObserver* observer)
275 : message_center_(message_center), 251 : message_center_(message_center),
276 pending_downloads_(0), 252 pending_downloads_(0),
277 observer_(observer) { 253 observer_(observer) {
278 } 254 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // Notification ids should be unique. 434 // Notification ids should be unique.
459 DCHECK(profile_notifications_.find(id) == profile_notifications_.end()); 435 DCHECK(profile_notifications_.find(id) == profile_notifications_.end());
460 profile_notifications_[id] = profile_notification; 436 profile_notifications_[id] = profile_notification;
461 437
462 message_center_->AddNotification(notification.type(), 438 message_center_->AddNotification(notification.type(),
463 notification.notification_id(), 439 notification.notification_id(),
464 notification.title(), 440 notification.title(),
465 notification.body(), 441 notification.body(),
466 notification.display_source(), 442 notification.display_source(),
467 profile_notification->GetExtensionId(), 443 profile_notification->GetExtensionId(),
468 notification.optional_fields()); 444 notification.optional_fields(),
445 notification.delegate());
469 profile_notification->StartDownloads(); 446 profile_notification->StartDownloads();
470 } 447 }
471 448
472 void MessageCenterNotificationManager::RemoveProfileNotification( 449 void MessageCenterNotificationManager::RemoveProfileNotification(
473 ProfileNotification* profile_notification, 450 ProfileNotification* profile_notification,
474 bool by_user) { 451 bool by_user) {
475 profile_notification->notification().Close(by_user); 452 profile_notification->notification().Close(by_user);
476 std::string id = profile_notification->notification().notification_id(); 453 std::string id = profile_notification->notification().notification_id();
477 profile_notifications_.erase(id); 454 profile_notifications_.erase(id);
478 delete profile_notification; 455 delete profile_notification;
479 } 456 }
480 457
481 MessageCenterNotificationManager::ProfileNotification* 458 MessageCenterNotificationManager::ProfileNotification*
482 MessageCenterNotificationManager::FindProfileNotification( 459 MessageCenterNotificationManager::FindProfileNotification(
483 const std::string& id) const { 460 const std::string& id) const {
484 NotificationMap::const_iterator iter = profile_notifications_.find(id); 461 NotificationMap::const_iterator iter = profile_notifications_.find(id);
485 if (iter == profile_notifications_.end()) 462 if (iter == profile_notifications_.end())
486 return NULL; 463 return NULL;
487 464
488 return (*iter).second; 465 return (*iter).second;
489 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698