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

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

Issue 2690543004: Add UMA for recording embargo reasons and autoblocker interactions. (Closed)
Patch Set: Address comment 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
« no previous file with comments | « no previous file | chrome/browser/permissions/permission_context_base_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 void PermissionContextBase::ContinueRequestPermission( 139 void PermissionContextBase::ContinueRequestPermission(
140 content::WebContents* web_contents, 140 content::WebContents* web_contents,
141 const PermissionRequestID& id, 141 const PermissionRequestID& id,
142 const GURL& requesting_origin, 142 const GURL& requesting_origin,
143 const GURL& embedding_origin, 143 const GURL& embedding_origin,
144 bool user_gesture, 144 bool user_gesture,
145 const BrowserPermissionCallback& callback, 145 const BrowserPermissionCallback& callback,
146 bool permission_blocked) { 146 bool permission_blocked) {
147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
148 if (permission_blocked) { 148 if (permission_blocked) {
149 // TODO(meredithl): Add UMA metrics here.
150 web_contents->GetMainFrame()->AddMessageToConsole( 149 web_contents->GetMainFrame()->AddMessageToConsole(
151 content::CONSOLE_MESSAGE_LEVEL_INFO, 150 content::CONSOLE_MESSAGE_LEVEL_INFO,
152 base::StringPrintf( 151 base::StringPrintf(
153 "%s permission has been auto-blocked.", 152 "%s permission has been auto-blocked.",
154 PermissionUtil::GetPermissionString(permission_type_).c_str())); 153 PermissionUtil::GetPermissionString(permission_type_).c_str()));
155 // Permission has been automatically blocked. 154 // Permission has been automatically blocked.
155 PermissionUmaUtil::RecordPermissionEmbargoStatus(
156 PermissionEmbargoStatus::PERMISSIONS_BLACKLISTING);
156 callback.Run(CONTENT_SETTING_BLOCK); 157 callback.Run(CONTENT_SETTING_BLOCK);
157 return; 158 return;
158 } 159 }
159 160
160 PermissionUmaUtil::PermissionRequested(permission_type_, requesting_origin, 161 PermissionUmaUtil::PermissionRequested(permission_type_, requesting_origin,
161 embedding_origin, profile_); 162 embedding_origin, profile_);
162 163
163 DecidePermission(web_contents, id, requesting_origin, embedding_origin, 164 DecidePermission(web_contents, id, requesting_origin, embedding_origin,
164 user_gesture, callback); 165 user_gesture, callback);
165 } 166 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 bool user_gesture, 289 bool user_gesture,
289 const BrowserPermissionCallback& callback, 290 const BrowserPermissionCallback& callback,
290 bool persist, 291 bool persist,
291 ContentSetting content_setting) { 292 ContentSetting content_setting) {
292 if (PermissionRequestManager::IsEnabled()) { 293 if (PermissionRequestManager::IsEnabled()) {
293 // Infobar persistence and its related UMA is tracked on the infobar 294 // Infobar persistence and its related UMA is tracked on the infobar
294 // controller directly. 295 // controller directly.
295 PermissionRequestGestureType gesture_type = 296 PermissionRequestGestureType gesture_type =
296 user_gesture ? PermissionRequestGestureType::GESTURE 297 user_gesture ? PermissionRequestGestureType::GESTURE
297 : PermissionRequestGestureType::NO_GESTURE; 298 : PermissionRequestGestureType::NO_GESTURE;
299 PermissionEmbargoStatus embargo_status =
300 PermissionEmbargoStatus::NOT_EMBARGOED;
298 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 301 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
299 content_setting == CONTENT_SETTING_BLOCK || 302 content_setting == CONTENT_SETTING_BLOCK ||
300 content_setting == CONTENT_SETTING_DEFAULT); 303 content_setting == CONTENT_SETTING_DEFAULT);
301 if (content_setting == CONTENT_SETTING_ALLOW) { 304 if (content_setting == CONTENT_SETTING_ALLOW) {
302 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, 305 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type,
303 requesting_origin, profile_); 306 requesting_origin, profile_);
304 } else if (content_setting == CONTENT_SETTING_BLOCK) { 307 } else if (content_setting == CONTENT_SETTING_BLOCK) {
305 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, 308 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type,
306 requesting_origin, profile_); 309 requesting_origin, profile_);
307 } else { 310 } else {
308 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, 311 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type,
309 requesting_origin, profile_); 312 requesting_origin, profile_);
313
314 if (PermissionDecisionAutoBlocker::GetForProfile(profile_)
315 ->RecordDismissAndEmbargo(requesting_origin, permission_type_)) {
316 embargo_status = PermissionEmbargoStatus::REPEATED_DISMISSALS;
317 }
310 } 318 }
311 } 319 PermissionUmaUtil::RecordPermissionEmbargoStatus(embargo_status);
312
313 if (content_setting == CONTENT_SETTING_DEFAULT &&
314 PermissionDecisionAutoBlocker::GetForProfile(profile_)
315 ->RecordDismissAndEmbargo(requesting_origin, permission_type_)) {
316 // The permission has been embargoed, so it is blocked for this permission
317 // request, but not persisted.
318 content_setting = CONTENT_SETTING_BLOCK;
319 } 320 }
320 321
321 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 322 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
322 persist, content_setting); 323 persist, content_setting);
323 } 324 }
324 325
325 #if defined(OS_ANDROID) 326 #if defined(OS_ANDROID)
326 PermissionQueueController* PermissionContextBase::GetQueueController() { 327 PermissionQueueController* PermissionContextBase::GetQueueController() {
327 return permission_queue_controller_.get(); 328 return permission_queue_controller_.get();
328 } 329 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 368 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
368 content_setting == CONTENT_SETTING_BLOCK); 369 content_setting == CONTENT_SETTING_BLOCK);
369 DCHECK(!requesting_origin.SchemeIsFile()); 370 DCHECK(!requesting_origin.SchemeIsFile());
370 DCHECK(!embedding_origin.SchemeIsFile()); 371 DCHECK(!embedding_origin.SchemeIsFile());
371 372
372 HostContentSettingsMapFactory::GetForProfile(profile_) 373 HostContentSettingsMapFactory::GetForProfile(profile_)
373 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, 374 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin,
374 content_settings_type_, std::string(), 375 content_settings_type_, std::string(),
375 content_setting); 376 content_setting);
376 } 377 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/permissions/permission_context_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698