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

Unified Diff: chrome/browser/extensions/api/notification_provider/notification_provider_api.cc

Issue 468813002: Add NotifyOnPermissionLevelChanged implementation of notification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/notification_provider/basic_usage/background.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/notification_provider/notification_provider_api.cc
diff --git a/chrome/browser/extensions/api/notification_provider/notification_provider_api.cc b/chrome/browser/extensions/api/notification_provider/notification_provider_api.cc
index 78f773789340ff4181f2ee11943b2f238e2b081e..784b538322ef11785be3b3d7ac9ca1c3e865e289 100644
--- a/chrome/browser/extensions/api/notification_provider/notification_provider_api.cc
+++ b/chrome/browser/extensions/api/notification_provider/notification_provider_api.cc
@@ -10,6 +10,8 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.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/chrome_version_info.h"
@@ -194,9 +196,31 @@ NotificationProviderNotifyOnPermissionLevelChangedFunction::Run() {
params = api::notification_provider::NotifyOnPermissionLevelChanged::
Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ // Third party apps/extensions with notification provider API will not be able
+ // to change permission levels of web notifiers, because the list of allowed
+ // websites should only be set in Chrome Settings manually by users. But they
+ // are able to change permission levels of application type notifiers.
+ bool is_application_type =
+ (params->notifier_type ==
+ api::notification_provider::NotifierType::NOTIFIER_TYPE_APPLICATION);
+ if (is_application_type) {
+ bool enabled =
+ (params->level == api::notification_provider::NotifierPermissionLevel::
+ NOTIFIER_PERMISSION_LEVEL_GRANTED);
+
+ DesktopNotificationService* desktop_notification_service =
+ DesktopNotificationServiceFactory::GetForProfile(GetProfile());
+ message_center::NotifierId notifier_id(
+ message_center::NotifierId::NotifierType::APPLICATION,
+ params->notifier_id);
+
+ desktop_notification_service->SetNotifierEnabled(notifier_id, enabled);
+ }
+
return RespondNow(
ArgumentList(api::notification_provider::NotifyOnPermissionLevelChanged::
- Results::Create(true)));
+ Results::Create(is_application_type)));
}
NotificationProviderNotifyOnShowSettingsFunction::
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/notification_provider/basic_usage/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698