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

Side by Side Diff: chrome/browser/notifications/notification_permission_context.cc

Issue 1207363002: Simplify permission-related code for Web Notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/notification_permission_context.h"
6
7 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
8 #include "components/content_settings/core/common/content_settings_pattern.h"
9 #include "url/gurl.h"
10
11 NotificationPermissionContext::NotificationPermissionContext(Profile* profile)
12 : PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {}
13
14 NotificationPermissionContext::~NotificationPermissionContext() {}
15
16 void NotificationPermissionContext::ResetPermission(
17 const GURL& requesting_origin,
18 const GURL& embedder_origin) {
19 DesktopNotificationProfileUtil::ClearSetting(
20 profile(), ContentSettingsPattern::FromURLNoWildcard(requesting_origin));
21 }
22
23 // Unlike other permission types, granting a notification for a given origin
24 // will not take into account the |embedder_origin|, it will only be based
25 // on the requesting iframe origin.
26 // TODO(mukai) Consider why notifications behave differently than
27 // other permissions. https://crbug.com/416894
28 void NotificationPermissionContext::UpdateContentSetting(
29 const GURL& requesting_origin,
30 const GURL& embedder_origin,
31 ContentSetting content_setting) {
32 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
33 content_setting == CONTENT_SETTING_BLOCK);
34
35 if (content_setting == CONTENT_SETTING_ALLOW) {
36 DesktopNotificationProfileUtil::GrantPermission(profile(),
37 requesting_origin);
38 } else {
39 DesktopNotificationProfileUtil::DenyPermission(profile(),
40 requesting_origin);
41 }
42 }
43
44 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const {
45 return false;
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698