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

Unified Diff: chrome/browser/notifications/message_center_notification_manager.cc

Issue 2659533003: Remove the notificationProvider extension API (Closed)
Patch Set: Remove the notificationProvider extension API Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/message_center_notification_manager.cc
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
index bf036d604c41aed6190874396611ea2bc5f2e9cc..49028114e94e7f66872001c72f23d17f1fc19dd7 100644
--- a/chrome/browser/notifications/message_center_notification_manager.cc
+++ b/chrome/browser/notifications/message_center_notification_manager.cc
@@ -10,17 +10,14 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
-#include "chrome/browser/extensions/api/notification_provider/notification_provider_api.h"
#include "chrome/browser/notifications/extension_welcome_notification.h"
#include "chrome/browser/notifications/extension_welcome_notification_factory.h"
#include "chrome/browser/notifications/fullscreen_notification_blocker.h"
#include "chrome/browser/notifications/message_center_settings_controller.h"
#include "chrome/browser/notifications/notification.h"
-#include "chrome/browser/notifications/notification_conversion_helper.h"
#include "chrome/browser/notifications/profile_notification.h"
#include "chrome/browser/notifications/screen_lock_notification_blocker.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/api/notification_provider.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/extension_registry.h"
@@ -100,19 +97,6 @@ void MessageCenterNotificationManager::Add(const Notification& notification,
// Takes ownership of profile_notification.
AddProfileNotification(std::move(profile_notification_ptr));
- // TODO(liyanhou): Change the logic to only send notifications to one party.
- // Currently, if there is an app with notificationProvider permission,
- // notifications will go to both message center and the app.
- // Change it to send notifications to message center only when the user chose
- // default message center (extension_id.empty()).
-
- // If there exist apps/extensions that have notificationProvider permission,
- // route notifications to one of the apps/extensions.
- std::string extension_id = GetExtensionTakingOverNotifications(profile);
- if (!extension_id.empty())
- AddNotificationToAlternateProvider(profile_notification->notification(),
- profile, extension_id);
-
message_center_->AddNotification(
base::MakeUnique<message_center::Notification>(
profile_notification->notification()));
@@ -322,23 +306,6 @@ MessageCenterNotificationManager::GetMessageCenterNotificationIdForTest(
////////////////////////////////////////////////////////////////////////////////
// private
-void MessageCenterNotificationManager::AddNotificationToAlternateProvider(
- const Notification& notification,
- Profile* profile,
- const std::string& extension_id) const {
- // Convert data from Notification type to NotificationOptions type.
- extensions::api::notifications::NotificationOptions options;
- NotificationConversionHelper::NotificationToNotificationOptions(notification,
- &options);
-
- // Send the notification to the alternate provider extension/app.
- extensions::NotificationProviderEventRouter event_router(profile);
- event_router.CreateNotification(extension_id,
- notification.notifier_id().id,
- notification.delegate_id(),
- options);
-}
-
void MessageCenterNotificationManager::AddProfileNotification(
std::unique_ptr<ProfileNotification> profile_notification) {
const Notification& notification = profile_notification->notification();
@@ -376,25 +343,3 @@ ProfileNotification* MessageCenterNotificationManager::FindProfileNotification(
return (*iter).second.get();
}
-
-std::string
-MessageCenterNotificationManager::GetExtensionTakingOverNotifications(
- Profile* profile) {
- // TODO(liyanhou): When additional settings in Chrome Settings is implemented,
- // change choosing the last app with permission to a user selected app.
- extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(profile);
- DCHECK(registry);
- std::string extension_id;
- for (extensions::ExtensionSet::const_iterator it =
- registry->enabled_extensions().begin();
- it != registry->enabled_extensions().end();
- ++it) {
- if ((*it->get()).permissions_data()->HasAPIPermission(
- extensions::APIPermission::ID::kNotificationProvider)) {
- extension_id = (*it->get()).id();
- return extension_id;
- }
- }
- return extension_id;
-}

Powered by Google App Engine
This is Rietveld 408576698