summaryrefslogtreecommitdiffstats
path: root/chrome/browser/background
diff options
context:
space:
mode:
authordewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-21 23:14:05 +0000
committerdewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-21 23:14:05 +0000
commit05d611865ff656674ffdd8a7d6f6910614c48161 (patch)
treea4b1d99f47d949a27e1318c8c8d5a1b9a12cd123 /chrome/browser/background
parent737c083177aaaaacd0edb43ba020a99890fc4a92 (diff)
downloadchromium_src-05d611865ff656674ffdd8a7d6f6910614c48161.zip
chromium_src-05d611865ff656674ffdd8a7d6f6910614c48161.tar.gz
chromium_src-05d611865ff656674ffdd8a7d6f6910614c48161.tar.bz2
Allow extension crash notifications to replace each other.
Previously they did not set an origin or replace_id, causing updates to be turned into adds in the notification UI manager, where it would DCHECK because the id matched that of an existing notification. This patch adds a replace_id and origin so that updates can happen smoothly. BUG=360591 Review URL: https://codereview.chromium.org/294473002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/background')
-rw-r--r--chrome/browser/background/background_contents_service.cc6
-rw-r--r--chrome/browser/background/background_contents_service_unittest.cc23
2 files changed, 24 insertions, 5 deletions
diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc
index 0d21871..45e84c1 100644
--- a/chrome/browser/background/background_contents_service.cc
+++ b/chrome/browser/background/background_contents_service.cc
@@ -177,11 +177,11 @@ void NotificationImageReady(
// TODO(mukai, dewittj): remove this and switch to message center
// notifications.
DesktopNotificationService::AddIconNotification(
- GURL() /* empty origin */,
- base::string16(),
+ GURL("chrome://extension-crash"), // Origin URL.
+ base::string16(), // Title of notification.
message,
notification_icon,
- base::string16(),
+ base::UTF8ToUTF16(delegate->id()), // Replace ID.
delegate.get(),
profile);
}
diff --git a/chrome/browser/background/background_contents_service_unittest.cc b/chrome/browser/background/background_contents_service_unittest.cc
index 7389d9e..1db5fb7 100644
--- a/chrome/browser/background/background_contents_service_unittest.cc
+++ b/chrome/browser/background/background_contents_service_unittest.cc
@@ -131,8 +131,6 @@ class NotificationWaiter : public message_center::MessageCenterObserver {
DCHECK(!run_loop_.running());
message_center::MessageCenter* message_center =
message_center::MessageCenter::Get();
- if (message_center->HasNotification(target_id_))
- return;
message_center->AddObserver(this);
run_loop_.Run();
@@ -147,6 +145,12 @@ class NotificationWaiter : public message_center::MessageCenterObserver {
run_loop_.Quit();
}
+ virtual void OnNotificationUpdated(
+ const std::string& notification_id) OVERRIDE {
+ if (notification_id == target_id_)
+ run_loop_.Quit();
+ }
+
std::string target_id_;
base::RunLoop run_loop_;
@@ -366,4 +370,19 @@ TEST_F(BackgroundContentsServiceNotificationTest, TestShowBalloonNoIcon) {
const Notification* notification = CreateCrashNotification(extension);
EXPECT_FALSE(notification->icon().IsEmpty());
}
+
+TEST_F(BackgroundContentsServiceNotificationTest, TestShowTwoBalloons) {
+ TestingProfile profile;
+ scoped_refptr<extensions::Extension> extension =
+ extension_test_util::LoadManifest("app", "manifest.json");
+ ASSERT_TRUE(extension.get());
+ CreateCrashNotification(extension);
+ CreateCrashNotification(extension);
+
+ message_center::MessageCenter* message_center =
+ message_center::MessageCenter::Get();
+ message_center::NotificationList::Notifications notifications =
+ message_center->GetVisibleNotifications();
+ ASSERT_EQ(1u, notifications.size());
+}
#endif