OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/notifications/message_center_notification_manager.h" | 5 #include "chrome/browser/notifications/message_center_notification_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 //////////////////////////////////////////////////////////////////////////////// | 167 //////////////////////////////////////////////////////////////////////////////// |
168 // MessageCenter::Delegate | 168 // MessageCenter::Delegate |
169 | 169 |
170 void MessageCenterNotificationManager::DisableExtension( | 170 void MessageCenterNotificationManager::DisableExtension( |
171 const std::string& notification_id) { | 171 const std::string& notification_id) { |
172 ProfileNotification* profile_notification = | 172 ProfileNotification* profile_notification = |
173 FindProfileNotification(notification_id); | 173 FindProfileNotification(notification_id); |
174 std::string extension_id = profile_notification->GetExtensionId(); | 174 std::string extension_id = profile_notification->GetExtensionId(); |
175 DCHECK(!extension_id.empty()); // or UI should not have enabled the command. | 175 DCHECK(!extension_id.empty()); // or UI should not have enabled the command. |
176 profile_notification->profile()->GetExtensionService()->DisableExtension( | 176 DesktopNotificationService* service = |
177 extension_id, extensions::Extension::DISABLE_USER_ACTION); | 177 DesktopNotificationServiceFactory::GetForProfile( |
| 178 profile_notification->profile()); |
| 179 service->SetExtensionEnabled(extension_id, false); |
178 } | 180 } |
179 | 181 |
180 void MessageCenterNotificationManager::DisableNotificationsFromSource( | 182 void MessageCenterNotificationManager::DisableNotificationsFromSource( |
181 const std::string& notification_id) { | 183 const std::string& notification_id) { |
182 ProfileNotification* profile_notification = | 184 ProfileNotification* profile_notification = |
183 FindProfileNotification(notification_id); | 185 FindProfileNotification(notification_id); |
184 // UI should not have enabled the command if there is no valid source. | 186 // UI should not have enabled the command if there is no valid source. |
185 DCHECK(profile_notification->notification().origin_url().is_valid()); | 187 DCHECK(profile_notification->notification().origin_url().is_valid()); |
186 DesktopNotificationService* service = | 188 DesktopNotificationService* service = |
187 DesktopNotificationServiceFactory::GetForProfile( | 189 DesktopNotificationServiceFactory::GetForProfile( |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 406 |
405 MessageCenterNotificationManager::ProfileNotification* | 407 MessageCenterNotificationManager::ProfileNotification* |
406 MessageCenterNotificationManager::FindProfileNotification( | 408 MessageCenterNotificationManager::FindProfileNotification( |
407 const std::string& id) const { | 409 const std::string& id) const { |
408 NotificationMap::const_iterator iter = profile_notifications_.find(id); | 410 NotificationMap::const_iterator iter = profile_notifications_.find(id); |
409 // If the notification is shown in UI, it must be in the map. | 411 // If the notification is shown in UI, it must be in the map. |
410 DCHECK(iter != profile_notifications_.end()); | 412 DCHECK(iter != profile_notifications_.end()); |
411 DCHECK((*iter).second); | 413 DCHECK((*iter).second); |
412 return (*iter).second; | 414 return (*iter).second; |
413 } | 415 } |
OLD | NEW |