OLD | NEW |
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_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 475 |
476 void MessageCenterNotificationManager::ProfileNotification::StartDownloads() { | 476 void MessageCenterNotificationManager::ProfileNotification::StartDownloads() { |
477 downloads_->StartDownloads(notification_); | 477 downloads_->StartDownloads(notification_); |
478 } | 478 } |
479 | 479 |
480 void | 480 void |
481 MessageCenterNotificationManager::ProfileNotification::OnDownloadsCompleted() { | 481 MessageCenterNotificationManager::ProfileNotification::OnDownloadsCompleted() { |
482 notification_.DoneRendering(); | 482 notification_.DoneRendering(); |
483 } | 483 } |
484 | 484 |
485 std::string | |
486 MessageCenterNotificationManager::ProfileNotification::GetExtensionId() { | |
487 extensions::InfoMap* extension_info_map = | |
488 extensions::ExtensionSystem::Get(profile())->info_map(); | |
489 extensions::ExtensionSet extensions; | |
490 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( | |
491 notification().origin_url(), | |
492 notification().process_id(), | |
493 extensions::APIPermission::kNotifications, | |
494 &extensions); | |
495 | |
496 DesktopNotificationService* desktop_service = | |
497 DesktopNotificationServiceFactory::GetForProfile(profile()); | |
498 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); | |
499 iter != extensions.end(); ++iter) { | |
500 if (desktop_service->IsNotifierEnabled(message_center::NotifierId( | |
501 message_center::NotifierId::APPLICATION, (*iter)->id()))) { | |
502 return (*iter)->id(); | |
503 } | |
504 } | |
505 return std::string(); | |
506 } | |
507 | |
508 void | 485 void |
509 MessageCenterNotificationManager::ProfileNotification::AddToAlternateProvider( | 486 MessageCenterNotificationManager::ProfileNotification::AddToAlternateProvider( |
510 const std::string extension_id) { | 487 const std::string extension_id) { |
511 // Convert data from Notification type to NotificationOptions type. | 488 // Convert data from Notification type to NotificationOptions type. |
512 extensions::api::notifications::NotificationOptions options; | 489 extensions::api::notifications::NotificationOptions options; |
513 NotificationConversionHelper::NotificationToNotificationOptions(notification_, | 490 NotificationConversionHelper::NotificationToNotificationOptions(notification_, |
514 &options); | 491 &options); |
515 | 492 |
516 // Send the notification to the alternate provider extension/app. | 493 // Send the notification to the alternate provider extension/app. |
517 extensions::NotificationProviderEventRouter event_router(profile_); | 494 extensions::NotificationProviderEventRouter event_router(profile_); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 it != registry->enabled_extensions().end(); | 540 it != registry->enabled_extensions().end(); |
564 ++it) { | 541 ++it) { |
565 if ((*it->get()).permissions_data()->HasAPIPermission( | 542 if ((*it->get()).permissions_data()->HasAPIPermission( |
566 extensions::APIPermission::ID::kNotificationProvider)) { | 543 extensions::APIPermission::ID::kNotificationProvider)) { |
567 extension_id = (*it->get()).id(); | 544 extension_id = (*it->get()).id(); |
568 return extension_id; | 545 return extension_id; |
569 } | 546 } |
570 } | 547 } |
571 return extension_id; | 548 return extension_id; |
572 } | 549 } |
OLD | NEW |