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

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: rebase Created 5 years 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 bcb89a79aece0f7d9e8956b2c446a2e65c59599b..a147fb3fac433c0e46c6f33eb7316907417cde85 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 "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
@@ -53,10 +54,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;
@@ -98,7 +95,12 @@ PlatformNotificationServiceImpl::GetInstance() {
}
PlatformNotificationServiceImpl::PlatformNotificationServiceImpl()
- : notification_ui_manager_for_tests_(nullptr) {}
+ : notification_ui_manager_for_tests_(nullptr) {
+#if defined(OS_MACOSX)
+ native_notification_ui_manager_.reset(
+ NotificationUIManager::CreateNativeNotificationManager());
+#endif
+}
PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {}
@@ -335,12 +337,17 @@ void PlatformNotificationServiceImpl::ClosePersistentNotification(
#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,
+ base::Int64ToString(persistent_notification_id),
NotificationUIManager::GetProfileID(profile));
#else
+ if (native_notification_ui_manager_ &&
+ native_notification_ui_manager_->AcceptNativeNotifications()) {
+ GetNotificationUIManager()->CancelById(
+ base::Int64ToString(persistent_notification_id),
+ NotificationUIManager::GetProfileID(profile));
+ }
+
auto iter = persistent_notifications_.find(persistent_notification_id);
if (iter == persistent_notifications_.end())
return;
@@ -425,6 +432,11 @@ PlatformNotificationServiceImpl::GetNotificationUIManager() const {
if (notification_ui_manager_for_tests_)
return notification_ui_manager_for_tests_;
+ if (native_notification_ui_manager_ &&
+ native_notification_ui_manager_->AcceptNativeNotifications()) {
+ return native_notification_ui_manager_.get();
+ }
+
return g_browser_process->notification_ui_manager();
}

Powered by Google App Engine
This is Rietveld 408576698