diff options
author | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 05:30:24 +0000 |
---|---|---|
committer | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 05:30:24 +0000 |
commit | fb1aac14e2833d6ba5b9d9ba61a964a6eb26f180 (patch) | |
tree | 3ec59087d20b1bded6b25484dbc7558a6957b76f | |
parent | 25c2f0dd9ae9c7f8db2527dd72e3cbb45666c57e (diff) | |
download | chromium_src-fb1aac14e2833d6ba5b9d9ba61a964a6eb26f180.zip chromium_src-fb1aac14e2833d6ba5b9d9ba61a964a6eb26f180.tar.gz chromium_src-fb1aac14e2833d6ba5b9d9ba61a964a6eb26f180.tar.bz2 |
Remove ENABLE_MESSAGE_CENTER
Next step on re-factoring Notifications. This will bring the MessageCenter classes, most important message_center::Notification, into build on all systems, including those where the MessageCenter is not yet appearign in UI. This will allow to start using this Notification class in client code and remove the old Notification class defined in chrome/browser/notificaitons/notification.h
That will allow the clients that already use Rich Notifications to use richer data type support, for example supply an image bits for a Notification (as in Snapshot notifications).
This also removes a lot of compile-time @ifdefs and replaces them with checking a runtime flag which we already have anyways.
On Android and iOS, the MessageCenter is not compiled in, for the size concerns and uncertain story for notifications in general - the existing ENABLE_NOTIFICATIONS define is used for that.
BUG=174164
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=199625
Review URL: https://chromiumcodereview.appspot.com/15025002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199920 0039d316-1c4b-4281-b951-d872f2087c98
34 files changed, 344 insertions, 467 deletions
diff --git a/ash/shell/content_client/shell_browser_main_parts.cc b/ash/shell/content_client/shell_browser_main_parts.cc index eab497b..7046ee3 100644 --- a/ash/shell/content_client/shell_browser_main_parts.cc +++ b/ash/shell/content_client/shell_browser_main_parts.cc @@ -29,13 +29,10 @@ #include "ui/compositor/compositor.h" #include "ui/compositor/test/compositor_test_support.h" #include "ui/gfx/screen.h" +#include "ui/message_center/message_center.h" #include "ui/views/focus/accelerator_handler.h" #include "ui/views/test/test_views_delegate.h" -#if defined(ENABLE_MESSAGE_CENTER) -#include "ui/message_center/message_center.h" -#endif - #if defined(USE_X11) #include "ui/base/touch/touch_factory_x11.h" #endif @@ -112,11 +109,9 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { views::ViewsDelegate::views_delegate = new ShellViewsDelegate; delegate_ = new ash::shell::ShellDelegateImpl; -#if defined(ENABLE_MESSAGE_CENTER) // The global message center state must be initialized absent // g_browser_process. message_center::MessageCenter::Initialize(); -#endif #if defined(OS_CHROMEOS) if (ash::switches::UseNewAudioHandler()) { @@ -154,11 +149,9 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() { delegate_->SetWatcher(NULL); delegate_ = NULL; ash::Shell::DeleteInstance(); -#if defined(ENABLE_MESSAGE_CENTER) // The global message center state must be shutdown absent // g_browser_process. message_center::MessageCenter::Shutdown(); -#endif #if defined(OS_CHROMEOS) if (ash::switches::UseNewAudioHandler()) diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc index 6392f3a..50d3879 100644 --- a/ash/test/ash_test_helper.cc +++ b/ash/test/ash_test_helper.cc @@ -13,10 +13,7 @@ #include "ui/aura/env.h" #include "ui/base/ime/text_input_test_support.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" - -#if defined(ENABLE_MESSAGE_CENTER) #include "ui/message_center/message_center.h" -#endif #if defined(OS_CHROMEOS) #include "chromeos/audio/cras_audio_handler.h" @@ -43,11 +40,9 @@ void AshTestHelper::SetUp() { // Creates Shell and hook with Desktop. test_shell_delegate_ = new TestShellDelegate; -#if defined(ENABLE_MESSAGE_CENTER) // Creates MessageCenter since g_browser_process is not created in AshTestBase // tests. message_center::MessageCenter::Initialize(); -#endif #if defined(OS_CHROMEOS) if (ash::switches::UseNewAudioHandler()) { @@ -69,10 +64,8 @@ void AshTestHelper::TearDown() { // Tear down the shell. Shell::DeleteInstance(); -#if defined(ENABLE_MESSAGE_CENTER) // Remove global message center state. message_center::MessageCenter::Shutdown(); -#endif #if defined(OS_CHROMEOS) if (ash::switches::UseNewAudioHandler()) diff --git a/build/common.gypi b/build/common.gypi index ed9d6d3..06e9b3b 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -155,13 +155,6 @@ 'enable_app_list%': 0, }], - # Enable Message Center only on ChromeOS, Windows, and Mac for now. - ['use_ash==1 or OS=="win" or OS=="mac"', { - 'enable_message_center%': 1, - }, { - 'enable_message_center%': 0, - }], - ['use_aura==1 or (OS!="win" and OS!="mac" and OS!="ios" and OS!="android")', { 'use_default_render_theme%': 1, }, { @@ -194,7 +187,6 @@ 'android_webview_build%': '<(android_webview_build)', 'google_tv%': '<(google_tv)', 'enable_app_list%': '<(enable_app_list)', - 'enable_message_center%': '<(enable_message_center)', 'use_default_render_theme%': '<(use_default_render_theme)', 'buildtype%': '<(buildtype)', 'branding%': '<(branding)', @@ -803,7 +795,6 @@ 'gyp_managed_install%': 0, 'google_tv%': '<(google_tv)', 'enable_app_list%': '<(enable_app_list)', - 'enable_message_center%': '<(enable_message_center)', 'use_default_render_theme%': '<(use_default_render_theme)', 'enable_settings_app%': '<(enable_settings_app)', 'use_official_google_api_keys%': '<(use_official_google_api_keys)', @@ -2202,9 +2193,6 @@ ['enable_app_list==1', { 'defines': ['ENABLE_APP_LIST=1'], }], - ['enable_message_center==1', { - 'defines': ['ENABLE_MESSAGE_CENTER=1'], - }], ['enable_settings_app==1', { 'defines': ['ENABLE_SETTINGS_APP=1'], }], diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 3ed9a38..a6685b9 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -32,11 +32,8 @@ #include "ui/gfx/switches.h" #include "ui/gl/gl_switches.h" #include "ui/keyboard/keyboard_switches.h" -#include "ui/surface/surface_switches.h" - -#if defined(ENABLE_MESSAGE_CENTER) #include "ui/message_center/message_center_switches.h" -#endif +#include "ui/surface/surface_switches.h" #if defined(USE_ASH) #include "ash/ash_switches.h" @@ -1297,7 +1294,6 @@ const Experiment kExperiments[] = { ENABLE_DISABLE_VALUE_TYPE(switches::kEnableTouchEditing, switches::kDisableTouchEditing) }, -#if defined(ENABLE_MESSAGE_CENTER) { "enable-rich-notifications", IDS_FLAGS_ENABLE_RICH_NOTIFICATIONS_NAME, @@ -1307,7 +1303,6 @@ const Experiment kExperiments[] = { message_center::switches::kEnableRichNotifications, message_center::switches::kDisableRichNotifications) }, -#endif { "enable-sync-synced-notifications", IDS_FLAGS_ENABLE_SYNCED_NOTIFICATIONS_NAME, diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h index 0b4c674..22b347c 100644 --- a/chrome/browser/browser_process.h +++ b/chrome/browser/browser_process.h @@ -54,11 +54,9 @@ namespace extensions { class EventRouterForwarder; } -#if defined(ENABLE_MESSAGE_CENTER) namespace message_center { class MessageCenter; } -#endif namespace net { class URLRequestContextGetter; @@ -114,10 +112,8 @@ class BrowserProcess { // Returns the manager for desktop notifications. virtual NotificationUIManager* notification_ui_manager() = 0; -#if defined(ENABLE_MESSAGE_CENTER) // MessageCenter is a global list of currently displayed notifications. virtual message_center::MessageCenter* message_center() = 0; -#endif // Returns the state object for the thread that we perform I/O // coordination on (network requests, communication with renderers, diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index dca205e..d65c37a 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -89,6 +89,7 @@ #include "net/socket/client_socket_pool_manager.h" #include "net/url_request/url_request_context_getter.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/message_center/message_center.h" #if defined(ENABLE_CONFIGURATION_POLICY) #include "chrome/browser/policy/browser_policy_connector.h" @@ -96,10 +97,6 @@ #include "chrome/browser/policy/policy_service_stub.h" #endif // defined(ENABLE_CONFIGURATION_POLICY) -#if defined(ENABLE_MESSAGE_CENTER) -#include "ui/message_center/message_center.h" -#endif - #if defined(OS_WIN) #include "base/win/windows_version.h" #include "ui/views/focus/view_storage.h" @@ -203,9 +200,7 @@ BrowserProcessImpl::BrowserProcessImpl( extension_event_router_forwarder_ = new extensions::EventRouterForwarder; ExtensionRendererState::GetInstance()->Init(); -#if defined(ENABLE_MESSAGE_CENTER) message_center::MessageCenter::Initialize(); -#endif } BrowserProcessImpl::~BrowserProcessImpl() { @@ -262,9 +257,7 @@ 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 @@ -478,12 +471,10 @@ NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { return notification_ui_manager_.get(); } -#if defined(ENABLE_MESSAGE_CENTER) message_center::MessageCenter* BrowserProcessImpl::message_center() { DCHECK(CalledOnValidThread()); return message_center::MessageCenter::Get(); } -#endif policy::BrowserPolicyConnector* BrowserProcessImpl::browser_policy_connector() { DCHECK(CalledOnValidThread()); diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index b1b8577..7010aa3 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -87,9 +87,7 @@ class BrowserProcessImpl : public BrowserProcess, virtual extensions::EventRouterForwarder* extension_event_router_forwarder() OVERRIDE; virtual NotificationUIManager* notification_ui_manager() OVERRIDE; -#if defined(ENABLE_MESSAGE_CENTER) virtual message_center::MessageCenter* message_center() OVERRIDE; -#endif virtual policy::BrowserPolicyConnector* browser_policy_connector() OVERRIDE; virtual policy::PolicyService* policy_service() OVERRIDE; virtual IconManager* icon_manager() OVERRIDE; diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 26d1ad5..a93cfad 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -127,6 +127,7 @@ #include "ppapi/host/ppapi_host.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/message_center/message_center_util.h" #include "webkit/glue/webpreferences.h" #include "webkit/plugins/plugin_switches.h" @@ -161,10 +162,6 @@ #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" #endif -#if defined(ENABLE_MESSAGE_CENTER) -#include "ui/message_center/message_center_util.h" -#endif - #if defined(OS_ANDROID) #include "ui/base/ui_base_paths.h" #endif @@ -1254,10 +1251,8 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( if (content::IsThreadedCompositingEnabled()) command_line->AppendSwitch(switches::kEnableThreadedCompositing); -#if defined(ENABLE_MESSAGE_CENTER) if (message_center::IsRichNotificationEnabled()) command_line->AppendSwitch(switches::kDisableHTMLNotifications); -#endif // Please keep this in alphabetical order. static const char* const kSwitchNames[] = { diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc index 19a6626..e45df6f 100644 --- a/chrome/browser/extensions/api/notifications/notifications_api.cc +++ b/chrome/browser/extensions/api/notifications/notifications_api.cc @@ -21,6 +21,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "googleurl/src/gurl.h" +#include "ui/message_center/message_center_util.h" namespace extensions { @@ -141,38 +142,35 @@ NotificationsApiFunction::NotificationsApiFunction() { NotificationsApiFunction::~NotificationsApiFunction() { } -// If older notification runtime is used, MessageCenter is not built. -// Use simpler bridge then, ignoring all options. -#if !defined (ENABLE_MESSAGE_CENTER) void NotificationsApiFunction::CreateNotification( const std::string& id, api::notifications::NotificationOptions* options) { - message_center::NotificationType type = - MapApiTemplateTypeToType(options->type); - GURL icon_url(UTF8ToUTF16(options->icon_url)); - string16 title(UTF8ToUTF16(options->title)); - string16 message(UTF8ToUTF16(options->message)); - - // Ignore options if running on the old notification runtime. - scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); - - NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate( - this, - profile(), - extension_->id(), - id)); // ownership is passed to Notification - Notification notification(type, extension_->url(), icon_url, title, message, - WebKit::WebTextDirectionDefault, - UTF8ToUTF16(extension_->name()), - UTF8ToUTF16(api_delegate->id()), - optional_fields.get(), api_delegate); + // If older notification runtime is used, use simpler bridge. + if (!message_center::IsRichNotificationEnabled()) { + message_center::NotificationType type = + MapApiTemplateTypeToType(options->type); + GURL icon_url(UTF8ToUTF16(options->icon_url)); + string16 title(UTF8ToUTF16(options->title)); + string16 message(UTF8ToUTF16(options->message)); + + // Ignore options if running on the old notification runtime. + scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); + + NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate( + this, + profile(), + extension_->id(), + id)); // ownership is passed to Notification + Notification notification(type, extension_->url(), icon_url, title, message, + WebKit::WebTextDirectionDefault, + UTF8ToUTF16(extension_->name()), + UTF8ToUTF16(api_delegate->id()), + optional_fields.get(), api_delegate); + + g_browser_process->notification_ui_manager()->Add(notification, profile()); + return; + } - g_browser_process->notification_ui_manager()->Add(notification, profile()); -} -#else // defined(ENABLE_MESSAGE_CENTER) -void NotificationsApiFunction::CreateNotification( - const std::string& id, - api::notifications::NotificationOptions* options) { message_center::NotificationType type = MapApiTemplateTypeToType(options->type); GURL icon_url(UTF8ToUTF16(options->icon_url)); @@ -251,7 +249,6 @@ void NotificationsApiFunction::CreateNotification( g_browser_process->notification_ui_manager()->Add(notification, profile()); } -#endif // !defined(ENABLE_MESSAGE_CENTER) bool NotificationsApiFunction::IsNotificationsApiEnabled() { DesktopNotificationService* service = diff --git a/chrome/browser/extensions/api/notifications/notifications_apitest.cc b/chrome/browser/extensions/api/notifications/notifications_apitest.cc index a251db9..e84c10a 100644 --- a/chrome/browser/extensions/api/notifications/notifications_apitest.cc +++ b/chrome/browser/extensions/api/notifications/notifications_apitest.cc @@ -274,12 +274,15 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestCSP) { ASSERT_TRUE(RunExtensionTest("notifications/api/csp")) << message_; } -#ifdef ENABLE_MESSAGE_CENTER -#if !defined(OS_WIN) || !defined(USE_ASH) +// MessaceCenter-specific test. +#if defined(RUN_MESSAGE_CENTER_TESTS) +#define MAYBE_TestByUser TestByUser +#else +#define MAYBE_TestByUser DISABLED_TestByUser +#endif -IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestByUser) { - if (!message_center::IsRichNotificationEnabled()) - return; +IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestByUser) { + ASSERT_TRUE(message_center::IsRichNotificationEnabled()); const extensions::Extension* extension = LoadExtensionAndWait("notifications/api/by_user"); @@ -301,6 +304,3 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestByUser) { EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); } } - -#endif -#endif diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc index 287aea9..502b43d 100644 --- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc +++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc @@ -25,13 +25,10 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/result_codes.h" - -#if defined(ENABLE_MESSAGE_CENTER) -#include "base/command_line.h" #include "ui/message_center/message_center.h" #include "ui/message_center/message_center_switches.h" +#include "ui/message_center/message_center_util.h" #include "ui/message_center/notification_list.h" -#endif using content::NavigationController; using content::WebContents; @@ -117,91 +114,64 @@ class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest { }; -// TODO(rsesek): Implement and enable these tests. http://crbug.com/179904 -#if defined(ENABLE_MESSAGE_CENTER) && !defined(OS_MACOSX) - -class MessageCenterExtensionCrashRecoveryTest +class MAYBE_ExtensionCrashRecoveryTest : public ExtensionCrashRecoveryTestBase { protected: - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - ExtensionCrashRecoveryTestBase::SetUpCommandLine(command_line); - command_line->AppendSwitch( - message_center::switches::kEnableRichNotifications); - } - virtual void AcceptNotification(size_t index) OVERRIDE { - message_center::MessageCenter* message_center = - message_center::MessageCenter::Get(); - ASSERT_GT(message_center->NotificationCount(), index); - message_center::NotificationList::Notifications::reverse_iterator it = - message_center->GetNotifications().rbegin(); - for (size_t i=0; i < index; ++i) - it++; - std::string id = (*it)->id(); - message_center->ClickOnNotification(id); + if (message_center::IsRichNotificationEnabled()) { + message_center::MessageCenter* message_center = + message_center::MessageCenter::Get(); + ASSERT_GT(message_center->NotificationCount(), index); + message_center::NotificationList::Notifications::reverse_iterator it = + message_center->GetNotifications().rbegin(); + for (size_t i=0; i < index; ++i) + it++; + std::string id = (*it)->id(); + message_center->ClickOnNotification(id); + } else { + Balloon* balloon = GetNotificationDelegate(index); + ASSERT_TRUE(balloon); + balloon->OnClick(); + } WaitForExtensionLoad(); } virtual void CancelNotification(size_t index) OVERRIDE { - message_center::MessageCenter* message_center = - message_center::MessageCenter::Get(); - ASSERT_GT(message_center->NotificationCount(), index); - message_center::NotificationList::Notifications::reverse_iterator it = - message_center->GetNotifications().rbegin(); - for (size_t i=0; i < index; i++) { it++; } - ASSERT_TRUE( - g_browser_process->notification_ui_manager()->CancelById((*it)->id())); + if (message_center::IsRichNotificationEnabled()) { + message_center::MessageCenter* message_center = + message_center::MessageCenter::Get(); + ASSERT_GT(message_center->NotificationCount(), index); + message_center::NotificationList::Notifications::reverse_iterator it = + message_center->GetNotifications().rbegin(); + for (size_t i=0; i < index; i++) { it++; } + ASSERT_TRUE(g_browser_process->notification_ui_manager()-> + CancelById((*it)->id())); + } else { + Balloon* balloon = GetNotificationDelegate(index); + ASSERT_TRUE(balloon); + std::string id = balloon->notification().notification_id(); + ASSERT_TRUE(g_browser_process->notification_ui_manager()->CancelById(id)); + } } virtual size_t CountBalloons() OVERRIDE { - message_center::MessageCenter* message_center = - message_center::MessageCenter::Get(); - return message_center->NotificationCount(); - } -}; - -typedef MessageCenterExtensionCrashRecoveryTest - MAYBE_ExtensionCrashRecoveryTest; - -#else // defined(ENABLED_MESSAGE_CENTER) - -class BalloonExtensionCrashRecoveryTest - : public ExtensionCrashRecoveryTestBase { - protected: - virtual void AcceptNotification(size_t index) OVERRIDE { - Balloon* balloon = GetNotificationDelegate(index); - ASSERT_TRUE(balloon); - balloon->OnClick(); - WaitForExtensionLoad(); - } + if (message_center::IsRichNotificationEnabled()) + return message_center::MessageCenter::Get()->NotificationCount(); - virtual void CancelNotification(size_t index) OVERRIDE { - Balloon* balloon = GetNotificationDelegate(index); - ASSERT_TRUE(balloon); - std::string id = balloon->notification().notification_id(); - ASSERT_TRUE(g_browser_process->notification_ui_manager()->CancelById(id)); + return BalloonNotificationUIManager::GetInstanceForTesting()-> + balloon_collection()->GetActiveBalloons().size(); } - virtual size_t CountBalloons() OVERRIDE { - BalloonNotificationUIManager* manager = - BalloonNotificationUIManager::GetInstanceForTesting(); - BalloonCollection::Balloons balloons = - manager->balloon_collection()->GetActiveBalloons(); - return balloons.size(); - } - private: - Balloon* GetNotificationDelegate(size_t index) { - BalloonNotificationUIManager* manager = - BalloonNotificationUIManager::GetInstanceForTesting(); - BalloonCollection::Balloons balloons = - manager->balloon_collection()->GetActiveBalloons(); - return index < balloons.size() ? balloons.at(index) : NULL; - } +private: + Balloon* GetNotificationDelegate(size_t index) { + BalloonNotificationUIManager* manager = + BalloonNotificationUIManager::GetInstanceForTesting(); + BalloonCollection::Balloons balloons = + manager->balloon_collection()->GetActiveBalloons(); + return index < balloons.size() ? balloons.at(index) : NULL; + } }; -typedef BalloonExtensionCrashRecoveryTest MAYBE_ExtensionCrashRecoveryTest; -#endif // defined(ENABLE_MESSAGE_CENTER) - IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, Basic) { const size_t size_before = GetExtensionService()->extensions()->size(); const size_t crash_size_before = diff --git a/chrome/browser/extensions/notifications_apitest.cc b/chrome/browser/extensions/notifications_apitest.cc index a1a8b39..858c45e 100644 --- a/chrome/browser/extensions/notifications_apitest.cc +++ b/chrome/browser/extensions/notifications_apitest.cc @@ -8,9 +8,6 @@ #include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" - -#if defined(ENABLE_MESSAGE_CENTER) - #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/lazy_background_page_test_util.h" #include "chrome/common/chrome_switches.h" @@ -18,28 +15,10 @@ #include "ui/message_center/message_center_switches.h" #include "ui/message_center/message_center_util.h" -class RichWebkitNotificationTest : public ExtensionApiTest { +class NotificationIdleTest : public ExtensionApiTest { protected: virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { ExtensionApiTest::SetUpCommandLine(command_line); - command_line->AppendSwitch( - message_center::switches::kEnableRichNotifications); - } -}; - -class DisabledRichWebkitNotificationTest : public ExtensionApiTest { - protected: - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - ExtensionApiTest::SetUpCommandLine(command_line); - command_line->AppendSwitch( - message_center::switches::kDisableRichNotifications); - } -}; - -class NotificationIdleTest : public RichWebkitNotificationTest { - protected: - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - RichWebkitNotificationTest::SetUpCommandLine(command_line); command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1"); command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1"); @@ -56,51 +35,44 @@ class NotificationIdleTest : public RichWebkitNotificationTest { } }; -#endif - // TODO(kbr): remove: http://crbug.com/222296 #if defined(OS_MACOSX) #import "base/mac/mac_util.h" #endif IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) { -#if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) - // Notifications not supported on linux/views yet. -#else ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_; -#endif } -#if defined(ENABLE_MESSAGE_CENTER) -IN_PROC_BROWSER_TEST_F(RichWebkitNotificationTest, NoHTMLNotifications) { +// This test verifies that on RichNotification-enabled platforms HTML +// notificaitons are disabled. +#if defined(RUN_MESSAGE_CENTER_TESTS) +#define MAYBE_NoHTMLNotifications NoHTMLNotifications +#else +#define MAYBE_NoHTMLNotifications DISABLED_NoHTMLNotifications +#endif +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_NoHTMLNotifications) { + ASSERT_TRUE(message_center::IsRichNotificationEnabled()); ASSERT_TRUE(RunExtensionTest("notifications/no_html")) << message_; } -#if !defined(OS_CHROMEOS) -// HTML notifications fail on ChromeOS whether or not rich notifications -// are enabled. -IN_PROC_BROWSER_TEST_F(DisabledRichWebkitNotificationTest, - HasHTMLNotifications) { - ASSERT_FALSE(message_center::IsRichNotificationEnabled()); - ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) - << message_; -} +// This test verifies that on platforms other then RichNotification-enabled +// HTML notificaitons are enabled. +#if defined(RUN_MESSAGE_CENTER_TESTS) +#define MAYBE_HasHTMLNotificationsAndManifestPermission \ + DISABLED_HasHTMLNotificationsAndManifestPermission +#else +#define MAYBE_HasHTMLNotificationsAndManifestPermission \ + HasHTMLNotificationsAndManifestPermission #endif - -#elif !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) -// Notifications not supported on linux/views yet. IN_PROC_BROWSER_TEST_F(ExtensionApiTest, - NotificationsHasPermissionManifest) { + MAYBE_HasHTMLNotificationsAndManifestPermission) { + ASSERT_FALSE(message_center::IsRichNotificationEnabled()); ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) << message_; } -#endif IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { -#if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) - // Notifications not supported on linux/views yet. -#else - #if defined(OS_MACOSX) // TODO(kbr): re-enable: http://crbug.com/222296 if (base::mac::IsOSMountainLionOrLater()) @@ -112,11 +84,16 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel")); ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs")) << message_; -#endif } -#if defined(ENABLE_MESSAGE_CENTER) -IN_PROC_BROWSER_TEST_F(NotificationIdleTest, NotificationsAllowUnload) { + // MessaceCenter-specific test. +#if defined(RUN_MESSAGE_CENTER_TESTS) +#define MAYBE_NotificationsAllowUnload NotificationsAllowUnload +#else +#define MAYBE_NotificationsAllowUnload DISABLED_NotificationsAllowUnload +#endif + +IN_PROC_BROWSER_TEST_F(NotificationIdleTest, MAYBE_NotificationsAllowUnload) { const extensions::Extension* extension = LoadExtensionAndWait("notifications/api/unload"); ASSERT_TRUE(extension) << message_; @@ -126,4 +103,3 @@ IN_PROC_BROWSER_TEST_F(NotificationIdleTest, NotificationsAllowUnload) { extensions::ExtensionSystem::Get(profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); } -#endif diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index e2127ea..54b3d05 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -43,6 +43,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/message_center/message_center_util.h" #include "ui/message_center/notifier_settings.h" #include "ui/webui/web_ui_util.h" @@ -57,15 +58,6 @@ const ContentSetting kDefaultSetting = CONTENT_SETTING_ASK; namespace { -bool UsesTextNotifications() { -#if defined(USE_ASH) - return true; -#else - return - g_browser_process->notification_ui_manager()->DelegatesToMessageCenter(); -#endif -} - void ToggleListPrefItem(PrefService* prefs, const char* key, const std::string& item, bool flag) { ListPrefUpdate update(prefs, key); @@ -239,12 +231,10 @@ bool NotificationPermissionInfoBarDelegate::Cancel() { // static void DesktopNotificationService::RegisterUserPrefs( user_prefs::PrefRegistrySyncable* registry) { -#if defined(OS_CHROMEOS) || defined(ENABLE_MESSAGE_CENTER) registry->RegisterListPref(prefs::kMessageCenterDisabledExtensionIds, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterListPref(prefs::kMessageCenterDisabledSystemComponentIds, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); -#endif } // static @@ -307,7 +297,7 @@ std::string DesktopNotificationService::AddNotification( const string16& replace_id, NotificationDelegate* delegate, Profile* profile) { - if (UsesTextNotifications()) { + if (message_center::IsRichNotificationEnabled()) { // For message center create a non-HTML notification with |icon_url|. Notification notification(origin_url, icon_url, title, message, WebKit::WebTextDirectionDefault, @@ -335,7 +325,7 @@ std::string DesktopNotificationService::AddIconNotification( NotificationDelegate* delegate, Profile* profile) { - if (UsesTextNotifications()) { + if (message_center::IsRichNotificationEnabled()) { // For message center create a non-HTML notification with |icon|. Notification notification(origin_url, icon, title, message, WebKit::WebTextDirectionDefault, @@ -362,7 +352,6 @@ DesktopNotificationService::DesktopNotificationService( NotificationUIManager* ui_manager) : profile_(profile), ui_manager_(ui_manager) { -#if defined(ENABLE_MESSAGE_CENTER) OnDisabledExtensionIdsChanged(); OnDisabledSystemComponentIdsChanged(); disabled_extension_id_pref_.Init( @@ -377,13 +366,9 @@ DesktopNotificationService::DesktopNotificationService( base::Bind( &DesktopNotificationService::OnDisabledSystemComponentIdsChanged, base::Unretained(this))); -#endif } DesktopNotificationService::~DesktopNotificationService() { -#if defined(ENABLE_MESSAGE_CENTER) - disabled_extension_id_pref_.Destroy(); -#endif } void DesktopNotificationService::GrantPermission(const GURL& origin) { @@ -592,7 +577,6 @@ void DesktopNotificationService::OnDisabledExtensionIdsChanged() { &disabled_extension_ids_); } -#if defined(ENABLE_MESSAGE_CENTER) bool DesktopNotificationService::IsSystemComponentEnabled( message_center::Notifier::SystemComponentNotifierType type) { return disabled_system_component_ids_.find(message_center::ToString(type)) == @@ -616,7 +600,6 @@ void DesktopNotificationService::OnDisabledSystemComponentIdsChanged() { prefs::kMessageCenterDisabledSystemComponentIds, &disabled_system_component_ids_); } -#endif WebKit::WebNotificationPresenter::Permission DesktopNotificationService::HasPermission(const GURL& origin) { diff --git a/chrome/browser/notifications/desktop_notifications_unittest.cc b/chrome/browser/notifications/desktop_notifications_unittest.cc index 50caecc..dbf7e1c 100644 --- a/chrome/browser/notifications/desktop_notifications_unittest.cc +++ b/chrome/browser/notifications/desktop_notifications_unittest.cc @@ -15,10 +15,7 @@ #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.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" @@ -116,11 +113,9 @@ void DesktopNotificationsTest::SetUp() { WebKit::initialize(webkit_platform_support_.Get()); ui::ScopedAnimationDurationScaleMode normal_duration_mode( ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); -#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); @@ -143,11 +138,9 @@ 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/browser/notifications/message_center_notifications_browsertest.cc b/chrome/browser/notifications/message_center_notifications_browsertest.cc index 556eb5a..71cc0a6 100644 --- a/chrome/browser/notifications/message_center_notifications_browsertest.cc +++ b/chrome/browser/notifications/message_center_notifications_browsertest.cc @@ -16,10 +16,8 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "ui/message_center/message_center.h" - -#if defined(ENABLE_MESSAGE_CENTER) #include "ui/message_center/message_center_switches.h" -#endif +#include "ui/message_center/message_center_util.h" class MessageCenterNotificationsTest : public InProcessBrowserTest { public: @@ -98,19 +96,36 @@ class MessageCenterNotificationsTest : public InProcessBrowserTest { IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) { // Make sure comamnd-line switch has an effect. - EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); + EXPECT_EQ(NotificationUIManager::DelegatesToMessageCenter(), + message_center::IsRichNotificationEnabled()); EXPECT_TRUE(manager()); EXPECT_TRUE(message_center()); } -IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicAddCancel) { +// MessaceCenter-specific test. +#if defined(RUN_MESSAGE_CENTER_TESTS) +#define MAYBE_BasicAddCancel BasicAddCancel +#else +#define MAYBE_BasicAddCancel DISABLED_BasicAddCancel +#endif + +IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, MAYBE_BasicAddCancel) { + EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); manager()->Add(CreateTestNotification("hey"), profile()); EXPECT_EQ(1u, message_center()->NotificationCount()); manager()->CancelById("hey"); EXPECT_EQ(0u, message_center()->NotificationCount()); } -IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicDelegate) { +// MessaceCenter-specific test. +#if defined(RUN_MESSAGE_CENTER_TESTS) +#define MAYBE_BasicDelegate BasicDelegate +#else +#define MAYBE_BasicDelegate DISABLED_BasicDelegate +#endif + +IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, MAYBE_BasicDelegate) { + EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); TestDelegate* delegate; manager()->Add(CreateTestNotification("hey", &delegate), profile()); // Verify that delegate accumulated correct log of events. @@ -121,7 +136,16 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicDelegate) { delegate->Release(); } -IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, ButtonClickedDelegate) { +// MessaceCenter-specific test. +#if defined(RUN_MESSAGE_CENTER_TESTS) +#define MAYBE_ButtonClickedDelegate ButtonClickedDelegate +#else +#define MAYBE_ButtonClickedDelegate DISABLED_ButtonClickedDelegate +#endif + +IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, + MAYBE_ButtonClickedDelegate) { + EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); TestDelegate* delegate; manager()->Add(CreateTestNotification("n", &delegate), profile()); message_center()->ClickOnNotificationButton("n", 1); diff --git a/chrome/browser/notifications/notification.cc b/chrome/browser/notifications/notification.cc index 1077b04..b45bf1e 100644 --- a/chrome/browser/notifications/notification.cc +++ b/chrome/browser/notifications/notification.cc @@ -127,9 +127,7 @@ Notification& Notification::operator=(const Notification& notification) { } void Notification::DisableTimeout() { -#if defined(ENABLE_MESSAGE_CENTER) if (!optional_fields_.get()) optional_fields_.reset(new base::DictionaryValue()); optional_fields_->SetBoolean(message_center::kPrivateNeverTimeoutKey, true); -#endif } diff --git a/chrome/browser/notifications/notification_browsertest.cc b/chrome/browser/notifications/notification_browsertest.cc index f524d34..4a317965 100644 --- a/chrome/browser/notifications/notification_browsertest.cc +++ b/chrome/browser/notifications/notification_browsertest.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/callback.h" +#include "base/command_line.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/run_loop.h" @@ -44,25 +45,14 @@ #include "net/test/spawned_test_server/spawned_test_server.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/window_open_disposition.h" - -// TODO(kbr): remove: http://crbug.com/222296 -#if defined(OS_MACOSX) -#import "base/mac/mac_util.h" -#endif - -#if defined(ENABLE_MESSAGE_CENTER) -#include "base/command_line.h" #include "ui/message_center/message_center.h" #include "ui/message_center/message_center_observer.h" #include "ui/message_center/message_center_switches.h" -#endif +#include "ui/message_center/message_center_util.h" -// Mac implementation of message_center is incomplete. The code builds, but -// the tests do not pass <http://crbug.com/179904>. -#if defined(ENABLE_MESSAGE_CENTER) && !defined(OS_MACOSX) -#define ENABLE_MESSAGE_CENTER_TESTING 1 -#else -#define ENABLE_MESSAGE_CENTER_TESTING 0 +// TODO(kbr): remove: http://crbug.com/222296 +#if defined(OS_MACOSX) +#import "base/mac/mac_util.h" #endif namespace { @@ -75,9 +65,15 @@ enum InfobarAction { DENY, }; -#if ENABLE_MESSAGE_CENTER_TESTING +class NotificationChangeObserver { +public: + virtual ~NotificationChangeObserver() {} + virtual bool Wait() = 0; +}; + class MessageCenterChangeObserver - : public message_center::MessageCenterObserver { + : public message_center::MessageCenterObserver, + public NotificationChangeObserver { public: MessageCenterChangeObserver() : notification_received_(false) { @@ -88,7 +84,8 @@ class MessageCenterChangeObserver message_center::MessageCenter::Get()->RemoveObserver(this); } - bool Wait() { + // NotificationChangeObserver: + virtual bool Wait() OVERRIDE { if (notification_received_) return true; @@ -97,15 +94,17 @@ class MessageCenterChangeObserver return notification_received_; } - // overridden from message_center::MessageCenterObserver: + // message_center::MessageCenterObserver: virtual void OnNotificationAdded( const std::string& notification_id) OVERRIDE { OnMessageCenterChanged(); } + virtual void OnNotificationRemoved(const std::string& notification_id, bool by_user) OVERRIDE { OnMessageCenterChanged(); } + virtual void OnNotificationUpdated( const std::string& notification_id) OVERRIDE { OnMessageCenterChanged(); @@ -123,11 +122,9 @@ class MessageCenterChangeObserver DISALLOW_COPY_AND_ASSIGN(MessageCenterChangeObserver); }; -typedef MessageCenterChangeObserver NotificationChangeObserver; - -#else - -class NotificationBalloonChangeObserver : public content::NotificationObserver { +class NotificationBalloonChangeObserver + : public content::NotificationObserver, + public NotificationChangeObserver { public: NotificationBalloonChangeObserver() : collection_(BalloonNotificationUIManager::GetInstanceForTesting()-> @@ -149,7 +146,8 @@ class NotificationBalloonChangeObserver : public content::NotificationObserver { collection_->set_on_collection_changed_callback(base::Closure()); } - bool Wait() { + // NotificationChangeObserver: + virtual bool Wait() OVERRIDE { if (!Check()) { running_ = true; message_loop_runner_ = new content::MessageLoopRunner; @@ -178,7 +176,7 @@ class NotificationBalloonChangeObserver : public content::NotificationObserver { Check(); } - // Overridden from content::NotificationObserver: + // content::NotificationObserver: virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE { @@ -201,10 +199,6 @@ class NotificationBalloonChangeObserver : public content::NotificationObserver { DISALLOW_COPY_AND_ASSIGN(NotificationBalloonChangeObserver); }; -typedef NotificationBalloonChangeObserver NotificationChangeObserver; - -#endif // ENABLE_MESSAGE_CENTER - } // namespace class NotificationsTest : public InProcessBrowserTest { @@ -217,15 +211,13 @@ class NotificationsTest : public InProcessBrowserTest { int GetNotificationCount(); + NotificationChangeObserver* CreateObserver(); + void CloseBrowserWindow(Browser* browser); void CrashTab(Browser* browser, int index); -#if ENABLE_MESSAGE_CENTER_TESTING - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; -#else const std::deque<Balloon*>& GetActiveBalloons(); void CrashNotification(Balloon* balloon); bool CloseNotificationAndWait(const Notification& notification); -#endif void SetDefaultPermissionSetting(ContentSetting setting); void DenyOrigin(const GURL& origin); @@ -270,12 +262,19 @@ void NotificationsTest::SetUpInProcessBrowserTestFixture() { } int NotificationsTest::GetNotificationCount() { -#if ENABLE_MESSAGE_CENTER_TESTING - return message_center::MessageCenter::Get()->NotificationCount(); -#else - return BalloonNotificationUIManager::GetInstanceForTesting()-> - balloon_collection()->GetActiveBalloons().size(); -#endif // ENABLE_MESSAGE_CENTER_TESTING + if (message_center::IsRichNotificationEnabled()) { + return message_center::MessageCenter::Get()->NotificationCount(); + } else { + return BalloonNotificationUIManager::GetInstanceForTesting()-> + balloon_collection()->GetActiveBalloons().size(); + } +} + +NotificationChangeObserver* NotificationsTest::CreateObserver() { + if (message_center::IsRichNotificationEnabled()) + return new MessageCenterChangeObserver(); + else + return new NotificationBalloonChangeObserver(); } void NotificationsTest::CloseBrowserWindow(Browser* browser) { @@ -290,15 +289,6 @@ void NotificationsTest::CrashTab(Browser* browser, int index) { content::CrashTab(browser->tab_strip_model()->GetWebContentsAt(index)); } -#if ENABLE_MESSAGE_CENTER_TESTING -// Overriden from InProcessBrowserTest: -void NotificationsTest::SetUpCommandLine(CommandLine* command_line) { - InProcessBrowserTest::SetUpCommandLine(command_line); - command_line->AppendSwitch( - message_center::switches::kEnableRichNotifications); -} -#else - const std::deque<Balloon*>& NotificationsTest::GetActiveBalloons() { return BalloonNotificationUIManager::GetInstanceForTesting()-> balloon_collection()->GetActiveBalloons(); @@ -310,16 +300,14 @@ void NotificationsTest::CrashNotification(Balloon* balloon) { bool NotificationsTest::CloseNotificationAndWait( const Notification& notification) { - NotificationChangeObserver observer; + scoped_ptr<NotificationChangeObserver> observer(CreateObserver()); bool success = g_browser_process->notification_ui_manager()-> CancelById(notification.notification_id()); if (success) - return observer.Wait(); + return observer->Wait(); return false; } -#endif // !ENABLE_MESSAGE_CENTER_TESTING - void NotificationsTest::SetDefaultPermissionSetting(ContentSetting setting) { DesktopNotificationService* service = GetDesktopNotificationService(); service->SetDefaultContentSetting(setting); @@ -365,14 +353,14 @@ std::string NotificationsTest::CreateNotification( "createNotification('%s', '%s', '%s', '%s');", icon, title, body, replace_id); - NotificationChangeObserver observer; + scoped_ptr<NotificationChangeObserver> observer(CreateObserver()); std::string result; bool success = content::ExecuteScriptAndExtractString( browser->tab_strip_model()->GetActiveWebContents(), script, &result); if (success && result != "-1" && wait_for_new_balloon) - success = observer.Wait(); + success = observer->Wait(); EXPECT_TRUE(success); return result; @@ -410,7 +398,7 @@ bool NotificationsTest::CancelNotification( "cancelNotification('%s');", notification_id); - NotificationChangeObserver observer; + scoped_ptr<NotificationChangeObserver> observer(CreateObserver()); std::string result; bool success = content::ExecuteScriptAndExtractString( browser->tab_strip_model()->GetActiveWebContents(), @@ -418,7 +406,7 @@ bool NotificationsTest::CancelNotification( &result); if (!success || result != "1") return false; - return observer.Wait(); + return observer->Wait(); } bool NotificationsTest::PerformActionOnInfobar( @@ -542,20 +530,20 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCreateSimpleNotification) { GURL EXPECTED_ICON_URL = test_server()->GetURL(kExpectedIconUrl); ASSERT_EQ(1, GetNotificationCount()); -#if ENABLE_MESSAGE_CENTER_TESTING - message_center::NotificationList::Notifications notifications = - message_center::MessageCenter::Get()->GetNotifications(); - EXPECT_EQ(ASCIIToUTF16("My Title"), (*notifications.rbegin())->title()); - EXPECT_EQ(ASCIIToUTF16("My Body"), (*notifications.rbegin())->message()); -#else - const std::deque<Balloon*>& balloons = GetActiveBalloons(); - ASSERT_EQ(1U, balloons.size()); - Balloon* balloon = balloons[0]; - const Notification& notification = balloon->notification(); - EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); - EXPECT_EQ(ASCIIToUTF16("My Title"), notification.title()); - EXPECT_EQ(ASCIIToUTF16("My Body"), notification.body()); -#endif + if (message_center::IsRichNotificationEnabled()) { + message_center::NotificationList::Notifications notifications = + message_center::MessageCenter::Get()->GetNotifications(); + EXPECT_EQ(ASCIIToUTF16("My Title"), (*notifications.rbegin())->title()); + EXPECT_EQ(ASCIIToUTF16("My Body"), (*notifications.rbegin())->message()); + } else { + const std::deque<Balloon*>& balloons = GetActiveBalloons(); + ASSERT_EQ(1U, balloons.size()); + Balloon* balloon = balloons[0]; + const Notification& notification = balloon->notification(); + EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); + EXPECT_EQ(ASCIIToUTF16("My Title"), notification.title()); + EXPECT_EQ(ASCIIToUTF16("My Body"), notification.body()); + } } IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCloseNotification) { @@ -573,16 +561,16 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCloseNotification) { EXPECT_NE("-1", result); ASSERT_EQ(1, GetNotificationCount()); -#if ENABLE_MESSAGE_CENTER_TESTING - message_center::NotificationList::Notifications notifications = - message_center::MessageCenter::Get()->GetNotifications(); - message_center::MessageCenter::Get()->RemoveNotification( - (*notifications.rbegin())->id(), - true); // by_user -#else - const std::deque<Balloon*>& balloons = GetActiveBalloons(); - EXPECT_TRUE(CloseNotificationAndWait(balloons[0]->notification())); -#endif // ENABLE_MESSAGE_CENTER_TESTING + if (message_center::IsRichNotificationEnabled()) { + message_center::NotificationList::Notifications notifications = + message_center::MessageCenter::Get()->GetNotifications(); + message_center::MessageCenter::Get()->RemoveNotification( + (*notifications.rbegin())->id(), + true); // by_user + } else { + const std::deque<Balloon*>& balloons = GetActiveBalloons(); + EXPECT_TRUE(CloseNotificationAndWait(balloons[0]->notification())); + } ASSERT_EQ(0, GetNotificationCount()); } @@ -765,16 +753,16 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCreateDenyCloseNotifications) { ASSERT_TRUE(CheckOriginInSetting(settings, test_page_url_.GetOrigin())); EXPECT_EQ(1, GetNotificationCount()); -#if ENABLE_MESSAGE_CENTER_TESTING - message_center::NotificationList::Notifications notifications = - message_center::MessageCenter::Get()->GetNotifications(); - message_center::MessageCenter::Get()->RemoveNotification( - (*notifications.rbegin())->id(), - true); // by_user -#else - const std::deque<Balloon*>& balloons = GetActiveBalloons(); - ASSERT_TRUE(CloseNotificationAndWait(balloons[0]->notification())); -#endif // ENABLE_MESSAGE_CENTER_TESTING + if (message_center::IsRichNotificationEnabled()) { + message_center::NotificationList::Notifications notifications = + message_center::MessageCenter::Get()->GetNotifications(); + message_center::MessageCenter::Get()->RemoveNotification( + (*notifications.rbegin())->id(), + true); // by_user + } else { + const std::deque<Balloon*>& balloons = GetActiveBalloons(); + ASSERT_TRUE(CloseNotificationAndWait(balloons[0]->notification())); + } ASSERT_EQ(0, GetNotificationCount()); } @@ -836,9 +824,11 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, CrashTab(browser(), 0); } -// Notifications don't have their own process with the message center. -#if !ENABLE_MESSAGE_CENTER_TESTING IN_PROC_BROWSER_TEST_F(NotificationsTest, TestKillNotificationProcess) { + // Notifications don't have their own process with the message center. + if (message_center::IsRichNotificationEnabled()) + return; + #if defined(OS_MACOSX) // TODO(kbr): re-enable: http://crbug.com/222296 if (base::mac::IsOSMountainLionOrLater()) @@ -855,7 +845,6 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestKillNotificationProcess) { CrashNotification(balloons[0]); ASSERT_EQ(0, GetNotificationCount()); } -#endif IN_PROC_BROWSER_TEST_F(NotificationsTest, TestIncognitoNotification) { #if defined(OS_MACOSX) @@ -958,20 +947,20 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNotificationReplacement) { browser(), false, "no_such_file.png", "Title2", "Body2", "chat"); EXPECT_NE("-1", result); -#if ENABLE_MESSAGE_CENTER_TESTING - ASSERT_EQ(1, GetNotificationCount()); - message_center::NotificationList::Notifications notifications = - message_center::MessageCenter::Get()->GetNotifications(); - EXPECT_EQ(ASCIIToUTF16("Title2"), (*notifications.rbegin())->title()); - EXPECT_EQ(ASCIIToUTF16("Body2"), (*notifications.rbegin())->message()); -#else - const std::deque<Balloon*>& balloons = GetActiveBalloons(); - ASSERT_EQ(1U, balloons.size()); - Balloon* balloon = balloons[0]; - const Notification& notification = balloon->notification(); - GURL EXPECTED_ICON_URL = test_server()->GetURL(kExpectedIconUrl); - EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); - EXPECT_EQ(ASCIIToUTF16("Title2"), notification.title()); - EXPECT_EQ(ASCIIToUTF16("Body2"), notification.body()); -#endif + if (message_center::IsRichNotificationEnabled()) { + ASSERT_EQ(1, GetNotificationCount()); + message_center::NotificationList::Notifications notifications = + message_center::MessageCenter::Get()->GetNotifications(); + EXPECT_EQ(ASCIIToUTF16("Title2"), (*notifications.rbegin())->title()); + EXPECT_EQ(ASCIIToUTF16("Body2"), (*notifications.rbegin())->message()); + } else { + const std::deque<Balloon*>& balloons = GetActiveBalloons(); + ASSERT_EQ(1U, balloons.size()); + Balloon* balloon = balloons[0]; + const Notification& notification = balloon->notification(); + GURL EXPECTED_ICON_URL = test_server()->GetURL(kExpectedIconUrl); + EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); + EXPECT_EQ(ASCIIToUTF16("Title2"), notification.title()); + EXPECT_EQ(ASCIIToUTF16("Body2"), notification.body()); + } } diff --git a/chrome/browser/notifications/notification_ui_manager.cc b/chrome/browser/notifications/notification_ui_manager.cc index a562557..1b1d62dc 100644 --- a/chrome/browser/notifications/notification_ui_manager.cc +++ b/chrome/browser/notifications/notification_ui_manager.cc @@ -4,13 +4,10 @@ #include "chrome/browser/notifications/notification_ui_manager.h" -#include "chrome/browser/notifications/balloon_notification_ui_manager.h" - -#if defined(ENABLE_MESSAGE_CENTER) #include "chrome/browser/browser_process.h" +#include "chrome/browser/notifications/balloon_notification_ui_manager.h" #include "chrome/browser/notifications/message_center_notification_manager.h" #include "ui/message_center/message_center_util.h" -#endif // static bool NotificationUIManager::DelegatesToMessageCenter() { @@ -19,20 +16,17 @@ bool NotificationUIManager::DelegatesToMessageCenter() { // the message center. #if defined(OS_CHROMEOS) return true; -#elif defined(ENABLE_MESSAGE_CENTER) - return message_center::IsRichNotificationEnabled(); #endif - return false; + return message_center::IsRichNotificationEnabled(); } #if !defined(OS_MACOSX) // static NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { -#if defined(ENABLE_MESSAGE_CENTER) if (DelegatesToMessageCenter()) return new MessageCenterNotificationManager( g_browser_process->message_center()); -#endif + BalloonNotificationUIManager* balloon_manager = new BalloonNotificationUIManager(local_state); balloon_manager->SetBalloonCollection(BalloonCollection::Create()); diff --git a/chrome/browser/notifications/notification_ui_manager_mac.mm b/chrome/browser/notifications/notification_ui_manager_mac.mm index 7e1af00..59339ed 100644 --- a/chrome/browser/notifications/notification_ui_manager_mac.mm +++ b/chrome/browser/notifications/notification_ui_manager_mac.mm @@ -7,14 +7,11 @@ #include "base/mac/cocoa_protocols.h" #include "base/mac/mac_util.h" #include "base/strings/sys_string_conversions.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/balloon_notification_ui_manager.h" - -#if defined(ENABLE_MESSAGE_CENTER) -#include "chrome/browser/browser_process.h" #include "chrome/browser/notifications/message_center_notification_manager.h" #include "ui/message_center/message_center_util.h" -#endif @class NSUserNotificationCenter; @@ -100,14 +97,12 @@ NotificationUIManagerMac::ControllerNotification::~ControllerNotification() { // static NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { -#if defined(ENABLE_MESSAGE_CENTER) // TODO(rsesek): Remove this function and merge it with the one in // notification_ui_manager.cc. if (DelegatesToMessageCenter()) { return new MessageCenterNotificationManager( g_browser_process->message_center()); } -#endif BalloonNotificationUIManager* balloon_manager = NULL; if (base::mac::IsOSMountainLionOrLater()) diff --git a/chrome/browser/notifications/sync_notifier/chrome_notifier_service_unittest.cc b/chrome/browser/notifications/sync_notifier/chrome_notifier_service_unittest.cc index bb7182b..0fee623 100644 --- a/chrome/browser/notifications/sync_notifier/chrome_notifier_service_unittest.cc +++ b/chrome/browser/notifications/sync_notifier/chrome_notifier_service_unittest.cc @@ -18,6 +18,7 @@ #include "sync/protocol/sync.pb.h" #include "sync/protocol/synced_notification_specifics.pb.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/message_center/message_center_util.h" using sync_pb::SyncedNotificationSpecifics; using sync_pb::EntitySpecifics; @@ -94,12 +95,8 @@ const char kContainedMessage3[] = "Let's play starcraft tonight on the LAN."; const int64 kFakeCreationTime = 42; const int kProtobufPriority = static_cast<int>( sync_pb::CoalescedSyncedNotification_Priority_LOW); -#if defined (ENABLE_MESSAGE_CENTER) const int kNotificationPriority = static_cast<int>( message_center::LOW_PRIORITY); -#else // ENABLE_MESSAGE_CENTER -const int kNotificationPriority = 1; -#endif // ENABLE_MESSAGE_CENTER const sync_pb::CoalescedSyncedNotification_ReadState kDismissed = sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED; const sync_pb::CoalescedSyncedNotification_ReadState kUnread = diff --git a/chrome/browser/notifications/sync_notifier/synced_notification.cc b/chrome/browser/notifications/sync_notifier/synced_notification.cc index 23883b2..813846d 100644 --- a/chrome/browser/notifications/sync_notifier/synced_notification.cc +++ b/chrome/browser/notifications/sync_notifier/synced_notification.cc @@ -13,20 +13,14 @@ #include "chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.h" #include "sync/protocol/sync.pb.h" #include "sync/protocol/synced_notification_specifics.pb.h" -#if defined(ENABLE_MESSAGE_CENTER) #include "ui/message_center/message_center_util.h" #include "ui/message_center/notification_types.h" -#endif // ENABLE_MESSAGE_CENTER namespace { const char kExtensionScheme[] = "chrome-extension://"; bool UseRichNotifications() { -#if defined(ENABLE_MESSAGE_CENTER) return message_center::IsRichNotificationEnabled(); -#else // ENABLE_MESSAGE_CENTER - return false; -#endif // ENABLE_MESSAGE_CENTER } } // namespace @@ -90,8 +84,6 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager, // Some inputs and fields are only used if there is a notification center. if (UseRichNotifications()) { - -#if defined(ENABLE_MESSAGE_CENTER) double creation_time = static_cast<double>(GetCreationTime()); int priority = GetPriority(); int notification_count = GetNotificationCount(); @@ -162,8 +154,6 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager, delegate); notification_manager->Add(ui_notification, profile); -#endif // ENABLE_MESSAGE_CENTER - } else { Notification ui_notification(GetOriginUrl(), @@ -339,7 +329,6 @@ int SyncedNotification::GetPriority() const { return kUndefinedPriority; int protobuf_priority = specifics_.coalesced_notification().priority(); -#if defined(ENABLE_MESSAGE_CENTER) // Convert the prioroty to the scheme used by the notification center. if (protobuf_priority == sync_pb::CoalescedSyncedNotification_Priority_LOW) { @@ -358,11 +347,6 @@ int SyncedNotification::GetPriority() const { protobuf_priority); return kUndefinedPriority; } - -#else // ENABLE_MESSAGE_CENTER - return protobuf_priority; - -#endif // ENABLE_MESSAGE_CENTER } int SyncedNotification::GetNotificationCount() const { diff --git a/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc b/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc index 3ccd4c2..87810cc 100644 --- a/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc +++ b/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc @@ -13,10 +13,8 @@ #include "sync/protocol/sync.pb.h" #include "sync/protocol/synced_notification_specifics.pb.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(ENABLE_MESSAGE_CENTER) #include "ui/message_center/message_center_util.h" #include "ui/message_center/notification_types.h" -#endif // ENABLE_MESSAGE_CENTER using syncer::SyncData; using notifier::SyncedNotification; @@ -28,19 +26,11 @@ namespace { const uint64 kFakeCreationTime = 42; const int kProtobufPriority = static_cast<int>( sync_pb::CoalescedSyncedNotification_Priority_LOW); -#if defined (ENABLE_MESSAGE_CENTER) const int kNotificationPriority = static_cast<int>( message_center::LOW_PRIORITY); -#else // ENABLE_MESSAGE_CENTER -const int kNotificationPriority = 1; -#endif // ENABLE_MESSAGE_CENTER bool UseRichNotifications() { -#if defined(ENABLE_MESSAGE_CENTER) return message_center::IsRichNotificationEnabled(); -#else // ENABLE_MESSAGE_CENTER - return false; -#endif // ENABLE_MESSAGE_CENTER } const char kTitle1[] = "New appointment at 2:15"; @@ -572,8 +562,6 @@ TEST_F(SyncedNotificationTest, ShowTest) { if (!UseRichNotifications()) return; -#if defined(ENABLE_MESSAGE_CENTER) - StubNotificationUIManager notification_manager; // Call the method under test using the pre-populated data. @@ -635,8 +623,6 @@ TEST_F(SyncedNotificationTest, ShowTest) { << "Expected: " << expected_fields << ", but actual: " << *actual_fields; -#endif // ENABLE_MESSAGE_CENTER - } // TODO(petewil): Add a test for a notification being read and or deleted. diff --git a/chrome/browser/task_manager/task_manager_notification_browsertest.cc b/chrome/browser/task_manager/task_manager_notification_browsertest.cc index 73f9657..eb51693 100644 --- a/chrome/browser/task_manager/task_manager_notification_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_notification_browsertest.cc @@ -19,10 +19,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "content/public/common/content_switches.h" #include "testing/gtest/include/gtest/gtest.h" - -#if !defined(ENABLE_MESSAGE_CENTER) -// These tests do not apply with Message Center platforms -// where notifications do not instantiate a new renderer. +#include "ui/message_center/message_center_util.h" class TaskManagerNotificationBrowserTest : public ExtensionBrowserTest { public: @@ -48,6 +45,11 @@ class TaskManagerNotificationBrowserTest : public ExtensionBrowserTest { #endif IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, MAYBE_NoticeNotificationChanges) { + // These tests do not apply with Message Center platforms + // where notifications do not instantiate a new renderer. + if (message_center::IsRichNotificationEnabled()) + return; + EXPECT_EQ(0, model()->ResourceCount()); // Show the task manager. @@ -79,5 +81,3 @@ IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, notifications->CancelById(n2.notification_id()); TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } - -#endif // !ENABLE_MESSAGE_CENTER diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d2ad692..5826a97 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -54,6 +54,7 @@ '../third_party/zlib/zlib.gyp:minizip', '../third_party/zlib/zlib.gyp:zlib', '../ui/base/strings/ui_strings.gyp:ui_strings', + '../ui/message_center/message_center.gyp:message_center', '../ui/ui.gyp:shell_dialogs', '../ui/ui.gyp:ui', '../ui/ui.gyp:ui_resources', @@ -3003,18 +3004,6 @@ '../ui/app_list/app_list.gyp:app_list', ] }], - ['enable_message_center==1', { - 'dependencies': [ - '../ui/message_center/message_center.gyp:message_center', - ], - }, { # enable_message_center==0 - 'sources!': [ - 'browser/notifications/message_center_notification_manager.cc', - 'browser/notifications/message_center_notification_manager.h', - 'browser/notifications/message_center_settings_controller.cc', - 'browser/notifications/message_center_settings_controller.h', - ], - }], ['enable_managed_users!=1', { 'sources/': [ ['exclude', '^browser/managed_mode/'], diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 5824a10..219e1e9 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -48,6 +48,7 @@ '../third_party/libxml/libxml.gyp:libxml', '../third_party/zlib/zlib.gyp:zlib', '../ui/base/strings/ui_strings.gyp:ui_strings', + '../ui/message_center/message_center.gyp:message_center', '../ui/native_theme/native_theme.gyp:native_theme', '../ui/snapshot/snapshot.gyp:snapshot', '../ui/ui.gyp:ui', @@ -2933,11 +2934,6 @@ ['include', '^browser/ui/app_list/app_list_service_disabled.cc'], ], }], - ['enable_message_center==1', { - 'dependencies': [ - '../ui/message_center/message_center.gyp:message_center', - ], - }], ], }, ], diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 11c3267..23a96cd 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -478,11 +478,6 @@ 'browser/ui/views/native_widget_win_interactive_uitest.cc', ], }], # OS != "win" - ['enable_message_center==0', { - 'sources!': [ - 'browser/ui/views/message_center/web_notification_tray_win_browsertest.cc', - ], - }], # enable_message_center ], # conditions }, { @@ -2036,11 +2031,6 @@ ['exclude', '^browser/ui/app_list/'], ], }], - ['enable_message_center==0', { - 'sources!': [ - 'browser/notifications/message_center_notifications_browsertest.cc', - ], - }], ['enable_plugins==1', { 'dependencies': [ # Runtime dependency. diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc index 9418006..f40d38c 100644 --- a/chrome/test/base/testing_browser_process.cc +++ b/chrome/test/base/testing_browser_process.cc @@ -13,6 +13,7 @@ #include "content/public/browser/notification_service.h" #include "net/url_request/url_request_context_getter.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/message_center/message_center.h" #if !defined(OS_IOS) #include "chrome/browser/media_galleries/media_file_system_registry.h" @@ -36,10 +37,6 @@ #include "chrome/browser/policy/policy_service_stub.h" #endif // defined(ENABLE_CONFIGURATION_POLICY) -#if defined(ENABLE_MESSAGE_CENTER) -#include "ui/message_center/message_center.h" -#endif - // static TestingBrowserProcess* TestingBrowserProcess::GetGlobal() { return static_cast<TestingBrowserProcess*>(g_browser_process); @@ -200,11 +197,9 @@ NotificationUIManager* TestingBrowserProcess::notification_ui_manager() { #endif } -#if defined(ENABLE_MESSAGE_CENTER) message_center::MessageCenter* TestingBrowserProcess::message_center() { return message_center::MessageCenter::Get(); } -#endif IntranetRedirectDetector* TestingBrowserProcess::intranet_redirect_detector() { return NULL; diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h index f5e589e..cc501fc 100644 --- a/chrome/test/base/testing_browser_process.h +++ b/chrome/test/base/testing_browser_process.h @@ -71,9 +71,7 @@ class TestingBrowserProcess : public BrowserProcess { virtual extensions::EventRouterForwarder* extension_event_router_forwarder() OVERRIDE; virtual NotificationUIManager* notification_ui_manager() OVERRIDE; -#if defined(ENABLE_MESSAGE_CENTER) virtual message_center::MessageCenter* message_center() OVERRIDE; -#endif virtual IntranetRedirectDetector* intranet_redirect_detector() OVERRIDE; virtual AutomationProviderList* GetAutomationProviderList() OVERRIDE; virtual void CreateDevToolsHttpProtocolHandler( diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc index d3d9c43..a23a9ca 100644 --- a/chrome/test/base/view_event_test_base.cc +++ b/chrome/test/base/view_event_test_base.cc @@ -14,14 +14,11 @@ #include "content/public/browser/browser_thread.h" #include "ui/base/ime/text_input_test_support.h" #include "ui/compositor/test/compositor_test_support.h" +#include "ui/message_center/message_center.h" #include "ui/views/view.h" #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" @@ -112,11 +109,9 @@ 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 #if defined(OS_CHROMEOS) chromeos::CrasAudioHandler::InitializeForTesting(); #endif @@ -154,11 +149,9 @@ void ViewEventTestBase::TearDown() { #if defined(OS_CHROMEOS) chromeos::CrasAudioHandler::Shutdown(); #endif -#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) diff --git a/ui/message_center/dummy_message_center.cc b/ui/message_center/dummy_message_center.cc new file mode 100644 index 0000000..27ecc91 --- /dev/null +++ b/ui/message_center/dummy_message_center.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/message_center/message_center.h" +#include "ui/message_center/message_center_switches.h" +#include "ui/message_center/message_center_util.h" + +// This file contains dummy implementation of MessageCenter and used to compile +// and link with Android and iOS implementations of Chrome which do not have +// notification systems yet. This is to avoid spreading compile-time flags +// everywhere in the code. +#if !defined(OS_ANDROID) && !defined(OS_IOS) +#error This file should only be used in Android or iOS builds. +#endif + +namespace message_center { + +bool IsRichNotificationEnabled() { + return false; +} + +// static +void MessageCenter::Initialize() { +} + +// static +MessageCenter* MessageCenter::Get() { + return NULL; +} + +// static +void MessageCenter::Shutdown() { +} + +MessageCenter::MessageCenter() { +} + +MessageCenter::~MessageCenter() { +} + +MessageCenter::Delegate::~Delegate() { +} + +} // namespace message_center diff --git a/ui/message_center/message_center.gyp b/ui/message_center/message_center.gyp index 2b84ad8..ebf18e9 100644 --- a/ui/message_center/message_center.gyp +++ b/ui/message_center/message_center.gyp @@ -17,7 +17,6 @@ '../../build/temp_gyp/googleurl.gyp:googleurl', '../../skia/skia.gyp:skia', '../base/strings/ui_strings.gyp:ui_strings', - '../compositor/compositor.gyp:compositor', '../ui.gyp:ui', '../ui.gyp:ui_resources', ], @@ -31,6 +30,7 @@ 'cocoa/popup_collection.mm', 'cocoa/popup_controller.h', 'cocoa/popup_controller.mm', + 'dummy_message_center.cc', 'message_center.cc', 'message_center.h', 'message_center_constants.cc', @@ -97,6 +97,21 @@ '../../third_party/GTM', ], }], + ['OS!="ios"', { + 'dependencies': [ + '../compositor/compositor.gyp:compositor', + ], + }], + ['notifications==0', { # Android and iOS. + 'sources/': [ + # Exclude everything except dummy impl. + ['exclude', '\\.(cc|mm)$'], + ['include', '^dummy_message_center\\.cc$'], + ['include', '^message_center_switches\\.cc$'], + ], + }, { # notifications==1 + 'sources!': [ 'dummy_message_center.cc' ], + }], ], }, # target_name: message_center { @@ -142,6 +157,13 @@ 'views/message_popup_collection_unittest.cc', ], }], + ['notifications==0', { # Android and iOS. + 'sources/': [ + # Exclude everything except main(). + ['exclude', '\\.(cc|mm)$'], + ['include', '^test/run_all_unittests\\.cc$'], + ], + }], ], }, # target_name: message_center_unittests ], diff --git a/ui/message_center/message_center_constants.cc b/ui/message_center/message_center_constants.cc index adfebfb..5eeb450 100644 --- a/ui/message_center/message_center_constants.cc +++ b/ui/message_center/message_center_constants.cc @@ -11,7 +11,8 @@ namespace message_center { // Square image sizes in pixels. const int kNotificationButtonIconSize = 16; const int kNotificationIconSize = 80; -const int kNotificationPreferredImageSize = kNotificationWidth; +// Same as kNotificationWidth. +const int kNotificationPreferredImageSize = 360; const int kSettingsIconSize = 16; // Limits. @@ -39,7 +40,8 @@ const SkColor kRegularTextColor = SkColorSetRGB(34, 34, 34); const SkColor kFocusBorderColor = SkColorSetRGB(64, 128, 250); // Limits. -const int kNotificationMaximumImageHeight = kNotificationWidth * 1.5; +// kNotificationWidth * 1.5 +const int kNotificationMaximumImageHeight = 540; const size_t kNotificationMaximumItems = 8; // Timing. diff --git a/ui/message_center/message_center_util.cc b/ui/message_center/message_center_util.cc index 916faa7..913cf0d 100644 --- a/ui/message_center/message_center_util.cc +++ b/ui/message_center/message_center_util.cc @@ -13,17 +13,23 @@ namespace message_center { // when a time period in Canary indicates the new notifications are acceptable // for default behavior. bool IsRichNotificationEnabled() { +#if !defined(OS_WIN) && !defined(OS_MACOSX) && !defined(USE_ASH) + return false; +#endif + if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableRichNotifications)) return false; if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableRichNotifications)) return true; + +// Not enabled by default on Mac yet. #if defined(OS_MACOSX) return false; -#else - return true; #endif + + return true; } } // namespace message_center diff --git a/ui/message_center/message_center_util.h b/ui/message_center/message_center_util.h index 512cb1a..e4b37aa 100644 --- a/ui/message_center/message_center_util.h +++ b/ui/message_center/message_center_util.h @@ -11,6 +11,12 @@ namespace message_center { MESSAGE_CENTER_EXPORT bool IsRichNotificationEnabled(); +// If Rich Notificaitons are enabled by default on a platform, run the +// corresponding tests on that platform. +#if defined(OS_WIN) || defined(USE_ASH) +#define RUN_MESSAGE_CENTER_TESTS 1 +#endif + } // namespace message_center #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_UTIL_H_ |