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

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 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
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..7202fad0a4ac6761bb9acece1c8b5a1a7790dd99 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,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());
Peter Beverloo 2016/01/08 05:14:26 Could you revert the changes to notification_ui_ma
Miguel Garcia 2016/01/08 11:46:55 So the problem with doing it the way you suggest i
Peter Beverloo 2016/01/08 19:40:19 This is a good point. Looking at various other fil
+#endif
+}
PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {}
@@ -336,12 +338,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),
Peter Beverloo 2016/01/08 05:14:26 I very badly need to clean this up :-(. Per the p
Miguel Garcia 2016/01/08 11:46:55 Done.
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;
@@ -426,6 +433,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