Revert 199625 "Remove ENABLE_MESSAGE_CENTER"
Caused a static initializer on Linux:
# message_center_constants.cc __i686.get_pc_thunk.cx
(Not on Mac though. The SkGetColor() macro has a comment about it not adding
a static initializer on release builds, so maybe it's the float-int-multiplication?
I don't have a linux box around to check, sorry.)
> 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
>
> Review URL: https://chromiumcodereview.appspot.com/15025002
[email protected]
Review URL: https://codereview.chromium.org/14631021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199639 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
index 502b43d..287aea96 100644
--- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
+++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
@@ -25,10 +25,13 @@
#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;
@@ -114,64 +117,91 @@
};
-class MAYBE_ExtensionCrashRecoveryTest
+// TODO(rsesek): Implement and enable these tests. http://crbug.com/179904
+#if defined(ENABLE_MESSAGE_CENTER) && !defined(OS_MACOSX)
+
+class MessageCenterExtensionCrashRecoveryTest
: 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 {
- 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();
- }
+ 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);
WaitForExtensionLoad();
}
virtual void CancelNotification(size_t index) OVERRIDE {
- 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));
- }
+ 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()));
}
virtual size_t CountBalloons() OVERRIDE {
- if (message_center::IsRichNotificationEnabled())
- return message_center::MessageCenter::Get()->NotificationCount();
+ message_center::MessageCenter* message_center =
+ message_center::MessageCenter::Get();
+ return message_center->NotificationCount();
+ }
+};
- return BalloonNotificationUIManager::GetInstanceForTesting()->
- balloon_collection()->GetActiveBalloons().size();
+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();
}
-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;
- }
+ 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));
+ }
+
+ 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;
+ }
};
+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 =