diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-11 00:59:14 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-11 00:59:14 +0000 |
commit | 93b1c4e979784d6741cad83cedbc2405878b0ecf (patch) | |
tree | e653029e2eba8f44d4c2565f46fdf1785121dd4b /chrome/browser/extensions | |
parent | e0e9dff62d8dfb9d43259e54a0e01c21e2b4c062 (diff) | |
download | chromium_src-93b1c4e979784d6741cad83cedbc2405878b0ecf.zip chromium_src-93b1c4e979784d6741cad83cedbc2405878b0ecf.tar.gz chromium_src-93b1c4e979784d6741cad83cedbc2405878b0ecf.tar.bz2 |
Remove balloon notification code. The last user was the Linux GTK port but that's deleted now.
BUG=297026, 361784
R=mukai@chromium.org, stevenjb@chromium.org
Review URL: https://codereview.chromium.org/231723006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263150 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
3 files changed, 132 insertions, 211 deletions
diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc index 1ee1c10..14bfc28 100644 --- a/chrome/browser/extensions/api/notifications/notifications_api.cc +++ b/chrome/browser/extensions/api/notifications/notifications_api.cc @@ -254,66 +254,64 @@ bool NotificationsApiFunction::CreateNotification( // Then, handle any optional data that's been provided. message_center::RichNotificationData optional_fields; - if (message_center::IsRichNotificationEnabled()) { - if (options->priority.get()) - optional_fields.priority = *options->priority; - - if (options->event_time.get()) - optional_fields.timestamp = base::Time::FromJsTime(*options->event_time); - - if (options->buttons.get()) { - // Currently we allow up to 2 buttons. - size_t number_of_buttons = options->buttons->size(); - number_of_buttons = number_of_buttons > 2 ? 2 : number_of_buttons; - - for (size_t i = 0; i < number_of_buttons; i++) { - message_center::ButtonInfo info( - base::UTF8ToUTF16((*options->buttons)[i]->title)); - NotificationBitmapToGfxImage((*options->buttons)[i]->icon_bitmap.get(), - &info.icon); - optional_fields.buttons.push_back(info); - } + if (options->priority.get()) + optional_fields.priority = *options->priority; + + if (options->event_time.get()) + optional_fields.timestamp = base::Time::FromJsTime(*options->event_time); + + if (options->buttons.get()) { + // Currently we allow up to 2 buttons. + size_t number_of_buttons = options->buttons->size(); + number_of_buttons = number_of_buttons > 2 ? 2 : number_of_buttons; + + for (size_t i = 0; i < number_of_buttons; i++) { + message_center::ButtonInfo info( + base::UTF8ToUTF16((*options->buttons)[i]->title)); + NotificationBitmapToGfxImage((*options->buttons)[i]->icon_bitmap.get(), + &info.icon); + optional_fields.buttons.push_back(info); } + } - if (options->context_message) { - optional_fields.context_message = - base::UTF8ToUTF16(*options->context_message); - } + if (options->context_message) { + optional_fields.context_message = + base::UTF8ToUTF16(*options->context_message); + } - bool has_image = NotificationBitmapToGfxImage(options->image_bitmap.get(), - &optional_fields.image); - // We should have an image if and only if the type is an image type. - if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) - return false; + bool has_image = NotificationBitmapToGfxImage(options->image_bitmap.get(), + &optional_fields.image); + // We should have an image if and only if the type is an image type. + if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) + return false; - // We should have list items if and only if the type is a multiple type. - bool has_list_items = options->items.get() && options->items->size() > 0; - if (has_list_items != (type == message_center::NOTIFICATION_TYPE_MULTIPLE)) - return false; + // We should have list items if and only if the type is a multiple type. + bool has_list_items = options->items.get() && options->items->size() > 0; + if (has_list_items != (type == message_center::NOTIFICATION_TYPE_MULTIPLE)) + return false; - if (options->progress.get() != NULL) { - // We should have progress if and only if the type is a progress type. - if (type != message_center::NOTIFICATION_TYPE_PROGRESS) { - SetError(kUnexpectedProgressValueForNonProgressType); - return false; - } - optional_fields.progress = *options->progress; - // Progress value should range from 0 to 100. - if (optional_fields.progress < 0 || optional_fields.progress > 100) { - SetError(kInvalidProgressValue); - return false; - } + if (options->progress.get() != NULL) { + // We should have progress if and only if the type is a progress type. + if (type != message_center::NOTIFICATION_TYPE_PROGRESS) { + SetError(kUnexpectedProgressValueForNonProgressType); + return false; + } + optional_fields.progress = *options->progress; + // Progress value should range from 0 to 100. + if (optional_fields.progress < 0 || optional_fields.progress > 100) { + SetError(kInvalidProgressValue); + return false; } + } - if (has_list_items) { - using api::notifications::NotificationItem; - std::vector<linked_ptr<NotificationItem> >::iterator i; - for (i = options->items->begin(); i != options->items->end(); ++i) { - message_center::NotificationItem item( - base::UTF8ToUTF16(i->get()->title), - base::UTF8ToUTF16(i->get()->message)); - optional_fields.items.push_back(item); - } + if (has_list_items) { + using api::notifications::NotificationItem; + std::vector<linked_ptr<NotificationItem> >::iterator i; + for (i = options->items->begin(); i != options->items->end(); ++i) { + message_center::NotificationItem item( + base::UTF8ToUTF16(i->get()->title), + base::UTF8ToUTF16(i->get()->message)); + optional_fields.items.push_back(item); } } @@ -360,73 +358,71 @@ bool NotificationsApiFunction::UpdateNotification( notification->set_icon(icon); } - if (message_center::IsRichNotificationEnabled()) { - if (options->priority) - notification->set_priority(*options->priority); - - if (options->event_time) - notification->set_timestamp(base::Time::FromJsTime(*options->event_time)); - - if (options->buttons) { - // Currently we allow up to 2 buttons. - size_t number_of_buttons = options->buttons->size(); - number_of_buttons = number_of_buttons > 2 ? 2 : number_of_buttons; - - std::vector<message_center::ButtonInfo> buttons; - for (size_t i = 0; i < number_of_buttons; i++) { - message_center::ButtonInfo button( - base::UTF8ToUTF16((*options->buttons)[i]->title)); - NotificationBitmapToGfxImage((*options->buttons)[i]->icon_bitmap.get(), - &button.icon); - buttons.push_back(button); - } - notification->set_buttons(buttons); - } + if (options->priority) + notification->set_priority(*options->priority); - if (options->context_message) { - notification->set_context_message( - base::UTF8ToUTF16(*options->context_message)); - } + if (options->event_time) + notification->set_timestamp(base::Time::FromJsTime(*options->event_time)); - gfx::Image image; - if (NotificationBitmapToGfxImage(options->image_bitmap.get(), &image)) { - // We should have an image if and only if the type is an image type. - if (notification->type() != message_center::NOTIFICATION_TYPE_IMAGE) - return false; - notification->set_image(image); + if (options->buttons) { + // Currently we allow up to 2 buttons. + size_t number_of_buttons = options->buttons->size(); + number_of_buttons = number_of_buttons > 2 ? 2 : number_of_buttons; + + std::vector<message_center::ButtonInfo> buttons; + for (size_t i = 0; i < number_of_buttons; i++) { + message_center::ButtonInfo button( + base::UTF8ToUTF16((*options->buttons)[i]->title)); + NotificationBitmapToGfxImage((*options->buttons)[i]->icon_bitmap.get(), + &button.icon); + buttons.push_back(button); } + notification->set_buttons(buttons); + } + + if (options->context_message) { + notification->set_context_message( + base::UTF8ToUTF16(*options->context_message)); + } + + gfx::Image image; + if (NotificationBitmapToGfxImage(options->image_bitmap.get(), &image)) { + // We should have an image if and only if the type is an image type. + if (notification->type() != message_center::NOTIFICATION_TYPE_IMAGE) + return false; + notification->set_image(image); + } - if (options->progress) { - // We should have progress if and only if the type is a progress type. - if (notification->type() != message_center::NOTIFICATION_TYPE_PROGRESS) { - SetError(kUnexpectedProgressValueForNonProgressType); - return false; - } - int progress = *options->progress; - // Progress value should range from 0 to 100. - if (progress < 0 || progress > 100) { - SetError(kInvalidProgressValue); - return false; - } - notification->set_progress(progress); + if (options->progress) { + // We should have progress if and only if the type is a progress type. + if (notification->type() != message_center::NOTIFICATION_TYPE_PROGRESS) { + SetError(kUnexpectedProgressValueForNonProgressType); + return false; + } + int progress = *options->progress; + // Progress value should range from 0 to 100. + if (progress < 0 || progress > 100) { + SetError(kInvalidProgressValue); + return false; } + notification->set_progress(progress); + } + + if (options->items.get() && options->items->size() > 0) { + // We should have list items if and only if the type is a multiple type. + if (notification->type() != message_center::NOTIFICATION_TYPE_MULTIPLE) + return false; - if (options->items.get() && options->items->size() > 0) { - // We should have list items if and only if the type is a multiple type. - if (notification->type() != message_center::NOTIFICATION_TYPE_MULTIPLE) - return false; - - std::vector<message_center::NotificationItem> items; - using api::notifications::NotificationItem; - std::vector<linked_ptr<NotificationItem> >::iterator i; - for (i = options->items->begin(); i != options->items->end(); ++i) { - message_center::NotificationItem item( - base::UTF8ToUTF16(i->get()->title), - base::UTF8ToUTF16(i->get()->message)); - items.push_back(item); - } - notification->set_items(items); + std::vector<message_center::NotificationItem> items; + using api::notifications::NotificationItem; + std::vector<linked_ptr<NotificationItem> >::iterator i; + for (i = options->items->begin(); i != options->items->end(); ++i) { + message_center::NotificationItem item( + base::UTF8ToUTF16(i->get()->title), + base::UTF8ToUTF16(i->get()->message)); + items.push_back(item); } + notification->set_items(items); } // Then override if it's already set. diff --git a/chrome/browser/extensions/api/notifications/notifications_apitest.cc b/chrome/browser/extensions/api/notifications/notifications_apitest.cc index d859955..6456550 100644 --- a/chrome/browser/extensions/api/notifications/notifications_apitest.cc +++ b/chrome/browser/extensions/api/notifications/notifications_apitest.cc @@ -456,16 +456,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestCSP) { ASSERT_TRUE(RunExtensionTest("notifications/api/csp")) << message_; } -// 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, MAYBE_TestByUser) { - ASSERT_TRUE(message_center::IsRichNotificationEnabled()); - +IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestByUser) { const extensions::Extension* extension = LoadExtensionAndWait("notifications/api/by_user"); ASSERT_TRUE(extension) << message_; @@ -626,13 +617,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestProgressNotification) { } } -// MessaceCenter-specific test. -#if defined(RUN_MESSAGE_CENTER_TESTS) -#define MAYBE_TestPartialUpdate TestPartialUpdate -#else -#define MAYBE_TestPartialUpdate DISABLED_TestPartialUpdate -#endif -IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestPartialUpdate) { +IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestPartialUpdate) { scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); // Create a new notification. @@ -726,14 +711,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestPartialUpdate) { EXPECT_EQ(0u, notification->buttons().size()); } -// MessaceCenter-specific test. -#if defined(RUN_MESSAGE_CENTER_TESTS) -#define MAYBE_TestGetPermissionLevel TestGetPermissionLevel -#else -#define MAYBE_TestGetPermissionLevel DISABLED_TestGetPermissionLevel -#endif - -IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestGetPermissionLevel) { +IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestGetPermissionLevel) { scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); // Get permission level for the extension whose notifications are enabled. @@ -786,15 +764,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestGetPermissionLevel) { } } -// MessaceCenter-specific test. -#if defined(RUN_MESSAGE_CENTER_TESTS) -#define MAYBE_TestOnPermissionLevelChanged TestOnPermissionLevelChanged -#else -#define MAYBE_TestOnPermissionLevelChanged DISABLED_TestOnPermissionLevelChanged -#endif - -IN_PROC_BROWSER_TEST_F(NotificationsApiTest, - MAYBE_TestOnPermissionLevelChanged) { +IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestOnPermissionLevelChanged) { const extensions::Extension* extension = LoadExtensionAndWait("notifications/api/permission"); ASSERT_TRUE(extension) << message_; diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc index c92f149..ccaf59e 100644 --- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc +++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc @@ -5,11 +5,9 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/notifications/balloon.h" -#include "chrome/browser/notifications/balloon_collection.h" -#include "chrome/browser/notifications/balloon_host.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_delegate.h" +#include "chrome/browser/notifications/notification_ui_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" @@ -30,12 +28,6 @@ #include "ui/message_center/message_center_util.h" #include "ui/message_center/notification_list.h" -#if defined(OS_CHROMEOS) -#include "chrome/browser/notifications/notification_ui_manager.h" -#else -#include "chrome/browser/notifications/balloon_notification_ui_manager.h" -#endif - using content::NavigationController; using content::WebContents; using extensions::Extension; @@ -137,69 +129,32 @@ class MAYBE_ExtensionCrashRecoveryTest : public ExtensionCrashRecoveryTestBase { protected: 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->GetVisibleNotifications().rbegin(); - for (size_t i=0; i < index; ++i) - it++; - std::string id = (*it)->id(); - message_center->ClickOnNotification(id); -#if defined(TOOLKIT_GTK) - } else { - Balloon* balloon = GetNotificationDelegate(index); - ASSERT_TRUE(balloon); - balloon->OnClick(); -#endif - } + message_center::MessageCenter* message_center = + message_center::MessageCenter::Get(); + ASSERT_GT(message_center->NotificationCount(), index); + message_center::NotificationList::Notifications::reverse_iterator it = + message_center->GetVisibleNotifications().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->GetVisibleNotifications().rbegin(); - for (size_t i=0; i < index; i++) { it++; } - ASSERT_TRUE(g_browser_process->notification_ui_manager()-> - CancelById((*it)->id())); -#if defined(TOOLKIT_GTK) - } 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)); -#endif - } + message_center::MessageCenter* message_center = + message_center::MessageCenter::Get(); + ASSERT_GT(message_center->NotificationCount(), index); + message_center::NotificationList::Notifications::reverse_iterator it = + message_center->GetVisibleNotifications().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(); - -#if defined(TOOLKIT_GTK) - return BalloonNotificationUIManager::GetInstanceForTesting()-> - balloon_collection()->GetActiveBalloons().size(); -#else - CHECK(false); - return 0; -#endif + return message_center::MessageCenter::Get()->NotificationCount(); } - - private: -#if defined(TOOLKIT_GTK) - Balloon* GetNotificationDelegate(size_t index) { - BalloonNotificationUIManager* manager = - BalloonNotificationUIManager::GetInstanceForTesting(); - BalloonCollection::Balloons balloons = - manager->balloon_collection()->GetActiveBalloons(); - return index < balloons.size() ? balloons.at(index) : NULL; - } -#endif }; // Flaky: http://crbug.com/242167. |