Untangle system NotificationDisplayService from sign-in profile

The CL changes how SystemNotificationHelper initializes notification
display service for (transient) system notification.

Previously, the notification display service was created as a profile
keyed service for the sign-in or system profile. On Chrome OS, we are
trying to reduce usage of sign-in profile beyond sign-in screen
(ideally, the profile would be shutdown once a user session starts).
Having system notifications attached to the sign-in profile prevents
this. Good news is that the profile in NotificationDisplayService is
used mainly to map notifications to users/profiles.

In this CL, NotificationDisplayService is updated to be able to work
with null profile (at least for transient notifications), and uses
null profile NotificationDisplayService to handle system notifications.
The system notification display service ownership is moved to
SystemNotificationHelper (it's created lazily, and shut down during
browser process shutdown).

In addition, this changes how NotificationPlatformBridgeChromeOs
detects profile shutdown - instead of explicitly observing profile
desctruction, the bridge is notified of NotificationDisplayService
shutdown (which occurs during profile destruction) by a
NotificationDisplayService instance. This way the platform bridge
can clean up system notifications on null-profile, system notification
display service shutdown.

BUG=901768

Change-Id: I63969f58683a38a009fd0253418c522d58b68512
Reviewed-on: https://chromium-review.googlesource.com/c/1338759
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Steven Bennetts <[email protected]>
Commit-Queue: Toni Baržić <[email protected]>
Cr-Commit-Position: refs/heads/master@{#610908}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 5292392..9178909 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -62,6 +62,7 @@
 #include "chrome/browser/net/chrome_net_log_helper.h"
 #include "chrome/browser/net/system_network_context_manager.h"
 #include "chrome/browser/notifications/notification_platform_bridge.h"
+#include "chrome/browser/notifications/system_notification_helper.h"
 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
 #include "chrome/browser/plugins/plugin_finder.h"
 #include "chrome/browser/policy/chrome_browser_policy_connector.h"
@@ -285,6 +286,8 @@
   message_center::MessageCenter::Initialize();
 #endif
 
+  system_notification_helper_ = std::make_unique<SystemNotificationHelper>();
+
   update_client::UpdateQueryParams::SetDelegate(
       ChromeUpdateQueryParamsDelegate::GetInstance());
 
@@ -375,6 +378,8 @@
   plugins_resource_service_.reset();
 #endif
 
+  system_notification_helper_.reset();
+
 #if !defined(OS_CHROMEOS)
   // Need to clear the desktop notification balloons before the io_thread_ and
   // before the profiles, since if there are any still showing we will access