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

Unified Diff: chrome/browser/extensions/api/notification/notification_api.cc

Issue 12221127: Actually prevent sending notifications from apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 10 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
« no previous file with comments | « chrome/browser/extensions/api/notification/notification_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..65e788fe31e3eef5731759479e7849fc4ce5cd81 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,21 @@ 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());
+}
+
+bool NotificationApiFunction::RunImpl() {
+ if (!IsNotificationApiEnabled()) {
+ SendResponse(false);
+ return true;
+ }
+
+ return RunNotificationApi();
+}
+
const char kNotificationPrefix[] = "extension.api.";
static uint64 next_id_ = 0;
@@ -204,7 +221,7 @@ NotificationCreateFunction::NotificationCreateFunction() {
NotificationCreateFunction::~NotificationCreateFunction() {
}
-bool NotificationCreateFunction::RunImpl() {
+bool NotificationCreateFunction::RunNotificationApi() {
params_ = api::experimental_notification::Create::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
@@ -235,7 +252,7 @@ NotificationUpdateFunction::NotificationUpdateFunction() {
NotificationUpdateFunction::~NotificationUpdateFunction() {
}
-bool NotificationUpdateFunction::RunImpl() {
+bool NotificationUpdateFunction::RunNotificationApi() {
params_ = api::experimental_notification::Update::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
@@ -259,7 +276,7 @@ NotificationDeleteFunction::NotificationDeleteFunction() {
NotificationDeleteFunction::~NotificationDeleteFunction() {
}
-bool NotificationDeleteFunction::RunImpl() {
+bool NotificationDeleteFunction::RunNotificationApi() {
params_ = api::experimental_notification::Delete::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
« no previous file with comments | « chrome/browser/extensions/api/notification/notification_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698