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

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

Issue 376253005: Migrate the notification permission to the new common permission classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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/desktop_notification_profile_util.h"
6
7 #include "chrome/browser/content_settings/content_settings_provider.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/content_settings_pattern.h"
11
Peter Beverloo 2014/07/18 10:42:38 micro nit: two white lines -> one of 'em.
Miguel Garcia 2014/07/18 12:27:09 Done.
12
13 void DesktopNotificationProfileUtil::ResetToDefaultContentSetting(
14 Profile* profile) {
15 profile->GetHostContentSettingsMap()->SetDefaultContentSetting(
Peter Beverloo 2014/07/18 10:42:38 I'm in flux. Nothing in this class uses anything f
Miguel Garcia 2014/07/18 12:27:08 Acknowledged.
16 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_DEFAULT);
17 }
18
19 // Clears the notifications setting for the given pattern.
20 void DesktopNotificationProfileUtil::ClearSetting(
Peter Beverloo 2014/07/18 10:42:38 static methods should be annotated with a comment
Miguel Garcia 2014/07/18 12:27:09 I think we usually do this when the class has both
21 Profile* profile, const ContentSettingsPattern& pattern) {
22 profile->GetHostContentSettingsMap()->SetContentSetting(
23 pattern,
24 ContentSettingsPattern::Wildcard(),
25 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
26 NO_RESOURCE_IDENTIFIER,
27 CONTENT_SETTING_DEFAULT);
28
29 }
30
31 // Clears the sets of explicitly allowed and denied origins.
32 void DesktopNotificationProfileUtil::ResetAllOrigins(Profile* profile) {
Peter Beverloo 2014/07/18 10:42:38 This method is only used for NotificationTest. Can
Miguel Garcia 2014/07/18 12:27:09 Good idea, it was only used once in the test so I
33 profile->GetHostContentSettingsMap()->ClearSettingsForOneType(
34 CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
35 }
36
37 // Methods to setup and modify permission preferences.
38 void DesktopNotificationProfileUtil::GrantPermission(
39 Profile* profile, const GURL& origin) {
40 ContentSettingsPattern primary_pattern =
41 ContentSettingsPattern::FromURLNoWildcard(origin);
42 profile->GetHostContentSettingsMap()->SetContentSetting(
43 primary_pattern,
44 ContentSettingsPattern::Wildcard(),
45 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
46 NO_RESOURCE_IDENTIFIER,
47 CONTENT_SETTING_ALLOW);
48 }
49
50 void DesktopNotificationProfileUtil::DenyPermission(
51 Profile* profile, const GURL& origin) {
52 ContentSettingsPattern primary_pattern =
53 ContentSettingsPattern::FromURLNoWildcard(origin);
54 profile->GetHostContentSettingsMap()->SetContentSetting(
55 primary_pattern,
56 ContentSettingsPattern::Wildcard(),
57 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
58 NO_RESOURCE_IDENTIFIER,
59 CONTENT_SETTING_BLOCK);
60 }
61
62 void DesktopNotificationProfileUtil::GetNotificationsSettings(
63 Profile* profile, ContentSettingsForOneType* settings) {
64 profile->GetHostContentSettingsMap()->GetSettingsForOneType(
65 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
66 NO_RESOURCE_IDENTIFIER,
67 settings);
68 }
69
70 ContentSetting DesktopNotificationProfileUtil::GetContentSetting(
71 Profile* profile, const GURL& origin) {
72 return profile->GetHostContentSettingsMap()->GetContentSetting(
73 origin,
74 origin,
75 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
76 NO_RESOURCE_IDENTIFIER);
77 }
78
79 void DesktopNotificationProfileUtil::SetDefaultContentSetting(
Peter Beverloo 2014/07/18 10:42:38 Dito, we can implement this as a helper method in
Miguel Garcia 2014/07/18 12:27:09 Done.
80 Profile* profile, ContentSetting setting) {
81 profile->GetHostContentSettingsMap()->SetDefaultContentSetting(
82 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting);
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698