Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Unified Diff: chrome/browser/chromeos/extensions/file_browser_notifications.cc

Issue 10824265: Correctly remove file browser notifications from Ash notification tray. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/file_browser_notifications.cc
diff --git a/chrome/browser/chromeos/extensions/file_browser_notifications.cc b/chrome/browser/chromeos/extensions/file_browser_notifications.cc
index 6122ec1545c34bf3755d9e744539869e005999c6..c88de5a8f72726bc3bfdab429fd635a938f0deac 100644
--- a/chrome/browser/chromeos/extensions/file_browser_notifications.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_notifications.cc
@@ -107,7 +107,7 @@ class FileBrowserNotifications::NotificationMessage {
virtual void Error() OVERRIDE {}
virtual void Close(bool by_user) OVERRIDE {
if (host_)
- host_->HideNotificationById(id_);
+ host_->RemoveNotificationById(id_);
}
virtual void Click() OVERRIDE {
// TODO(tbarzic): Show more info page once we have one.
@@ -140,8 +140,9 @@ class FileBrowserNotifications::NotificationMessage {
const gfx::ImageSkia& icon =
*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_FILES_APP_ICON);
+ string16 replace_id = UTF8ToUTF16(notification_id_);
notification_id_ = DesktopNotificationService::AddIconNotification(
- GURL(), GetTitle(type_), message, icon,
+ GURL(), GetTitle(type_), message, icon, replace_id,
new Delegate(host->AsWeakPtr(), notification_id_), profile_);
} else {
system_notification_.reset(
@@ -388,13 +389,31 @@ void FileBrowserNotifications::ShowNotificationById(
notification->Show();
}
-void FileBrowserNotifications::HideNotificationById(const std::string& id) {
- NotificationMap::iterator it = notification_map_.find(id);
+void FileBrowserNotifications::HideNotificationById(
+ const std::string& notification_id) {
+ NotificationMap::iterator it = notification_map_.find(notification_id);
if (it != notification_map_.end()) {
- delete it->second;
- notification_map_.erase(it);
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ ash::switches::kAshNotifyDisabled)) {
+ // Will trigger Delegate::Close which will call RemoveNotificationById.
+ DesktopNotificationService::RemoveNotification(notification_id);
+ } else {
+ NotificationMessage* notification = it->second;
+ notification_map_.erase(it);
+ delete notification;
+ }
} else {
// Mark as hidden so it does not get shown from a delayed task.
- hidden_notifications_.insert(id);
+ hidden_notifications_.insert(notification_id);
+ }
+}
+
+void FileBrowserNotifications::RemoveNotificationById(
+ const std::string& notification_id) {
+ NotificationMap::iterator it = notification_map_.find(notification_id);
+ if (it != notification_map_.end()) {
+ NotificationMessage* notification = it->second;
+ notification_map_.erase(it);
+ delete notification;
}
}

Powered by Google App Engine
This is Rietveld 408576698