summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-05 19:10:19 +0000
committerdewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-05 19:10:19 +0000
commit35653072a19559aa077fe241c36cd509152f7535 (patch)
tree8dc2bef7514ad077c5a11dfd9c35f2859b681f3a /chrome
parent6737c579fd8e5b2aa81971e5b7b8ceb7e3eb5c13 (diff)
downloadchromium_src-35653072a19559aa077fe241c36cd509152f7535.zip
chromium_src-35653072a19559aa077fe241c36cd509152f7535.tar.gz
chromium_src-35653072a19559aa077fe241c36cd509152f7535.tar.bz2
Re-home the global MessageCenter to support Ash+Win environments.
In the case where Ash is displayed on Windows, we want a single message center data structure with multiple UI surfaces for notifications. g_browser_process now manages the lifetime of the global Message Center object, since its lifetime is always longer than Ash::Shell. This allows us to re-enable the browser tests for message center on Ash+Win, and stops a crash bug. BUG=178429 Review URL: https://chromiumcodereview.appspot.com/12375004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186220 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_process_impl.cc31
-rw-r--r--chrome/browser/browser_process_impl.h9
-rw-r--r--chrome/browser/notifications/desktop_notifications_unittest.cc14
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/test/base/testing_browser_process.cc12
-rw-r--r--chrome/test/base/testing_browser_process.h3
-rw-r--r--chrome/test/base/view_event_test_base.cc14
7 files changed, 39 insertions, 46 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 8f6a95d..3eba46e 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -93,10 +93,6 @@
#include "chrome/browser/policy/policy_service_stub.h"
#endif // defined(ENABLE_CONFIGURATION_POLICY)
-#if defined(ENABLE_MESSAGE_CENTER) && defined(USE_ASH)
-#include "ash/shell.h"
-#endif
-
#if defined(ENABLE_MESSAGE_CENTER)
#include "ui/message_center/message_center.h"
#endif
@@ -159,9 +155,6 @@ BrowserProcessImpl::BrowserProcessImpl(
created_local_state_(false),
created_icon_manager_(false),
created_notification_ui_manager_(false),
-#if defined(ENABLE_MESSAGE_CENTER) && !defined(USE_ASH)
- created_message_center_(false),
-#endif
created_safe_browsing_service_(false),
module_ref_count_(0),
did_start_(false),
@@ -191,6 +184,10 @@ BrowserProcessImpl::BrowserProcessImpl(
extension_event_router_forwarder_ = new extensions::EventRouterForwarder;
ExtensionRendererState::GetInstance()->Init();
+
+#if defined(ENABLE_MESSAGE_CENTER)
+ message_center::MessageCenter::Initialize();
+#endif
}
BrowserProcessImpl::~BrowserProcessImpl() {
@@ -247,6 +244,10 @@ void BrowserProcessImpl::StartTearDown() {
ExtensionRendererState::GetInstance()->Shutdown();
+#if defined(ENABLE_MESSAGE_CENTER)
+ message_center::MessageCenter::Shutdown();
+#endif
+
#if defined(ENABLE_CONFIGURATION_POLICY)
// The policy providers managed by |browser_policy_connector_| need to shut
// down while the IO and FILE threads are still alive.
@@ -461,13 +462,7 @@ NotificationUIManager* BrowserProcessImpl::notification_ui_manager() {
#if defined(ENABLE_MESSAGE_CENTER)
message_center::MessageCenter* BrowserProcessImpl::message_center() {
DCHECK(CalledOnValidThread());
-#if defined(USE_ASH)
- return ash::Shell::GetInstance()->message_center();
-#else
- if (!created_message_center_)
- CreateMessageCenter();
- return message_center_.get();
-#endif
+ return message_center::MessageCenter::Get();
}
#endif
@@ -914,14 +909,6 @@ void BrowserProcessImpl::CreateNotificationUIManager() {
#endif
}
-#if defined(ENABLE_MESSAGE_CENTER) && !defined(USE_ASH)
-void BrowserProcessImpl::CreateMessageCenter() {
- DCHECK(message_center_.get() == NULL);
- message_center_.reset(new message_center::MessageCenter());
- created_message_center_ = true;
-}
-#endif
-
void BrowserProcessImpl::CreateBackgroundModeManager() {
DCHECK(background_mode_manager_.get() == NULL);
background_mode_manager_.reset(
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 3b28dc4..8487798 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -147,9 +147,6 @@ class BrowserProcessImpl : public BrowserProcess,
void CreateIconManager();
void CreateIntranetRedirectDetector();
void CreateNotificationUIManager();
-#if defined(ENABLE_MESSAGE_CENTER) && !defined(USE_ASH)
- void CreateMessageCenter();
-#endif
void CreateStatusTrayManager();
void CreatePrintPreviewDialogController();
void CreateBackgroundPrintingManager();
@@ -215,12 +212,6 @@ class BrowserProcessImpl : public BrowserProcess,
bool created_notification_ui_manager_;
scoped_ptr<NotificationUIManager> notification_ui_manager_;
-#if defined(ENABLE_MESSAGE_CENTER) && !defined(USE_ASH)
- // MessageCenter keeps currently displayed UI notifications.
- scoped_ptr<message_center::MessageCenter> message_center_;
- bool created_message_center_;
-#endif
-
#if defined(ENABLE_AUTOMATION)
scoped_ptr<AutomationProviderList> automation_provider_list_;
#endif
diff --git a/chrome/browser/notifications/desktop_notifications_unittest.cc b/chrome/browser/notifications/desktop_notifications_unittest.cc
index 85ce0e23..aca84f1 100644
--- a/chrome/browser/notifications/desktop_notifications_unittest.cc
+++ b/chrome/browser/notifications/desktop_notifications_unittest.cc
@@ -13,6 +13,10 @@
#include "chrome/common/pref_names.h"
#include "content/public/common/show_desktop_notification_params.h"
+#if defined(ENABLE_MESSAGE_CENTER)
+#include "ui/message_center/message_center.h"
+#endif
+
#if defined(USE_ASH)
#include "ash/shell.h"
#include "ash/test/test_shell_delegate.h"
@@ -97,6 +101,11 @@ DesktopNotificationsTest::~DesktopNotificationsTest() {
void DesktopNotificationsTest::SetUp() {
#if defined(USE_ASH)
WebKit::initialize(webkit_platform_support_.Get());
+#if defined(ENABLE_MESSAGE_CENTER)
+ // The message center is notmally initialized on |g_browser_process| which
+ // is not created for these tests.
+ message_center::MessageCenter::Initialize();
+#endif
// MockBalloonCollection retrieves information about the screen on creation.
// So it is necessary to make sure the desktop gets created first.
ash::Shell::CreateInstance(new ash::test::TestShellDelegate);
@@ -119,6 +128,11 @@ void DesktopNotificationsTest::TearDown() {
#if defined(USE_ASH)
active_desktop_monitor_.reset();
ash::Shell::DeleteInstance();
+#if defined(ENABLE_MESSAGE_CENTER)
+ // The message center is notmally shutdown on |g_browser_process| which
+ // is not created for these tests.
+ message_center::MessageCenter::Shutdown();
+#endif
aura::Env::DeleteInstance();
WebKit::shutdown();
#endif
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index fcb6ae3..520f557 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1857,7 +1857,7 @@
['exclude', '^browser/ui/app_list/'],
],
}],
- ['enable_message_center==0 or use_ash==1', {
+ ['enable_message_center==0', {
'sources!': [
'browser/notifications/message_center_notifications_browsertest.cc',
'browser/ui/views/message_center/web_notification_tray_win_browsertest.cc',
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index bbaab14..e74d080 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -34,10 +34,6 @@
#include "chrome/browser/policy/policy_service_stub.h"
#endif // defined(ENABLE_CONFIGURATION_POLICY)
-#if defined(ENABLE_MESSAGE_CENTER) && defined(USE_ASH)
-#include "ash/shell.h"
-#endif
-
#if defined(ENABLE_MESSAGE_CENTER)
#include "ui/message_center/message_center.h"
#endif
@@ -201,13 +197,7 @@ NotificationUIManager* TestingBrowserProcess::notification_ui_manager() {
#if defined(ENABLE_MESSAGE_CENTER)
message_center::MessageCenter* TestingBrowserProcess::message_center() {
-#if defined(USE_ASH)
- return ash::Shell::GetInstance()->message_center();
-#else
- if (!message_center_.get())
- message_center_.reset(new message_center::MessageCenter());
- return message_center_.get();
-#endif
+ return message_center::MessageCenter::Get();
}
#endif
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index 00ba5d1..99e763e 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -135,9 +135,6 @@ class TestingBrowserProcess : public BrowserProcess {
#endif
scoped_ptr<ProfileManager> profile_manager_;
scoped_ptr<NotificationUIManager> notification_ui_manager_;
-#if defined(ENABLE_MESSAGE_CENTER) && !defined(USE_ASH)
- scoped_ptr<message_center::MessageCenter> message_center_;
-#endif
scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_;
scoped_refptr<printing::PrintPreviewDialogController>
print_preview_dialog_controller_;
diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc
index cbf1f5e..91b1855 100644
--- a/chrome/test/base/view_event_test_base.cc
+++ b/chrome/test/base/view_event_test_base.cc
@@ -18,6 +18,10 @@
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/views/widget/widget.h"
+#if defined(ENABLE_MESSAGE_CENTER)
+#include "ui/message_center/message_center.h"
+#endif
+
#if defined(USE_ASH)
#include "ash/shell.h"
#include "ash/test/test_shell_delegate.h"
@@ -98,6 +102,11 @@ void ViewEventTestBase::SetUp() {
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
#else
+#if defined(ENABLE_MESSAGE_CENTER)
+ // Ash Shell can't just live on its own without a browser process, we need to
+ // also create the message center.
+ message_center::MessageCenter::Initialize();
+#endif
ash::Shell::CreateInstance(new ash::test::TestShellDelegate());
context = ash::Shell::GetPrimaryRootWindow();
#endif
@@ -126,6 +135,11 @@ void ViewEventTestBase::TearDown() {
#if defined(OS_WIN)
#else
ash::Shell::DeleteInstance();
+#if defined(ENABLE_MESSAGE_CENTER)
+ // Ash Shell can't just live on its own without a browser process, we need to
+ // also shut down the message center.
+ message_center::MessageCenter::Shutdown();
+#endif
aura::Env::DeleteInstance();
#endif
#elif defined(USE_AURA)