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

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: Fix bad merge 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
298 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 299 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
299 content_setting == CONTENT_SETTING_BLOCK || 300 content_setting == CONTENT_SETTING_BLOCK ||
300 content_setting == CONTENT_SETTING_DEFAULT); 301 content_setting == CONTENT_SETTING_DEFAULT);
301 if (content_setting == CONTENT_SETTING_ALLOW) { 302 if (content_setting == CONTENT_SETTING_ALLOW) {
302 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, 303 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type,
303 requesting_origin, profile_); 304 requesting_origin, profile_);
305 PermissionUmaUtil::RecordPermissionEmbargoStatus(
306 PermissionEmbargoStatus::NOT_EMBARGOED);
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_);
310 PermissionUmaUtil::RecordPermissionEmbargoStatus(
311 PermissionEmbargoStatus::NOT_EMBARGOED);
307 } else { 312 } else {
308 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, 313 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type,
309 requesting_origin, profile_); 314 requesting_origin, profile_);
315
316 if (PermissionDecisionAutoBlocker::GetForProfile(profile_)
317 ->RecordDismissAndEmbargo(requesting_origin, permission_type_)) {
318 PermissionUmaUtil::RecordPermissionEmbargoStatus(
319 PermissionEmbargoStatus::REPEATED_DISMISSALS);
320 } else {
321 PermissionUmaUtil::RecordPermissionEmbargoStatus(
322 PermissionEmbargoStatus::NOT_EMBARGOED);
323 }
310 } 324 }
rkaplow 2017/02/13 18:16:21 this looks like this might be simpler if you just
dominickn 2017/02/14 01:55:08 Done, thanks
311 } 325 }
312 326
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
321 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 327 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
322 persist, content_setting); 328 persist, content_setting);
323 } 329 }
324 330
325 #if defined(OS_ANDROID) 331 #if defined(OS_ANDROID)
326 PermissionQueueController* PermissionContextBase::GetQueueController() { 332 PermissionQueueController* PermissionContextBase::GetQueueController() {
327 return permission_queue_controller_.get(); 333 return permission_queue_controller_.get();
328 } 334 }
329 #endif 335 #endif
330 336
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 373 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
368 content_setting == CONTENT_SETTING_BLOCK); 374 content_setting == CONTENT_SETTING_BLOCK);
369 DCHECK(!requesting_origin.SchemeIsFile()); 375 DCHECK(!requesting_origin.SchemeIsFile());
370 DCHECK(!embedding_origin.SchemeIsFile()); 376 DCHECK(!embedding_origin.SchemeIsFile());
371 377
372 HostContentSettingsMapFactory::GetForProfile(profile_) 378 HostContentSettingsMapFactory::GetForProfile(profile_)
373 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, 379 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin,
374 content_settings_type_, std::string(), 380 content_settings_type_, std::string(),
375 content_setting); 381 content_setting);
376 } 382 }
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