Nuke NotificationUIManager from PlatformNotificationServiceImpl

A few highlights
- Always use one kind of profile id (the stable one)
- Always use a single notification id (the persistent one when possible)
- The mac implementation injects the NSUSerNotificationService to allow unittests

Note that the mac and android files are not renamed. Ideally I would land this and then land a straight forward rename cl.

BUG=571056,596161

Review URL: https://codereview.chromium.org/1814923002

Cr-Commit-Position: refs/heads/master@{#388776}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 0b2d2d4..c03d2b5 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -53,6 +53,7 @@
 #include "chrome/browser/metrics/thread_watcher.h"
 #include "chrome/browser/net/chrome_net_log_helper.h"
 #include "chrome/browser/net/crl_set_fetcher.h"
+#include "chrome/browser/notifications/notification_platform_bridge.h"
 #include "chrome/browser/notifications/notification_ui_manager.h"
 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
 #include "chrome/browser/plugins/plugin_finder.h"
@@ -190,6 +191,7 @@
       created_local_state_(false),
       created_icon_manager_(false),
       created_notification_ui_manager_(false),
+      created_notification_bridge_(false),
       created_safe_browsing_service_(false),
       shutting_down_(false),
       tearing_down_(false),
@@ -571,9 +573,25 @@
 
 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() {
   DCHECK(CalledOnValidThread());
+// TODO(miguelg) return NULL for MAC as well once native notifications
+// are enabled by default.
+#if defined(OS_ANDROID)
+  return nullptr;
+#else
   if (!created_notification_ui_manager_)
     CreateNotificationUIManager();
   return notification_ui_manager_.get();
+#endif
+}
+
+NotificationPlatformBridge* BrowserProcessImpl::notification_platform_bridge() {
+#if defined(OS_ANDROID) || defined(OS_MACOSX)
+  if (!created_notification_bridge_)
+    CreateNotificationPlatformBridge();
+  return notification_bridge_.get();
+#else
+  return nullptr;
+#endif
 }
 
 message_center::MessageCenter* BrowserProcessImpl::message_center() {
@@ -1058,8 +1076,18 @@
   intranet_redirect_detector_.swap(intranet_redirect_detector);
 }
 
+void BrowserProcessImpl::CreateNotificationPlatformBridge() {
+#if (defined(OS_ANDROID) || defined(OS_MACOSX)) && defined(ENABLE_NOTIFICATIONS)
+  DCHECK(notification_bridge_.get() == NULL);
+  notification_bridge_.reset(NotificationPlatformBridge::Create());
+  created_notification_bridge_ = true;
+#endif
+}
+
 void BrowserProcessImpl::CreateNotificationUIManager() {
-#if defined(ENABLE_NOTIFICATIONS)
+// Android does not use the NotificationUIManager anuymore
+// All notification traffic is routed through NotificationPlatformBridge.
+#if defined(ENABLE_NOTIFICATIONS) && !defined(OS_ANDROID)
   DCHECK(notification_ui_manager_.get() == NULL);
   notification_ui_manager_.reset(NotificationUIManager::Create(local_state()));
   created_notification_ui_manager_ = true;