[Chrome OS] Move initialization of MessageCenter singleton into Ash.
also,
- use native notifications any time Mash is enabled
- get rid of ScopedKeepAlive in ProfileNotification for Chrome OS
and the call to clear ScopedKeepAlives in HandleAppExitingForPlatform.
This should have no effect on a normal run of Chrome, where the
browser process is kept alive regardless of how many browser windows
are left, but it's necessary to do this for browser tests to
terminate cleanly without jumping through the hoops of manually
destroying existing ProfileNotification objects.
Change-Id: I510ec4e774965159ee03209791f6bd1c43c3c042
Reviewed-on: https://chromium-review.googlesource.com/940186
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Steven Bennetts <[email protected]>
Reviewed-by: James Cook <[email protected]>
Commit-Queue: Evan Stade <[email protected]>
Cr-Commit-Position: refs/heads/master@{#542884}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 0417fb60..2e98e801 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -143,7 +143,13 @@
#include "chrome/browser/chrome_browser_main_mac.h"
#endif
-#if !defined(OS_ANDROID)
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/ui/ash/ash_util.h"
+#endif
+
+#if defined(OS_ANDROID)
+#include "chrome/browser/android/physical_web/physical_web_data_source_android.h"
+#else // !defined(OS_ANDROID)
#include "chrome/browser/gcm/gcm_product_util.h"
#include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_desktop_utils.h"
@@ -180,10 +186,6 @@
#include "chrome/browser/ui/user_manager.h"
#endif
-#if defined(OS_ANDROID)
-#include "chrome/browser/android/physical_web/physical_web_data_source_android.h"
-#endif
-
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
// How often to check if the persistent instance of Chrome needs to restart
// to install an update.
@@ -264,9 +266,16 @@
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
#endif
- // TODO(estade): don't initialize the MessageCenter until we know it's needed
- // (i.e. because a NotificationPlatformBridgeMessageCenter has been created).
- message_center::MessageCenter::Initialize();
+ bool initialize_message_center = true;
+#if defined(OS_CHROMEOS)
+ // On Chrome OS, the message center is initialized and shut down by Ash and
+ // should not be directly accessible to Chrome. However, ARC++ still relies
+ // on the existence of a MessageCenter object, so in Mash, initialize one
+ // here.
+ initialize_message_center = ash_util::IsRunningInMash();
+#endif
+ if (initialize_message_center)
+ message_center::MessageCenter::Initialize();
update_client::UpdateQueryParams::SetDelegate(
ChromeUpdateQueryParamsDelegate::GetInstance());
@@ -376,7 +385,8 @@
storage_monitor::StorageMonitor::Destroy();
#endif
- message_center::MessageCenter::Shutdown();
+ if (message_center::MessageCenter::Get())
+ message_center::MessageCenter::Shutdown();
// The policy providers managed by |browser_policy_connector_| need to shut
// down while the IO and FILE threads are still alive. The monitoring