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

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

Issue 1509923002: Implement native web notifications for mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « chrome/browser/notifications/platform_notification_service_impl.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6a28a84f962924ea2b99752549571da507af4a8a..7995511b55b7130f53f54c8fe8c1586c302451a3 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -10,6 +10,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics_action.h"
#include "base/prefs/pref_service.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
@@ -54,10 +55,6 @@
#include "extensions/common/permissions/permissions_data.h"
#endif
-#if defined(OS_ANDROID)
-#include "base/strings/string_number_conversions.h"
-#endif
-
using content::BrowserContext;
using content::BrowserThread;
using content::PlatformNotificationContext;
@@ -99,7 +96,9 @@ PlatformNotificationServiceImpl::GetInstance() {
}
PlatformNotificationServiceImpl::PlatformNotificationServiceImpl()
- : notification_ui_manager_for_tests_(nullptr) {}
+ : native_notification_ui_manager_(
+ NotificationUIManager::CreateNativeNotificationManager()),
+ notification_ui_manager_for_tests_(nullptr) {}
PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {}
@@ -334,14 +333,19 @@ void PlatformNotificationServiceImpl::ClosePersistentNotification(
DCHECK(profile);
#if defined(OS_ANDROID)
- // TODO(peter): Remove this conversion when the notification ids are being
- // generated by the caller of this method.
- std::string textual_persistent_notification_id =
- base::Int64ToString(persistent_notification_id);
- GetNotificationUIManager()->CancelById(
- textual_persistent_notification_id,
- NotificationUIManager::GetProfileID(profile));
+ bool cancel_by_persistent_id = true;
#else
+ bool cancel_by_persistent_id = (native_notification_ui_manager_ != nullptr);
+#endif
+
+ if (cancel_by_persistent_id) {
+ // TODO(peter): Remove this conversion when the notification ids are being
+ // generated by the caller of this method.
+ GetNotificationUIManager()->CancelById(
+ base::Int64ToString(persistent_notification_id),
+ NotificationUIManager::GetProfileID(profile));
+ }
+
auto iter = persistent_notifications_.find(persistent_notification_id);
if (iter == persistent_notifications_.end())
return;
@@ -350,7 +354,6 @@ void PlatformNotificationServiceImpl::ClosePersistentNotification(
iter->second, NotificationUIManager::GetProfileID(profile));
persistent_notifications_.erase(iter);
-#endif
}
bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications(
@@ -426,6 +429,10 @@ PlatformNotificationServiceImpl::GetNotificationUIManager() const {
if (notification_ui_manager_for_tests_)
return notification_ui_manager_for_tests_;
+ if (native_notification_ui_manager_) {
+ return native_notification_ui_manager_.get();
+ }
+
return g_browser_process->notification_ui_manager();
}
« no previous file with comments | « chrome/browser/notifications/platform_notification_service_impl.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698