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

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 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 02f8cd776a05ce9df8b71bdb65471af962ddec0f..b21b1587802c8be78894722d18fe87ea7bb24273 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -4,10 +4,10 @@
#include "chrome/browser/notifications/platform_notification_service_impl.h"
-#include "base/command_line.h"
#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"
@@ -22,7 +22,6 @@
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
-#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
@@ -51,10 +50,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;
@@ -96,7 +91,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() {}
@@ -333,12 +333,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;
@@ -423,6 +428,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