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

Unified Diff: chrome/browser/notifications/desktop_notification_service.cc

Issue 622793002: Group the different permission related methods in the content api. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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
Index: chrome/browser/notifications/desktop_notification_service.cc
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index fad44eb4d08637db2d682900097157e443a90a9d..2806ce1ed5c0d89cc560a76f93f6ed66666dde74 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -102,11 +102,12 @@ std::string DesktopNotificationService::AddIconNotification(
DesktopNotificationService::DesktopNotificationService(Profile* profile)
: PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS),
- profile_(profile),
+ profile_(profile)
#if defined(ENABLE_EXTENSIONS)
- extension_registry_observer_(this),
+ ,
+ extension_registry_observer_(this)
#endif
- weak_factory_(this) {
+{
OnStringListPrefChanged(
prefs::kMessageCenterDisabledExtensionIds, &disabled_extension_ids_);
OnStringListPrefChanged(
@@ -142,7 +143,7 @@ void DesktopNotificationService::RequestNotificationPermission(
const PermissionRequestID& request_id,
const GURL& requesting_origin,
bool user_gesture,
- const NotificationPermissionCallback& callback) {
+ const base::Callback<void(bool)>& result_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
#if defined(ENABLE_EXTENSIONS)
@@ -169,19 +170,16 @@ void DesktopNotificationService::RequestNotificationPermission(
extensions::APIPermission::kNotifications,
extension,
web_contents->GetRenderViewHost())) {
- callback.Run(blink::WebNotificationPermissionAllowed);
+ result_callback.Run(true);
return;
}
#endif
- RequestPermission(
- web_contents,
- request_id,
- requesting_origin,
- user_gesture,
- base::Bind(&DesktopNotificationService::OnNotificationPermissionRequested,
- weak_factory_.GetWeakPtr(),
- callback));
+ RequestPermission(web_contents,
+ request_id,
+ requesting_origin,
+ user_gesture,
+ result_callback);
}
void DesktopNotificationService::ShowDesktopNotification(
@@ -357,15 +355,6 @@ void DesktopNotificationService::UpdateContentSetting(
}
}
-void DesktopNotificationService::OnNotificationPermissionRequested(
- const NotificationPermissionCallback& callback, bool allowed) {
- blink::WebNotificationPermission permission = allowed ?
- blink::WebNotificationPermissionAllowed :
- blink::WebNotificationPermissionDenied;
-
- callback.Run(permission);
-}
-
void DesktopNotificationService::FirePermissionLevelChangedEvent(
const NotifierId& notifier_id, bool enabled) {
#if defined(ENABLE_EXTENSIONS)

Powered by Google App Engine
This is Rietveld 408576698