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

Side by Side Diff: chrome/browser/permissions/permission_context_base.cc

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: rebase + include content_settings_types.h more Created 3 years, 10 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/permissions/permission_context_base.h" 5 #include "chrome/browser/permissions/permission_context_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/permissions/permission_request_id.h" 22 #include "chrome/browser/permissions/permission_request_id.h"
23 #include "chrome/browser/permissions/permission_request_impl.h" 23 #include "chrome/browser/permissions/permission_request_impl.h"
24 #include "chrome/browser/permissions/permission_request_manager.h" 24 #include "chrome/browser/permissions/permission_request_manager.h"
25 #include "chrome/browser/permissions/permission_uma_util.h" 25 #include "chrome/browser/permissions/permission_uma_util.h"
26 #include "chrome/browser/permissions/permission_util.h" 26 #include "chrome/browser/permissions/permission_util.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 28 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
29 #include "chrome/common/chrome_features.h" 29 #include "chrome/common/chrome_features.h"
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "components/content_settings/core/browser/host_content_settings_map.h" 31 #include "components/content_settings/core/browser/host_content_settings_map.h"
32 #include "components/content_settings/core/browser/website_settings_registry.h"
33 #include "components/prefs/pref_service.h" 32 #include "components/prefs/pref_service.h"
34 #include "components/safe_browsing_db/database_manager.h" 33 #include "components/safe_browsing_db/database_manager.h"
35 #include "components/variations/variations_associated_data.h" 34 #include "components/variations/variations_associated_data.h"
36 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/render_frame_host.h" 36 #include "content/public/browser/render_frame_host.h"
38 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
39 #include "content/public/common/origin_util.h" 38 #include "content/public/common/origin_util.h"
40 #include "url/gurl.h" 39 #include "url/gurl.h"
41 40
42 #if defined(OS_ANDROID) 41 #if defined(OS_ANDROID)
43 #include "chrome/browser/permissions/permission_queue_controller.h" 42 #include "chrome/browser/permissions/permission_queue_controller.h"
44 #endif 43 #endif
45 44
46 // static 45 // static
47 const char PermissionContextBase::kPermissionsKillSwitchFieldStudy[] = 46 const char PermissionContextBase::kPermissionsKillSwitchFieldStudy[] =
48 "PermissionsKillSwitch"; 47 "PermissionsKillSwitch";
49 // static 48 // static
50 const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] = 49 const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] =
51 "blocked"; 50 "blocked";
52 51
53 PermissionResult::PermissionResult(ContentSetting cs, 52 PermissionResult::PermissionResult(ContentSetting cs,
54 PermissionStatusSource pss) 53 PermissionStatusSource pss)
55 : content_setting(cs), source(pss) {} 54 : content_setting(cs), source(pss) {}
56 55
57 PermissionResult::~PermissionResult() {} 56 PermissionResult::~PermissionResult() {}
58 57
59 PermissionContextBase::PermissionContextBase( 58 PermissionContextBase::PermissionContextBase(
60 Profile* profile, 59 Profile* profile,
61 const content::PermissionType permission_type,
62 const ContentSettingsType content_settings_type) 60 const ContentSettingsType content_settings_type)
63 : profile_(profile), 61 : profile_(profile),
64 permission_type_(permission_type),
65 content_settings_type_(content_settings_type), 62 content_settings_type_(content_settings_type),
66 weak_factory_(this) { 63 weak_factory_(this) {
67 #if defined(OS_ANDROID) 64 #if defined(OS_ANDROID)
68 permission_queue_controller_.reset(new PermissionQueueController( 65 permission_queue_controller_.reset(
69 profile_, permission_type_, content_settings_type_)); 66 new PermissionQueueController(profile_, content_settings_type_));
70 #endif 67 #endif
71 PermissionDecisionAutoBlocker::UpdateFromVariations(); 68 PermissionDecisionAutoBlocker::UpdateFromVariations();
72 } 69 }
73 70
74 PermissionContextBase::~PermissionContextBase() { 71 PermissionContextBase::~PermissionContextBase() {
75 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 72 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
76 } 73 }
77 74
78 void PermissionContextBase::RequestPermission( 75 void PermissionContextBase::RequestPermission(
79 content::WebContents* web_contents, 76 content::WebContents* web_contents,
80 const PermissionRequestID& id, 77 const PermissionRequestID& id,
81 const GURL& requesting_frame, 78 const GURL& requesting_frame,
82 bool user_gesture, 79 bool user_gesture,
83 const BrowserPermissionCallback& callback) { 80 const BrowserPermissionCallback& callback) {
84 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 81 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
85 82
86 // First check if this permission has been disabled. 83 // First check if this permission has been disabled.
87 if (IsPermissionKillSwitchOn()) { 84 if (IsPermissionKillSwitchOn()) {
88 // Log to the developer console. 85 // Log to the developer console.
89 web_contents->GetMainFrame()->AddMessageToConsole( 86 web_contents->GetMainFrame()->AddMessageToConsole(
90 content::CONSOLE_MESSAGE_LEVEL_INFO, 87 content::CONSOLE_MESSAGE_LEVEL_INFO,
91 base::StringPrintf( 88 base::StringPrintf(
92 "%s permission has been blocked.", 89 "%s permission has been blocked.",
93 PermissionUtil::GetPermissionString(permission_type_).c_str())); 90 PermissionUtil::GetPermissionString(content_settings_type_)
91 .c_str()));
94 // The kill switch is enabled for this permission; Block all requests. 92 // The kill switch is enabled for this permission; Block all requests.
95 callback.Run(CONTENT_SETTING_BLOCK); 93 callback.Run(CONTENT_SETTING_BLOCK);
96 return; 94 return;
97 } 95 }
98 96
99 GURL requesting_origin = requesting_frame.GetOrigin(); 97 GURL requesting_origin = requesting_frame.GetOrigin();
100 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); 98 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin();
101 99
102 if (!requesting_origin.is_valid() || !embedding_origin.is_valid()) { 100 if (!requesting_origin.is_valid() || !embedding_origin.is_valid()) {
103 std::string type_name = 101 std::string type_name =
104 content_settings::WebsiteSettingsRegistry::GetInstance() 102 PermissionUtil::GetPermissionString(content_settings_type_);
105 ->Get(content_settings_type_)
106 ->name();
107 103
108 DVLOG(1) << "Attempt to use " << type_name 104 DVLOG(1) << "Attempt to use " << type_name
109 << " from an invalid URL: " << requesting_origin << "," 105 << " from an invalid URL: " << requesting_origin << ","
110 << embedding_origin << " (" << type_name 106 << embedding_origin << " (" << type_name
111 << " is not supported in popups)"; 107 << " is not supported in popups)";
112 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 108 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
113 false /* persist */, CONTENT_SETTING_BLOCK); 109 false /* persist */, CONTENT_SETTING_BLOCK);
114 return; 110 return;
115 } 111 }
116 112
117 // Synchronously check the content setting to see if the user has already made 113 // Synchronously check the content setting to see if the user has already made
118 // a decision, or if the origin is under embargo. If so, respect that 114 // a decision, or if the origin is under embargo. If so, respect that
119 // decision. 115 // decision.
120 PermissionResult result = 116 PermissionResult result =
121 GetPermissionStatus(requesting_origin, embedding_origin); 117 GetPermissionStatus(requesting_origin, embedding_origin);
122 if (result.content_setting == CONTENT_SETTING_ALLOW) { 118 if (result.content_setting == CONTENT_SETTING_ALLOW) {
123 HostContentSettingsMapFactory::GetForProfile(profile_)->UpdateLastUsage( 119 HostContentSettingsMapFactory::GetForProfile(profile_)->UpdateLastUsage(
124 requesting_origin, embedding_origin, content_settings_type_); 120 requesting_origin, embedding_origin, content_settings_storage_type());
125 } 121 }
126 122
127 if (result.content_setting == CONTENT_SETTING_ALLOW || 123 if (result.content_setting == CONTENT_SETTING_ALLOW ||
128 result.content_setting == CONTENT_SETTING_BLOCK) { 124 result.content_setting == CONTENT_SETTING_BLOCK) {
129 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 125 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
130 false /* persist */, result.content_setting); 126 false /* persist */, result.content_setting);
131 return; 127 return;
132 } 128 }
133 129
134 // Asynchronously check whether the origin should be blocked from making this 130 // Asynchronously check whether the origin should be blocked from making this
135 // permission request. It may be on the Safe Browsing API blacklist, or it may 131 // permission request. It may be on the Safe Browsing API blacklist, or it may
136 // have been dismissed too many times in a row. If the origin is allowed to 132 // have been dismissed too many times in a row. If the origin is allowed to
137 // request, that request will be made to ContinueRequestPermission(). 133 // request, that request will be made to ContinueRequestPermission().
138 PermissionDecisionAutoBlocker::GetForProfile(profile_)->UpdateEmbargoedStatus( 134 PermissionDecisionAutoBlocker::GetForProfile(profile_)->UpdateEmbargoedStatus(
139 permission_type_, requesting_origin, web_contents, 135 content_settings_type_, requesting_origin, web_contents,
140 base::Bind(&PermissionContextBase::ContinueRequestPermission, 136 base::Bind(&PermissionContextBase::ContinueRequestPermission,
141 weak_factory_.GetWeakPtr(), web_contents, id, 137 weak_factory_.GetWeakPtr(), web_contents, id,
142 requesting_origin, embedding_origin, user_gesture, callback)); 138 requesting_origin, embedding_origin, user_gesture, callback));
143 } 139 }
144 140
145 void PermissionContextBase::ContinueRequestPermission( 141 void PermissionContextBase::ContinueRequestPermission(
146 content::WebContents* web_contents, 142 content::WebContents* web_contents,
147 const PermissionRequestID& id, 143 const PermissionRequestID& id,
148 const GURL& requesting_origin, 144 const GURL& requesting_origin,
149 const GURL& embedding_origin, 145 const GURL& embedding_origin,
150 bool user_gesture, 146 bool user_gesture,
151 const BrowserPermissionCallback& callback, 147 const BrowserPermissionCallback& callback,
152 bool permission_blocked) { 148 bool permission_blocked) {
153 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
154 if (permission_blocked) { 150 if (permission_blocked) {
155 web_contents->GetMainFrame()->AddMessageToConsole( 151 web_contents->GetMainFrame()->AddMessageToConsole(
156 content::CONSOLE_MESSAGE_LEVEL_INFO, 152 content::CONSOLE_MESSAGE_LEVEL_INFO,
157 base::StringPrintf( 153 base::StringPrintf(
158 "%s permission has been auto-blocked.", 154 "%s permission has been auto-blocked.",
159 PermissionUtil::GetPermissionString(permission_type_).c_str())); 155 PermissionUtil::GetPermissionString(content_settings_type_)
156 .c_str()));
160 // Permission has been automatically blocked. 157 // Permission has been automatically blocked.
161 PermissionUmaUtil::RecordPermissionEmbargoStatus( 158 PermissionUmaUtil::RecordPermissionEmbargoStatus(
162 PermissionEmbargoStatus::PERMISSIONS_BLACKLISTING); 159 PermissionEmbargoStatus::PERMISSIONS_BLACKLISTING);
163 callback.Run(CONTENT_SETTING_BLOCK); 160 callback.Run(CONTENT_SETTING_BLOCK);
164 return; 161 return;
165 } 162 }
166 163
167 PermissionUmaUtil::PermissionRequested(permission_type_, requesting_origin, 164 PermissionUmaUtil::PermissionRequested(
168 embedding_origin, profile_); 165 content_settings_type_, requesting_origin, embedding_origin, profile_);
169 166
170 DecidePermission(web_contents, id, requesting_origin, embedding_origin, 167 DecidePermission(web_contents, id, requesting_origin, embedding_origin,
171 user_gesture, callback); 168 user_gesture, callback);
172 } 169 }
173 170
174 PermissionResult PermissionContextBase::GetPermissionStatus( 171 PermissionResult PermissionContextBase::GetPermissionStatus(
175 const GURL& requesting_origin, 172 const GURL& requesting_origin,
176 const GURL& embedding_origin) const { 173 const GURL& embedding_origin) const {
177 // TODO(raymes): Ensure we return appropriate decision reasons in the 174 // TODO(raymes): Ensure we return appropriate decision reasons in the
178 // PermissionResult. We should add these as each is needed. 175 // PermissionResult. We should add these as each is needed.
179 176
180 // If the permission has been disabled through Finch, block all requests. 177 // If the permission has been disabled through Finch, block all requests.
181 if (IsPermissionKillSwitchOn()) { 178 if (IsPermissionKillSwitchOn()) {
182 return PermissionResult(CONTENT_SETTING_BLOCK, 179 return PermissionResult(CONTENT_SETTING_BLOCK,
183 PermissionStatusSource::UNSPECIFIED); 180 PermissionStatusSource::UNSPECIFIED);
184 } 181 }
185 182
186 if (IsRestrictedToSecureOrigins() && 183 if (IsRestrictedToSecureOrigins() &&
187 !content::IsOriginSecure(requesting_origin)) { 184 !content::IsOriginSecure(requesting_origin)) {
188 return PermissionResult(CONTENT_SETTING_BLOCK, 185 return PermissionResult(CONTENT_SETTING_BLOCK,
189 PermissionStatusSource::UNSPECIFIED); 186 PermissionStatusSource::UNSPECIFIED);
190 } 187 }
191 188
192 ContentSetting content_setting = 189 ContentSetting content_setting =
193 GetPermissionStatusInternal(requesting_origin, embedding_origin); 190 GetPermissionStatusInternal(requesting_origin, embedding_origin);
194 if (content_setting == CONTENT_SETTING_ASK && 191 if (content_setting == CONTENT_SETTING_ASK &&
195 PermissionDecisionAutoBlocker::GetForProfile(profile_)->IsUnderEmbargo( 192 PermissionDecisionAutoBlocker::GetForProfile(profile_)->IsUnderEmbargo(
196 permission_type_, requesting_origin)) { 193 content_settings_type_, requesting_origin)) {
197 return PermissionResult(CONTENT_SETTING_BLOCK, 194 return PermissionResult(CONTENT_SETTING_BLOCK,
198 PermissionStatusSource::UNSPECIFIED); 195 PermissionStatusSource::UNSPECIFIED);
199 } 196 }
200 197
201 return PermissionResult(content_setting, PermissionStatusSource::UNSPECIFIED); 198 return PermissionResult(content_setting, PermissionStatusSource::UNSPECIFIED);
202 } 199 }
203 200
204 void PermissionContextBase::ResetPermission( 201 void PermissionContextBase::ResetPermission(
205 const GURL& requesting_origin, 202 const GURL& requesting_origin,
206 const GURL& embedding_origin) { 203 const GURL& embedding_origin) {
207 HostContentSettingsMapFactory::GetForProfile(profile_) 204 HostContentSettingsMapFactory::GetForProfile(profile_)
208 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, 205 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin,
209 content_settings_type_, std::string(), 206 content_settings_storage_type(),
210 CONTENT_SETTING_DEFAULT); 207 std::string(), CONTENT_SETTING_DEFAULT);
211 } 208 }
212 209
213 void PermissionContextBase::CancelPermissionRequest( 210 void PermissionContextBase::CancelPermissionRequest(
214 content::WebContents* web_contents, 211 content::WebContents* web_contents,
215 const PermissionRequestID& id) { 212 const PermissionRequestID& id) {
216 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
217 214
218 if (PermissionRequestManager::IsEnabled()) { 215 if (PermissionRequestManager::IsEnabled()) {
219 auto it = pending_requests_.find(id.ToString()); 216 auto it = pending_requests_.find(id.ToString());
220 if (it != pending_requests_.end() && web_contents != nullptr && 217 if (it != pending_requests_.end() && web_contents != nullptr &&
221 PermissionRequestManager::FromWebContents(web_contents) != nullptr) { 218 PermissionRequestManager::FromWebContents(web_contents) != nullptr) {
222 PermissionRequestManager::FromWebContents(web_contents) 219 PermissionRequestManager::FromWebContents(web_contents)
223 ->CancelRequest(it->second.get()); 220 ->CancelRequest(it->second.get());
224 } 221 }
225 } else { 222 } else {
226 #if defined(OS_ANDROID) 223 #if defined(OS_ANDROID)
227 GetQueueController()->CancelInfoBarRequest(id); 224 GetQueueController()->CancelInfoBarRequest(id);
228 #else 225 #else
229 NOTREACHED(); 226 NOTREACHED();
230 #endif 227 #endif
231 } 228 }
232 } 229 }
233 230
234 bool PermissionContextBase::IsPermissionKillSwitchOn() const { 231 bool PermissionContextBase::IsPermissionKillSwitchOn() const {
235 const std::string param = variations::GetVariationParamValue( 232 const std::string param = variations::GetVariationParamValue(
236 kPermissionsKillSwitchFieldStudy, 233 kPermissionsKillSwitchFieldStudy,
237 PermissionUtil::GetPermissionString(permission_type_)); 234 PermissionUtil::GetPermissionString(content_settings_type_));
238 235
239 return param == kPermissionsKillSwitchBlockedValue; 236 return param == kPermissionsKillSwitchBlockedValue;
240 } 237 }
241 238
242 ContentSetting PermissionContextBase::GetPermissionStatusInternal( 239 ContentSetting PermissionContextBase::GetPermissionStatusInternal(
243 const GURL& requesting_origin, 240 const GURL& requesting_origin,
244 const GURL& embedding_origin) const { 241 const GURL& embedding_origin) const {
245 return HostContentSettingsMapFactory::GetForProfile(profile_) 242 return HostContentSettingsMapFactory::GetForProfile(profile_)
246 ->GetContentSetting(requesting_origin, embedding_origin, 243 ->GetContentSetting(requesting_origin, embedding_origin,
247 content_settings_type_, std::string()); 244 content_settings_storage_type(), std::string());
248 } 245 }
249 246
250 void PermissionContextBase::DecidePermission( 247 void PermissionContextBase::DecidePermission(
251 content::WebContents* web_contents, 248 content::WebContents* web_contents,
252 const PermissionRequestID& id, 249 const PermissionRequestID& id,
253 const GURL& requesting_origin, 250 const GURL& requesting_origin,
254 const GURL& embedding_origin, 251 const GURL& embedding_origin,
255 bool user_gesture, 252 bool user_gesture,
256 const BrowserPermissionCallback& callback) { 253 const BrowserPermissionCallback& callback) {
257 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 254 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
258 255
259 if (PermissionRequestManager::IsEnabled()) { 256 if (PermissionRequestManager::IsEnabled()) {
260 PermissionRequestManager* permission_request_manager = 257 PermissionRequestManager* permission_request_manager =
261 PermissionRequestManager::FromWebContents(web_contents); 258 PermissionRequestManager::FromWebContents(web_contents);
262 // TODO(felt): sometimes |permission_request_manager| is null. This check is 259 // TODO(felt): sometimes |permission_request_manager| is null. This check is
263 // meant to prevent crashes. See crbug.com/457091. 260 // meant to prevent crashes. See crbug.com/457091.
264 if (!permission_request_manager) 261 if (!permission_request_manager)
265 return; 262 return;
266 263
267 std::unique_ptr<PermissionRequest> request_ptr = 264 std::unique_ptr<PermissionRequest> request_ptr =
268 base::MakeUnique<PermissionRequestImpl>( 265 base::MakeUnique<PermissionRequestImpl>(
269 requesting_origin, permission_type_, profile_, user_gesture, 266 requesting_origin, content_settings_type_, profile_, user_gesture,
270 base::Bind(&PermissionContextBase::PermissionDecided, 267 base::Bind(&PermissionContextBase::PermissionDecided,
271 weak_factory_.GetWeakPtr(), id, requesting_origin, 268 weak_factory_.GetWeakPtr(), id, requesting_origin,
272 embedding_origin, user_gesture, callback), 269 embedding_origin, user_gesture, callback),
273 base::Bind(&PermissionContextBase::CleanUpRequest, 270 base::Bind(&PermissionContextBase::CleanUpRequest,
274 weak_factory_.GetWeakPtr(), id)); 271 weak_factory_.GetWeakPtr(), id));
275 PermissionRequest* request = request_ptr.get(); 272 PermissionRequest* request = request_ptr.get();
276 273
277 bool inserted = 274 bool inserted =
278 pending_requests_ 275 pending_requests_
279 .insert(std::make_pair(id.ToString(), std::move(request_ptr))) 276 .insert(std::make_pair(id.ToString(), std::move(request_ptr)))
(...skipping 29 matching lines...) Expand all
309 // controller directly. 306 // controller directly.
310 PermissionRequestGestureType gesture_type = 307 PermissionRequestGestureType gesture_type =
311 user_gesture ? PermissionRequestGestureType::GESTURE 308 user_gesture ? PermissionRequestGestureType::GESTURE
312 : PermissionRequestGestureType::NO_GESTURE; 309 : PermissionRequestGestureType::NO_GESTURE;
313 PermissionEmbargoStatus embargo_status = 310 PermissionEmbargoStatus embargo_status =
314 PermissionEmbargoStatus::NOT_EMBARGOED; 311 PermissionEmbargoStatus::NOT_EMBARGOED;
315 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 312 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
316 content_setting == CONTENT_SETTING_BLOCK || 313 content_setting == CONTENT_SETTING_BLOCK ||
317 content_setting == CONTENT_SETTING_DEFAULT); 314 content_setting == CONTENT_SETTING_DEFAULT);
318 if (content_setting == CONTENT_SETTING_ALLOW) { 315 if (content_setting == CONTENT_SETTING_ALLOW) {
319 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, 316 PermissionUmaUtil::PermissionGranted(content_settings_type_, gesture_type,
320 requesting_origin, profile_); 317 requesting_origin, profile_);
321 } else if (content_setting == CONTENT_SETTING_BLOCK) { 318 } else if (content_setting == CONTENT_SETTING_BLOCK) {
322 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, 319 PermissionUmaUtil::PermissionDenied(content_settings_type_, gesture_type,
323 requesting_origin, profile_); 320 requesting_origin, profile_);
324 } else { 321 } else {
325 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, 322 PermissionUmaUtil::PermissionDismissed(
326 requesting_origin, profile_); 323 content_settings_type_, gesture_type, requesting_origin, profile_);
327 324
328 if (PermissionDecisionAutoBlocker::GetForProfile(profile_) 325 if (PermissionDecisionAutoBlocker::GetForProfile(profile_)
329 ->RecordDismissAndEmbargo(requesting_origin, permission_type_)) { 326 ->RecordDismissAndEmbargo(requesting_origin,
327 content_settings_type_)) {
330 embargo_status = PermissionEmbargoStatus::REPEATED_DISMISSALS; 328 embargo_status = PermissionEmbargoStatus::REPEATED_DISMISSALS;
331 } 329 }
332 } 330 }
333 PermissionUmaUtil::RecordPermissionEmbargoStatus(embargo_status); 331 PermissionUmaUtil::RecordPermissionEmbargoStatus(embargo_status);
334 } 332 }
335 333
336 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 334 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
337 persist, content_setting); 335 persist, content_setting);
338 } 336 }
339 337
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 ContentSetting content_setting) { 377 ContentSetting content_setting) {
380 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); 378 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin());
381 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); 379 DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin());
382 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 380 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
383 content_setting == CONTENT_SETTING_BLOCK); 381 content_setting == CONTENT_SETTING_BLOCK);
384 DCHECK(!requesting_origin.SchemeIsFile()); 382 DCHECK(!requesting_origin.SchemeIsFile());
385 DCHECK(!embedding_origin.SchemeIsFile()); 383 DCHECK(!embedding_origin.SchemeIsFile());
386 384
387 HostContentSettingsMapFactory::GetForProfile(profile_) 385 HostContentSettingsMapFactory::GetForProfile(profile_)
388 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, 386 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin,
389 content_settings_type_, std::string(), 387 content_settings_storage_type(),
390 content_setting); 388 std::string(), content_setting);
391 } 389 }
390
391 ContentSettingsType PermissionContextBase::content_settings_storage_type()
392 const {
393 if (content_settings_type_ == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING)
394 return CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
395 return content_settings_type_;
396 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_context_base.h ('k') | chrome/browser/permissions/permission_context_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698