Index: chrome/browser/extensions/api/notification/notification_api.cc |
diff --git a/chrome/browser/extensions/api/notification/notification_api.cc b/chrome/browser/extensions/api/notification/notification_api.cc |
index 2aea0d9343a56034c420bafe11738d831673cb40..6db3e17b56a605e94c344bf3f352e92abe06c074 100644 |
--- a/chrome/browser/extensions/api/notification/notification_api.cc |
+++ b/chrome/browser/extensions/api/notification/notification_api.cc |
@@ -11,6 +11,8 @@ |
#include "chrome/browser/extensions/event_names.h" |
#include "chrome/browser/extensions/event_router.h" |
#include "chrome/browser/extensions/extension_system.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/notifications/notification_ui_manager.h" |
#include "chrome/common/extensions/extension.h" |
@@ -194,6 +196,12 @@ void NotificationApiFunction::CreateNotification( |
g_browser_process->notification_ui_manager()->Add(notification, profile()); |
} |
+bool NotificationApiFunction::IsNotificationApiEnabled() { |
+ DesktopNotificationService* service = |
+ DesktopNotificationServiceFactory::GetForProfile(profile()); |
+ return service->IsExtensionEnabled(extension_->id()); |
+} |
+ |
const char kNotificationPrefix[] = "extension.api."; |
static uint64 next_id_ = 0; |
@@ -208,6 +216,11 @@ bool NotificationCreateFunction::RunImpl() { |
params_ = api::experimental_notification::Create::Params::Create(*args_); |
EXTENSION_FUNCTION_VALIDATE(params_.get()); |
+ if (!IsNotificationApiEnabled()) { |
miket_OOO
2013/02/11 23:04:20
If you think this should be enforced for all Notif
Jun Mukai
2013/02/12 01:09:02
That sounds reasonable. Fixed the code based on yo
|
+ SendResponse(false); |
+ return true; |
+ } |
+ |
// If the caller provided a notificationId, use that. Otherwise, generate |
// one. Note that there's nothing stopping an app developer from passing in |
// arbitrary "extension.api.999" notificationIds that will collide with |
@@ -239,6 +252,11 @@ bool NotificationUpdateFunction::RunImpl() { |
params_ = api::experimental_notification::Update::Params::Create(*args_); |
EXTENSION_FUNCTION_VALIDATE(params_.get()); |
+ if (!IsNotificationApiEnabled()) { |
+ SendResponse(false); |
+ return true; |
+ } |
+ |
if (g_browser_process->notification_ui_manager()-> |
DoesIdExist(NotificationApiDelegate::CreateScopedIdentifier( |
extension_->id(), params_->notification_id))) { |
@@ -263,6 +281,11 @@ bool NotificationDeleteFunction::RunImpl() { |
params_ = api::experimental_notification::Delete::Params::Create(*args_); |
EXTENSION_FUNCTION_VALIDATE(params_.get()); |
+ if (!IsNotificationApiEnabled()) { |
+ SendResponse(false); |
+ return true; |
+ } |
+ |
bool cancel_result = g_browser_process->notification_ui_manager()-> |
CancelById(NotificationApiDelegate::CreateScopedIdentifier( |
extension_->id(), params_->notification_id)); |