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

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

Issue 2093953002: Introduce a new API to handle native notification clicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 5 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/platform_notification_service_impl.cc
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
index 61ab36d37158b290bbea78c514850c770d63357b..6e52f15d3fe004fd3b5686a9912fdd98a6779c5d 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -81,38 +81,7 @@ void OnCloseNonPersistentNotificationProfileLoaded(
const std::string& notification_id,
Profile* profile) {
NotificationDisplayServiceFactory::GetForProfile(profile)->Close(
- notification_id);
-}
-
-// Callback to run once the profile has been loaded in order to perform a
-// given |operation| in a notification.
-void ProfileLoadedCallback(NotificationCommon::Operation operation,
- const GURL& origin,
- int64_t persistent_notification_id,
- int action_index,
- Profile* profile) {
- if (!profile) {
- // TODO(miguelg): Add UMA for this condition.
- // Perhaps propagate this through PersistentNotificationStatus.
- LOG(WARNING) << "Profile not loaded correctly";
- return;
- }
-
- switch (operation) {
- case NotificationCommon::CLICK:
- PlatformNotificationServiceImpl::GetInstance()
- ->OnPersistentNotificationClick(profile, persistent_notification_id,
- origin, action_index);
- break;
- case NotificationCommon::CLOSE:
- PlatformNotificationServiceImpl::GetInstance()
- ->OnPersistentNotificationClose(profile, persistent_notification_id,
- origin, true);
- break;
- case NotificationCommon::SETTINGS:
- NotificationCommon::OpenNotificationSettings(profile);
- break;
- }
+ NotificationCommon::NON_PERSISTENT, notification_id);
}
// Callback used to close an non-persistent notification from blink.
@@ -144,22 +113,6 @@ PlatformNotificationServiceImpl::PlatformNotificationServiceImpl()
PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {}
-void PlatformNotificationServiceImpl::ProcessPersistentNotificationOperation(
- NotificationCommon::Operation operation,
- const std::string& profile_id,
- bool incognito,
- const GURL& origin,
- int64_t persistent_notification_id,
- int action_index) {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- DCHECK(profile_manager);
-
- profile_manager->LoadProfile(
- profile_id, incognito,
- base::Bind(&ProfileLoadedCallback, operation, origin,
- persistent_notification_id, action_index));
-}
-
void PlatformNotificationServiceImpl::OnPersistentNotificationClick(
BrowserContext* browser_context,
int64_t persistent_notification_id,
@@ -337,8 +290,10 @@ void PlatformNotificationServiceImpl::DisplayNotification(
new NotificationObjectProxy(browser_context, std::move(delegate));
Notification notification = CreateNotificationFromData(
profile, origin, notification_data, notification_resources, proxy);
- GetNotificationDisplayService(profile)->Display(notification.delegate_id(),
- notification);
+
+ GetNotificationDisplayService(profile)->Display(
+ NotificationCommon::NON_PERSISTENT, notification.delegate_id(),
+ notification);
if (cancel_callback) {
#if defined(OS_WIN)
std::string profile_id =
@@ -381,6 +336,7 @@ void PlatformNotificationServiceImpl::DisplayPersistentNotification(
persistent_notifications_[persistent_notification_id] = notification.id();
GetNotificationDisplayService(profile)->Display(
+ NotificationCommon::PERSISTENT,
base::Int64ToString(delegate->persistent_notification_id()),
notification);
content::RecordAction(
@@ -411,12 +367,14 @@ void PlatformNotificationServiceImpl::ClosePersistentNotification(
// TODO(peter): Remove this conversion when the notification ids are being
// generated by the caller of this method.
GetNotificationDisplayService(profile)->Close(
+ NotificationCommon::PERSISTENT,
base::Int64ToString(persistent_notification_id));
} else {
auto iter = persistent_notifications_.find(persistent_notification_id);
if (iter == persistent_notifications_.end())
return;
- GetNotificationDisplayService(profile)->Close(iter->second);
+ GetNotificationDisplayService(profile)->Close(
+ NotificationCommon::PERSISTENT, iter->second);
}
persistent_notifications_.erase(persistent_notification_id);

Powered by Google App Engine
This is Rietveld 408576698