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

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

Issue 2906913002: Move handler processing to NotificationDisplayService. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/native_notification_display_service.cc
diff --git a/chrome/browser/notifications/native_notification_display_service.cc b/chrome/browser/notifications/native_notification_display_service.cc
index 392ae390e1e7e5e11201eabb2ee9dd5e8e3b4f5f..a3389178a1ba55813f91a0ad59bdea28bc2379f2 100644
--- a/chrome/browser/notifications/native_notification_display_service.cc
+++ b/chrome/browser/notifications/native_notification_display_service.cc
@@ -9,24 +9,17 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
-#include "base/strings/nullable_string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/message_center_display_service.h"
-#include "chrome/browser/notifications/non_persistent_notification_handler.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_delegate.h"
#include "chrome/browser/notifications/notification_handler.h"
#include "chrome/browser/notifications/notification_platform_bridge.h"
-#include "chrome/browser/notifications/persistent_notification_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_event_dispatcher.h"
-#include "extensions/features/features.h"
-
-#if BUILDFLAG(ENABLE_EXTENSIONS)
-#include "chrome/browser/extensions/api/notifications/extension_notification_handler.h"
-#endif
+// #include "extensions/features/features.h"
Peter Beverloo 2017/06/01 11:32:45 Please delete if this is unused.
Miguel Garcia 2017/06/02 15:02:55 Done.
namespace {
@@ -45,7 +38,8 @@ std::string GetProfileId(Profile* profile) {
NativeNotificationDisplayService::NativeNotificationDisplayService(
Profile* profile,
NotificationPlatformBridge* notification_bridge)
- : profile_(profile),
+ : NotificationDisplayService(profile),
+ profile_(profile),
notification_bridge_(notification_bridge),
notification_bridge_ready_(false),
weak_factory_(this) {
@@ -55,16 +49,6 @@ NativeNotificationDisplayService::NativeNotificationDisplayService(
notification_bridge->SetReadyCallback(base::BindOnce(
&NativeNotificationDisplayService::OnNotificationPlatformBridgeReady,
weak_factory_.GetWeakPtr()));
-
- AddNotificationHandler(NotificationCommon::NON_PERSISTENT,
- base::MakeUnique<NonPersistentNotificationHandler>());
- AddNotificationHandler(NotificationCommon::PERSISTENT,
- base::MakeUnique<PersistentNotificationHandler>());
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- AddNotificationHandler(
- NotificationCommon::EXTENSION,
- base::MakeUnique<extensions::ExtensionNotificationHandler>());
-#endif
}
NativeNotificationDisplayService::~NativeNotificationDisplayService() = default;
@@ -144,46 +128,3 @@ void NativeNotificationDisplayService::GetDisplayed(
weak_factory_.GetWeakPtr(), callback));
}
}
-
-void NativeNotificationDisplayService::ProcessNotificationOperation(
- NotificationCommon::Operation operation,
- NotificationCommon::Type notification_type,
- const std::string& origin,
- const std::string& notification_id,
- int action_index,
- const base::NullableString16& reply) {
- NotificationHandler* handler = GetNotificationHandler(notification_type);
- CHECK(handler);
- switch (operation) {
- case NotificationCommon::CLICK:
- handler->OnClick(profile_, origin, notification_id, action_index, reply);
- break;
- case NotificationCommon::CLOSE:
- handler->OnClose(profile_, origin, notification_id, true /* by_user */);
- break;
- case NotificationCommon::SETTINGS:
- handler->OpenSettings(profile_);
- break;
- }
-}
-
-void NativeNotificationDisplayService::AddNotificationHandler(
- NotificationCommon::Type notification_type,
- std::unique_ptr<NotificationHandler> handler) {
- DCHECK(handler);
- DCHECK_EQ(notification_handlers_.count(notification_type), 0u);
- notification_handlers_[notification_type] = std::move(handler);
-}
-
-void NativeNotificationDisplayService::RemoveNotificationHandler(
- NotificationCommon::Type notification_type) {
- notification_handlers_.erase(notification_type);
-}
-
-NotificationHandler* NativeNotificationDisplayService::GetNotificationHandler(
- NotificationCommon::Type notification_type) {
- DCHECK(notification_handlers_.find(notification_type) !=
- notification_handlers_.end())
- << notification_type << " is not registered.";
- return notification_handlers_[notification_type].get();
-}

Powered by Google App Engine
This is Rietveld 408576698