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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_permission_context.cc

Issue 1312453005: Removed Profile::GetHostContentSettingsMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed patch conflict Created 5 years, 3 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/push_messaging/push_messaging_permission_context.h" 5 #include "chrome/browser/push_messaging/push_messaging_permission_context.h"
6 6
7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
7 #include "chrome/browser/notifications/notification_permission_context.h" 8 #include "chrome/browser/notifications/notification_permission_context.h"
8 #include "chrome/browser/notifications/notification_permission_context_factory.h " 9 #include "chrome/browser/notifications/notification_permission_context_factory.h "
9 #include "chrome/browser/permissions/permission_context_uma_util.h" 10 #include "chrome/browser/permissions/permission_context_uma_util.h"
10 #include "chrome/browser/permissions/permission_request_id.h" 11 #include "chrome/browser/permissions/permission_request_id.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "components/content_settings/core/browser/host_content_settings_map.h" 13 #include "components/content_settings/core/browser/host_content_settings_map.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_delegate.h" 16 #include "content/public/browser/web_contents_delegate.h"
16 17
(...skipping 10 matching lines...) Expand all
27 } 28 }
28 29
29 ContentSetting PushMessagingPermissionContext::GetPermissionStatus( 30 ContentSetting PushMessagingPermissionContext::GetPermissionStatus(
30 const GURL& requesting_origin, 31 const GURL& requesting_origin,
31 const GURL& embedding_origin) const { 32 const GURL& embedding_origin) const {
32 #if defined(ENABLE_NOTIFICATIONS) 33 #if defined(ENABLE_NOTIFICATIONS)
33 if (requesting_origin != embedding_origin) 34 if (requesting_origin != embedding_origin)
34 return CONTENT_SETTING_BLOCK; 35 return CONTENT_SETTING_BLOCK;
35 36
36 ContentSetting push_content_setting = 37 ContentSetting push_content_setting =
37 profile_->GetHostContentSettingsMap()->GetContentSetting( 38 HostContentSettingsMapFactory::GetForProfile(profile_)->GetContentSetting(
38 requesting_origin, embedding_origin, kPushSettingType, std::string()); 39 requesting_origin, embedding_origin, kPushSettingType, std::string());
39 40
40 NotificationPermissionContext* notification_context = 41 NotificationPermissionContext* notification_context =
41 NotificationPermissionContextFactory::GetForProfile(profile_); 42 NotificationPermissionContextFactory::GetForProfile(profile_);
42 DCHECK(notification_context); 43 DCHECK(notification_context);
43 44
44 ContentSetting notifications_permission = 45 ContentSetting notifications_permission =
45 notification_context->GetPermissionStatus(requesting_origin, 46 notification_context->GetPermissionStatus(requesting_origin,
46 embedding_origin); 47 embedding_origin);
47 48
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 103 }
103 104
104 void PushMessagingPermissionContext::DecidePushPermission( 105 void PushMessagingPermissionContext::DecidePushPermission(
105 const PermissionRequestID& id, 106 const PermissionRequestID& id,
106 const GURL& requesting_origin, 107 const GURL& requesting_origin,
107 const GURL& embedding_origin, 108 const GURL& embedding_origin,
108 const BrowserPermissionCallback& callback, 109 const BrowserPermissionCallback& callback,
109 ContentSetting notification_content_setting) { 110 ContentSetting notification_content_setting) {
110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 111 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
111 ContentSetting push_content_setting = 112 ContentSetting push_content_setting =
112 profile_->GetHostContentSettingsMap() 113 HostContentSettingsMapFactory::GetForProfile(profile_)
113 ->GetContentSettingAndMaybeUpdateLastUsage( 114 ->GetContentSettingAndMaybeUpdateLastUsage(
114 requesting_origin, embedding_origin, kPushSettingType, 115 requesting_origin, embedding_origin, kPushSettingType,
115 std::string()); 116 std::string());
116 117
117 if (push_content_setting == CONTENT_SETTING_BLOCK) { 118 if (push_content_setting == CONTENT_SETTING_BLOCK) {
118 DVLOG(1) << "Push permission was explicitly blocked."; 119 DVLOG(1) << "Push permission was explicitly blocked.";
119 PermissionContextUmaUtil::PermissionDenied(kPushSettingType, 120 PermissionContextUmaUtil::PermissionDenied(kPushSettingType,
120 requesting_origin); 121 requesting_origin);
121 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 122 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
122 true /* persist */, CONTENT_SETTING_BLOCK); 123 true /* persist */, CONTENT_SETTING_BLOCK);
123 return; 124 return;
124 } 125 }
125 126
126 if (notification_content_setting != CONTENT_SETTING_ALLOW) { 127 if (notification_content_setting != CONTENT_SETTING_ALLOW) {
127 DVLOG(1) << "Notification permission has not been granted."; 128 DVLOG(1) << "Notification permission has not been granted.";
128 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 129 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
129 false /* persist */, notification_content_setting); 130 false /* persist */, notification_content_setting);
130 return; 131 return;
131 } 132 }
132 133
133 PermissionContextUmaUtil::PermissionGranted(kPushSettingType, 134 PermissionContextUmaUtil::PermissionGranted(kPushSettingType,
134 requesting_origin); 135 requesting_origin);
135 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 136 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
136 true /* persist */, CONTENT_SETTING_ALLOW); 137 true /* persist */, CONTENT_SETTING_ALLOW);
137 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698