Chromium Code Reviews| 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 34535fbd5a6cf7aa9fbf7876b83b9913fad3cf90..4d4d91458884a19b2b81dfabaa2d3520642fa0b6 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" | 
| @@ -17,6 +19,7 @@ | 
| #include "extensions/common/extension.h" | 
| #include "extensions/common/features/feature.h" | 
| #include "ui/base/layout.h" | 
| +#include "ui/message_center/notifier_settings.h" | 
| #include "url/gurl.h" | 
| namespace extensions { | 
| @@ -191,12 +194,34 @@ NotificationProviderNotifyOnPermissionLevelChangedFunction::Run() { | 
| scoped_ptr<api::notification_provider::NotifyOnPermissionLevelChanged::Params> | 
| params = api::notification_provider::NotifyOnPermissionLevelChanged:: | 
| Params::Create(*args_); | 
| - | 
| EXTENSION_FUNCTION_VALIDATE(params.get()); | 
| + bool is_application_type = | 
| 
 
Pete Williamson
2014/08/13 19:54:01
Let's add a comment about why we only check applic
 
liyanhou
2014/08/14 16:15:24
Done.
 
 | 
| + (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) | 
| + ? true | 
| + : false; | 
| + | 
| + 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); | 
| + } | 
| + | 
| + // 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. They can | 
| + // can change permission levels of application type notifiers. | 
| 
 
Pete Williamson
2014/08/13 19:54:01
nit: notifiers. Because -> notifiers, because
 
liyanhou
2014/08/14 16:15:24
Done.
 
 | 
| return RespondNow( | 
| ArgumentList(api::notification_provider::NotifyOnPermissionLevelChanged:: | 
| - Results::Create(true))); | 
| + Results::Create(is_application_type))); | 
| } | 
| NotificationProviderNotifyOnShowSettingsFunction:: |