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

Unified Diff: chrome/browser/notifications/message_center_notification_manager.cc

Issue 11896085: Adding implementation for MessageCenter::Delegate on MessageCeneterNotificationManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable on win7_aura Created 7 years, 11 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/notifications/message_center_notification_manager.cc
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
index 030b5fa870e888dd93305050ed720fa295abe772..b6a876dd7703237163245bae04a07d2280dd81c6 100644
--- a/chrome/browser/notifications/message_center_notification_manager.cc
+++ b/chrome/browser/notifications/message_center_notification_manager.cc
@@ -7,9 +7,14 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/notifications/desktop_notification_service.h"
+#include "chrome/browser/notifications/desktop_notification_service_factory.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/pref_names.h"
@@ -135,22 +140,42 @@ bool MessageCenterNotificationManager::UpdateNotification(
void MessageCenterNotificationManager::DisableExtension(
const std::string& notification_id) {
- NOTIMPLEMENTED();
+ ProfileNotification* profile_notification =
+ FindProfileNotification(notification_id);
+ std::string extension_id = profile_notification->GetExtensionId();
+ DCHECK(!extension_id.empty()); // or UI should not have enabled the command.
+ profile_notification->profile()->GetExtensionService()->DisableExtension(
+ extension_id, extensions::Extension::DISABLE_USER_ACTION);
}
void MessageCenterNotificationManager::DisableNotificationsFromSource(
const std::string& notification_id) {
- NOTIMPLEMENTED();
+ ProfileNotification* profile_notification =
+ FindProfileNotification(notification_id);
+ // UI should not have enabled the command if there is no valid source.
+ DCHECK(profile_notification->notification().origin_url().is_valid());
+ DesktopNotificationService* service =
+ DesktopNotificationServiceFactory::GetForProfile(
+ profile_notification->profile());
+ service->DenyPermission(profile_notification->notification().origin_url());
}
void MessageCenterNotificationManager::NotificationRemoved(
const std::string& notification_id) {
- NOTIMPLEMENTED();
+ RemoveProfileNotification(FindProfileNotification(notification_id));
}
void MessageCenterNotificationManager::ShowSettings(
const std::string& notification_id) {
- NOTIMPLEMENTED();
+ ProfileNotification* profile_notification =
+ FindProfileNotification(notification_id);
+ Browser* browser =
+ chrome::FindOrCreateTabbedBrowser(profile_notification->profile(),
+ chrome::HOST_DESKTOP_TYPE_NATIVE);
+ if (profile_notification->GetExtensionId().empty())
+ chrome::ShowContentSettings(browser, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
+ else
+ chrome::ShowExtensions(browser);
}
void MessageCenterNotificationManager::ShowSettingsDialog(
@@ -160,12 +185,13 @@ void MessageCenterNotificationManager::ShowSettingsDialog(
void MessageCenterNotificationManager::OnClicked(
const std::string& notification_id) {
- NOTIMPLEMENTED();
+ FindProfileNotification(notification_id)->notification().Click();
}
void MessageCenterNotificationManager::OnButtonClicked(
const std::string& notification_id, int button_index) {
- NOTIMPLEMENTED();
+ FindProfileNotification(notification_id)->notification().ButtonClick(
+ button_index);
}
////////////////////////////////////////////////////////////////////////////////
@@ -216,3 +242,13 @@ void MessageCenterNotificationManager::RemoveProfileNotification(
profile_notifications_.erase(id);
delete profile_notification;
}
+
+MessageCenterNotificationManager::ProfileNotification*
+ MessageCenterNotificationManager::FindProfileNotification(
+ const std::string& id) const {
+ NotificationMap::const_iterator iter = profile_notifications_.find(id);
+ // If the notification is shown in UI, it must be in the map.
+ DCHECK(iter != profile_notifications_.end());
+ DCHECK((*iter).second);
+ return (*iter).second;
+}

Powered by Google App Engine
This is Rietveld 408576698