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

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

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: rebase 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_uma_util.h" 5 #include "chrome/browser/permissions/permission_uma_util.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 PERMISSION_BUBBLE_TYPE_UMA(gesture_metric_name, permission_bubble_type); \ 56 PERMISSION_BUBBLE_TYPE_UMA(gesture_metric_name, permission_bubble_type); \
57 } else if (gesture_type == PermissionRequestGestureType::NO_GESTURE) { \ 57 } else if (gesture_type == PermissionRequestGestureType::NO_GESTURE) { \
58 PERMISSION_BUBBLE_TYPE_UMA(no_gesture_metric_name, \ 58 PERMISSION_BUBBLE_TYPE_UMA(no_gesture_metric_name, \
59 permission_bubble_type); \ 59 permission_bubble_type); \
60 } 60 }
61 61
62 using content::PermissionType; 62 using content::PermissionType;
63 63
64 namespace { 64 namespace {
65 65
66 const std::string GetRapporMetric(PermissionType permission, 66 const std::string GetRapporMetric(ContentSettingsType permission,
67 PermissionAction action) { 67 PermissionAction action) {
68 std::string action_str; 68 std::string action_str;
69 switch (action) { 69 switch (action) {
70 case GRANTED: 70 case GRANTED:
71 action_str = "Granted"; 71 action_str = "Granted";
72 break; 72 break;
73 case DENIED: 73 case DENIED:
74 action_str = "Denied"; 74 action_str = "Denied";
75 break; 75 break;
76 case DISMISSED: 76 case DISMISSED:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 static_cast<base::HistogramBase::Sample>(permission), 181 static_cast<base::HistogramBase::Sample>(permission),
182 static_cast<base::HistogramBase::Sample>(PermissionType::NUM)); 182 static_cast<base::HistogramBase::Sample>(PermissionType::NUM));
183 } 183 }
184 } 184 }
185 185
186 } // anonymous namespace 186 } // anonymous namespace
187 187
188 // PermissionReportInfo ------------------------------------------------------- 188 // PermissionReportInfo -------------------------------------------------------
189 PermissionReportInfo::PermissionReportInfo( 189 PermissionReportInfo::PermissionReportInfo(
190 const GURL& origin, 190 const GURL& origin,
191 PermissionType permission, 191 ContentSettingsType permission,
192 PermissionAction action, 192 PermissionAction action,
193 PermissionSourceUI source_ui, 193 PermissionSourceUI source_ui,
194 PermissionRequestGestureType gesture_type, 194 PermissionRequestGestureType gesture_type,
195 PermissionPersistDecision persist_decision, 195 PermissionPersistDecision persist_decision,
196 int num_prior_dismissals, 196 int num_prior_dismissals,
197 int num_prior_ignores) 197 int num_prior_ignores)
198 : origin(origin), permission(permission), action(action), 198 : origin(origin), permission(permission), action(action),
199 source_ui(source_ui), gesture_type(gesture_type), 199 source_ui(source_ui), gesture_type(gesture_type),
200 persist_decision(persist_decision), 200 persist_decision(persist_decision),
201 num_prior_dismissals(num_prior_dismissals), 201 num_prior_dismissals(num_prior_dismissals),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Make sure you update histograms.xml permission histogram_suffix if you 260 // Make sure you update histograms.xml permission histogram_suffix if you
261 // add new permission 261 // add new permission
262 void PermissionUmaUtil::PermissionRequested(PermissionType permission, 262 void PermissionUmaUtil::PermissionRequested(PermissionType permission,
263 const GURL& requesting_origin, 263 const GURL& requesting_origin,
264 const GURL& embedding_origin, 264 const GURL& embedding_origin,
265 Profile* profile) { 265 Profile* profile) {
266 RecordPermissionRequest(permission, requesting_origin, embedding_origin, 266 RecordPermissionRequest(permission, requesting_origin, embedding_origin,
267 profile); 267 profile);
268 } 268 }
269 269
270 void PermissionUmaUtil::PermissionRequested(ContentSettingsType content_type,
271 const GURL& requesting_origin,
272 const GURL& embedding_origin,
273 Profile* profile) {
274 PermissionType permission;
275 bool success = PermissionUtil::GetPermissionType(content_type, &permission);
276 DCHECK(success);
277 RecordPermissionRequest(permission, requesting_origin, embedding_origin,
278 profile);
279 }
280
270 void PermissionUmaUtil::PermissionGranted( 281 void PermissionUmaUtil::PermissionGranted(
271 PermissionType permission, 282 ContentSettingsType permission,
272 PermissionRequestGestureType gesture_type, 283 PermissionRequestGestureType gesture_type,
273 const GURL& requesting_origin, 284 const GURL& requesting_origin,
274 Profile* profile) { 285 Profile* profile) {
275 PermissionDecisionAutoBlocker* autoblocker = 286 PermissionDecisionAutoBlocker* autoblocker =
276 PermissionDecisionAutoBlocker::GetForProfile(profile); 287 PermissionDecisionAutoBlocker::GetForProfile(profile);
277 RecordPermissionAction(permission, GRANTED, PermissionSourceUI::PROMPT, 288 RecordPermissionAction(permission, GRANTED, PermissionSourceUI::PROMPT,
278 gesture_type, requesting_origin, profile); 289 gesture_type, requesting_origin, profile);
279 RecordPermissionPromptPriorCount( 290 RecordPermissionPromptPriorCount(
280 permission, kPermissionsPromptAcceptedPriorDismissCountPrefix, 291 permission, kPermissionsPromptAcceptedPriorDismissCountPrefix,
281 autoblocker->GetDismissCount(requesting_origin, permission)); 292 autoblocker->GetDismissCount(requesting_origin, permission));
282 RecordPermissionPromptPriorCount( 293 RecordPermissionPromptPriorCount(
283 permission, kPermissionsPromptAcceptedPriorIgnoreCountPrefix, 294 permission, kPermissionsPromptAcceptedPriorIgnoreCountPrefix,
284 autoblocker->GetIgnoreCount(requesting_origin, permission)); 295 autoblocker->GetIgnoreCount(requesting_origin, permission));
285 } 296 }
286 297
287 void PermissionUmaUtil::PermissionDenied( 298 void PermissionUmaUtil::PermissionDenied(
288 PermissionType permission, 299 ContentSettingsType permission,
289 PermissionRequestGestureType gesture_type, 300 PermissionRequestGestureType gesture_type,
290 const GURL& requesting_origin, 301 const GURL& requesting_origin,
291 Profile* profile) { 302 Profile* profile) {
292 PermissionDecisionAutoBlocker* autoblocker = 303 PermissionDecisionAutoBlocker* autoblocker =
293 PermissionDecisionAutoBlocker::GetForProfile(profile); 304 PermissionDecisionAutoBlocker::GetForProfile(profile);
294 RecordPermissionAction(permission, DENIED, PermissionSourceUI::PROMPT, 305 RecordPermissionAction(permission, DENIED, PermissionSourceUI::PROMPT,
295 gesture_type, requesting_origin, profile); 306 gesture_type, requesting_origin, profile);
296 RecordPermissionPromptPriorCount( 307 RecordPermissionPromptPriorCount(
297 permission, kPermissionsPromptDeniedPriorDismissCountPrefix, 308 permission, kPermissionsPromptDeniedPriorDismissCountPrefix,
298 autoblocker->GetDismissCount(requesting_origin, permission)); 309 autoblocker->GetDismissCount(requesting_origin, permission));
299 RecordPermissionPromptPriorCount( 310 RecordPermissionPromptPriorCount(
300 permission, kPermissionsPromptDeniedPriorIgnoreCountPrefix, 311 permission, kPermissionsPromptDeniedPriorIgnoreCountPrefix,
301 autoblocker->GetIgnoreCount(requesting_origin, permission)); 312 autoblocker->GetIgnoreCount(requesting_origin, permission));
302 } 313 }
303 314
304 void PermissionUmaUtil::PermissionDismissed( 315 void PermissionUmaUtil::PermissionDismissed(
305 PermissionType permission, 316 ContentSettingsType permission,
306 PermissionRequestGestureType gesture_type, 317 PermissionRequestGestureType gesture_type,
307 const GURL& requesting_origin, 318 const GURL& requesting_origin,
308 Profile* profile) { 319 Profile* profile) {
309 PermissionDecisionAutoBlocker* autoblocker = 320 PermissionDecisionAutoBlocker* autoblocker =
310 PermissionDecisionAutoBlocker::GetForProfile(profile); 321 PermissionDecisionAutoBlocker::GetForProfile(profile);
311 RecordPermissionAction(permission, DISMISSED, PermissionSourceUI::PROMPT, 322 RecordPermissionAction(permission, DISMISSED, PermissionSourceUI::PROMPT,
312 gesture_type, requesting_origin, profile); 323 gesture_type, requesting_origin, profile);
313 RecordPermissionPromptPriorCount( 324 RecordPermissionPromptPriorCount(
314 permission, kPermissionsPromptDismissedPriorDismissCountPrefix, 325 permission, kPermissionsPromptDismissedPriorDismissCountPrefix,
315 autoblocker->GetDismissCount(requesting_origin, permission)); 326 autoblocker->GetDismissCount(requesting_origin, permission));
316 RecordPermissionPromptPriorCount( 327 RecordPermissionPromptPriorCount(
317 permission, kPermissionsPromptDismissedPriorIgnoreCountPrefix, 328 permission, kPermissionsPromptDismissedPriorIgnoreCountPrefix,
318 autoblocker->GetIgnoreCount(requesting_origin, permission)); 329 autoblocker->GetIgnoreCount(requesting_origin, permission));
319 } 330 }
320 331
321 void PermissionUmaUtil::PermissionIgnored( 332 void PermissionUmaUtil::PermissionIgnored(
322 PermissionType permission, 333 ContentSettingsType permission,
323 PermissionRequestGestureType gesture_type, 334 PermissionRequestGestureType gesture_type,
324 const GURL& requesting_origin, 335 const GURL& requesting_origin,
325 Profile* profile) { 336 Profile* profile) {
326 PermissionDecisionAutoBlocker* autoblocker = 337 PermissionDecisionAutoBlocker* autoblocker =
327 PermissionDecisionAutoBlocker::GetForProfile(profile); 338 PermissionDecisionAutoBlocker::GetForProfile(profile);
328 RecordPermissionAction(permission, IGNORED, PermissionSourceUI::PROMPT, 339 RecordPermissionAction(permission, IGNORED, PermissionSourceUI::PROMPT,
329 gesture_type, requesting_origin, profile); 340 gesture_type, requesting_origin, profile);
330 RecordPermissionPromptPriorCount( 341 RecordPermissionPromptPriorCount(
331 permission, kPermissionsPromptIgnoredPriorDismissCountPrefix, 342 permission, kPermissionsPromptIgnoredPriorDismissCountPrefix,
332 autoblocker->GetDismissCount(requesting_origin, permission)); 343 autoblocker->GetDismissCount(requesting_origin, permission));
333 RecordPermissionPromptPriorCount( 344 RecordPermissionPromptPriorCount(
334 permission, kPermissionsPromptIgnoredPriorIgnoreCountPrefix, 345 permission, kPermissionsPromptIgnoredPriorIgnoreCountPrefix,
335 autoblocker->GetIgnoreCount(requesting_origin, permission)); 346 autoblocker->GetIgnoreCount(requesting_origin, permission));
336 347
337 // RecordPermission* methods need to be called before RecordIgnore in the 348 // RecordPermission* methods need to be called before RecordIgnore in the
338 // blocker because they record the number of prior ignore and dismiss values, 349 // blocker because they record the number of prior ignore and dismiss values,
339 // and we don't want to include the current ignore. 350 // and we don't want to include the current ignore.
340 autoblocker->RecordIgnore(requesting_origin, permission); 351 autoblocker->RecordIgnore(requesting_origin, permission);
341 } 352 }
342 353
343 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, 354 void PermissionUmaUtil::PermissionRevoked(ContentSettingsType permission,
344 PermissionSourceUI source_ui, 355 PermissionSourceUI source_ui,
345 const GURL& revoked_origin, 356 const GURL& revoked_origin,
346 Profile* profile) { 357 Profile* profile) {
347 // TODO(tsergeant): Expand metrics definitions for revocation to include all 358 // TODO(tsergeant): Expand metrics definitions for revocation to include all
348 // permissions. 359 // permissions.
349 if (permission == PermissionType::NOTIFICATIONS || 360 if (permission == CONTENT_SETTINGS_TYPE_NOTIFICATIONS ||
350 permission == PermissionType::GEOLOCATION || 361 permission == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
351 permission == PermissionType::AUDIO_CAPTURE || 362 permission == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
352 permission == PermissionType::VIDEO_CAPTURE) { 363 permission == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
353 // An unknown gesture type is passed in since gesture type is only 364 // An unknown gesture type is passed in since gesture type is only
354 // applicable in prompt UIs where revocations are not possible. 365 // applicable in prompt UIs where revocations are not possible.
355 RecordPermissionAction(permission, REVOKED, source_ui, 366 RecordPermissionAction(permission, REVOKED, source_ui,
356 PermissionRequestGestureType::UNKNOWN, 367 PermissionRequestGestureType::UNKNOWN,
357 revoked_origin, profile); 368 revoked_origin, profile);
358 } 369 }
359 } 370 }
360 371
361 void PermissionUmaUtil::RecordSafeBrowsingResponse( 372 void PermissionUmaUtil::RecordSafeBrowsingResponse(
362 base::TimeDelta response_time, 373 base::TimeDelta response_time,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 void PermissionUmaUtil::RecordPermissionPromptDenied( 472 void PermissionUmaUtil::RecordPermissionPromptDenied(
462 PermissionRequestType request_type, 473 PermissionRequestType request_type,
463 PermissionRequestGestureType gesture_type) { 474 PermissionRequestGestureType gesture_type) {
464 PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptDenied, request_type); 475 PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptDenied, request_type);
465 PERMISSION_BUBBLE_GESTURE_TYPE_UMA(kPermissionsPromptDeniedGesture, 476 PERMISSION_BUBBLE_GESTURE_TYPE_UMA(kPermissionsPromptDeniedGesture,
466 kPermissionsPromptDeniedNoGesture, 477 kPermissionsPromptDeniedNoGesture,
467 gesture_type, request_type); 478 gesture_type, request_type);
468 } 479 }
469 480
470 void PermissionUmaUtil::RecordPermissionPromptPriorCount( 481 void PermissionUmaUtil::RecordPermissionPromptPriorCount(
471 content::PermissionType permission, 482 ContentSettingsType permission,
472 const std::string& prefix, 483 const std::string& prefix,
473 int count) { 484 int count) {
474 // The user is not prompted for these permissions, thus there is no prompt 485 // The user is not prompted for this permissions, thus there is no prompt
475 // event to record a prior count for. 486 // event to record a prior count for.
476 DCHECK_NE(PermissionType::MIDI, permission); 487 DCHECK_NE(CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, permission);
477 DCHECK_NE(PermissionType::BACKGROUND_SYNC, permission);
478 DCHECK_NE(PermissionType::NUM, permission);
479 488
480 // Expand UMA_HISTOGRAM_COUNTS_100 so that we can use a dynamically suffixed 489 // Expand UMA_HISTOGRAM_COUNTS_100 so that we can use a dynamically suffixed
481 // histogram name. 490 // histogram name.
482 base::Histogram::FactoryGet( 491 base::Histogram::FactoryGet(
483 prefix + PermissionUtil::GetPermissionString(permission), 1, 100, 50, 492 prefix + PermissionUtil::GetPermissionString(permission), 1, 100, 50,
484 base::HistogramBase::kUmaTargetedHistogramFlag) 493 base::HistogramBase::kUmaTargetedHistogramFlag)
485 ->Add(count); 494 ->Add(count);
486 } 495 }
487 496
488 void PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle( 497 void PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle(
489 content::PermissionType permission, 498 ContentSettingsType permission,
490 bool toggle_enabled) { 499 bool toggle_enabled) {
491 switch (permission) { 500 switch (permission) {
492 case PermissionType::GEOLOCATION: 501 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
493 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Geolocation", 502 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Geolocation",
494 toggle_enabled); 503 toggle_enabled);
495 break; 504 break;
496 case PermissionType::NOTIFICATIONS: 505 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
497 UMA_HISTOGRAM_BOOLEAN( 506 UMA_HISTOGRAM_BOOLEAN(
498 "Permissions.Prompt.Accepted.Persisted.Notifications", 507 "Permissions.Prompt.Accepted.Persisted.Notifications",
499 toggle_enabled); 508 toggle_enabled);
500 break; 509 break;
501 case PermissionType::MIDI_SYSEX: 510 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
502 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.MidiSysEx", 511 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.MidiSysEx",
503 toggle_enabled); 512 toggle_enabled);
504 break; 513 break;
505 case PermissionType::PUSH_MESSAGING: 514 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
506 UMA_HISTOGRAM_BOOLEAN( 515 UMA_HISTOGRAM_BOOLEAN(
507 "Permissions.Prompt.Accepted.Persisted.PushMessaging", 516 "Permissions.Prompt.Accepted.Persisted.PushMessaging",
508 toggle_enabled); 517 toggle_enabled);
509 break; 518 break;
510 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: 519 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
511 UMA_HISTOGRAM_BOOLEAN( 520 UMA_HISTOGRAM_BOOLEAN(
512 "Permissions.Prompt.Accepted.Persisted.ProtectedMedia", 521 "Permissions.Prompt.Accepted.Persisted.ProtectedMedia",
513 toggle_enabled); 522 toggle_enabled);
514 break; 523 break;
515 case PermissionType::DURABLE_STORAGE: 524 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
516 UMA_HISTOGRAM_BOOLEAN( 525 UMA_HISTOGRAM_BOOLEAN(
517 "Permissions.Prompt.Accepted.Persisted.DurableStorage", 526 "Permissions.Prompt.Accepted.Persisted.DurableStorage",
518 toggle_enabled); 527 toggle_enabled);
519 break; 528 break;
520 case PermissionType::AUDIO_CAPTURE: 529 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
521 UMA_HISTOGRAM_BOOLEAN( 530 UMA_HISTOGRAM_BOOLEAN(
522 "Permissions.Prompt.Accepted.Persisted.AudioCapture", toggle_enabled); 531 "Permissions.Prompt.Accepted.Persisted.AudioCapture", toggle_enabled);
523 break; 532 break;
524 case PermissionType::VIDEO_CAPTURE: 533 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
525 UMA_HISTOGRAM_BOOLEAN( 534 UMA_HISTOGRAM_BOOLEAN(
526 "Permissions.Prompt.Accepted.Persisted.VideoCapture", toggle_enabled); 535 "Permissions.Prompt.Accepted.Persisted.VideoCapture", toggle_enabled);
527 break; 536 break;
528 case PermissionType::FLASH: 537 case CONTENT_SETTINGS_TYPE_PLUGINS:
529 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Flash", 538 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Flash",
530 toggle_enabled); 539 toggle_enabled);
531 break; 540 break;
532 // The user is not prompted for these permissions, thus there is no accept 541 // The user is not prompted for these permissions, thus there is no accept
533 // recorded for them. 542 // recorded for them.
534 case PermissionType::MIDI: 543 default:
535 case PermissionType::BACKGROUND_SYNC:
536 case PermissionType::NUM:
537 NOTREACHED() << "PERMISSION " 544 NOTREACHED() << "PERMISSION "
538 << PermissionUtil::GetPermissionString(permission) 545 << PermissionUtil::GetPermissionString(permission)
539 << " not accounted for"; 546 << " not accounted for";
540 } 547 }
541 } 548 }
542 549
543 void PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle( 550 void PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle(
544 content::PermissionType permission, 551 ContentSettingsType permission,
545 bool toggle_enabled) { 552 bool toggle_enabled) {
546 switch (permission) { 553 switch (permission) {
547 case PermissionType::GEOLOCATION: 554 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
548 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Geolocation", 555 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Geolocation",
549 toggle_enabled); 556 toggle_enabled);
550 break; 557 break;
551 case PermissionType::NOTIFICATIONS: 558 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
552 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Notifications", 559 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Notifications",
553 toggle_enabled); 560 toggle_enabled);
554 break; 561 break;
555 case PermissionType::MIDI_SYSEX: 562 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
556 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.MidiSysEx", 563 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.MidiSysEx",
557 toggle_enabled); 564 toggle_enabled);
558 break; 565 break;
559 case PermissionType::PUSH_MESSAGING: 566 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
560 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.PushMessaging", 567 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.PushMessaging",
561 toggle_enabled); 568 toggle_enabled);
562 break; 569 break;
563 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: 570 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
564 UMA_HISTOGRAM_BOOLEAN( 571 UMA_HISTOGRAM_BOOLEAN(
565 "Permissions.Prompt.Denied.Persisted.ProtectedMedia", toggle_enabled); 572 "Permissions.Prompt.Denied.Persisted.ProtectedMedia", toggle_enabled);
566 break; 573 break;
567 case PermissionType::DURABLE_STORAGE: 574 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
568 UMA_HISTOGRAM_BOOLEAN( 575 UMA_HISTOGRAM_BOOLEAN(
569 "Permissions.Prompt.Denied.Persisted.DurableStorage", toggle_enabled); 576 "Permissions.Prompt.Denied.Persisted.DurableStorage", toggle_enabled);
570 break; 577 break;
571 case PermissionType::AUDIO_CAPTURE: 578 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
572 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.AudioCapture", 579 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.AudioCapture",
573 toggle_enabled); 580 toggle_enabled);
574 break; 581 break;
575 case PermissionType::VIDEO_CAPTURE: 582 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
576 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.VideoCapture", 583 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.VideoCapture",
577 toggle_enabled); 584 toggle_enabled);
578 break; 585 break;
579 case PermissionType::FLASH: 586 case CONTENT_SETTINGS_TYPE_PLUGINS:
580 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Flash", 587 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Flash",
581 toggle_enabled); 588 toggle_enabled);
582 break; 589 break;
583 // The user is not prompted for these permissions, thus there is no deny 590 // The user is not prompted for these permissions, thus there is no deny
584 // recorded for them. 591 // recorded for them.
585 case PermissionType::MIDI: 592 default:
586 case PermissionType::BACKGROUND_SYNC:
587 case PermissionType::NUM:
588 NOTREACHED() << "PERMISSION " 593 NOTREACHED() << "PERMISSION "
589 << PermissionUtil::GetPermissionString(permission) 594 << PermissionUtil::GetPermissionString(permission)
590 << " not accounted for"; 595 << " not accounted for";
591 } 596 }
592 } 597 }
593 598
594 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) { 599 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) {
595 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 600 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
596 switches::kDisablePermissionActionReporting)) { 601 switches::kDisablePermissionActionReporting)) {
597 return false; 602 return false;
(...skipping 25 matching lines...) Expand all
623 profile_sync_service->GetPreferredDataTypes(); 628 profile_sync_service->GetPreferredDataTypes();
624 if (!(preferred_data_types.Has(syncer::PROXY_TABS) && 629 if (!(preferred_data_types.Has(syncer::PROXY_TABS) &&
625 preferred_data_types.Has(syncer::PRIORITY_PREFERENCES))) { 630 preferred_data_types.Has(syncer::PRIORITY_PREFERENCES))) {
626 return false; 631 return false;
627 } 632 }
628 633
629 return true; 634 return true;
630 } 635 }
631 636
632 void PermissionUmaUtil::RecordPermissionAction( 637 void PermissionUmaUtil::RecordPermissionAction(
633 PermissionType permission, 638 ContentSettingsType permission,
634 PermissionAction action, 639 PermissionAction action,
635 PermissionSourceUI source_ui, 640 PermissionSourceUI source_ui,
636 PermissionRequestGestureType gesture_type, 641 PermissionRequestGestureType gesture_type,
637 const GURL& requesting_origin, 642 const GURL& requesting_origin,
638 Profile* profile) { 643 Profile* profile) {
639 if (IsOptedIntoPermissionActionReporting(profile)) { 644 if (IsOptedIntoPermissionActionReporting(profile)) {
640 PermissionDecisionAutoBlocker* autoblocker = 645 PermissionDecisionAutoBlocker* autoblocker =
641 PermissionDecisionAutoBlocker::GetForProfile(profile); 646 PermissionDecisionAutoBlocker::GetForProfile(profile);
642 // TODO(kcarattini): Pass in the actual persist decision when it becomes 647 // TODO(kcarattini): Pass in the actual persist decision when it becomes
643 // available. 648 // available.
644 PermissionReportInfo report_info( 649 PermissionReportInfo report_info(
645 requesting_origin, permission, action, source_ui, gesture_type, 650 requesting_origin, permission, action, source_ui, gesture_type,
646 PermissionPersistDecision::UNSPECIFIED, 651 PermissionPersistDecision::UNSPECIFIED,
647 autoblocker->GetDismissCount(requesting_origin, permission), 652 autoblocker->GetDismissCount(requesting_origin, permission),
648 autoblocker->GetIgnoreCount(requesting_origin, permission)); 653 autoblocker->GetIgnoreCount(requesting_origin, permission));
649 g_browser_process->safe_browsing_service() 654 g_browser_process->safe_browsing_service()
650 ->ui_manager()->ReportPermissionAction(report_info); 655 ->ui_manager()->ReportPermissionAction(report_info);
651 } 656 }
652 657
653 bool secure_origin = content::IsOriginSecure(requesting_origin); 658 bool secure_origin = content::IsOriginSecure(requesting_origin);
654 659
655 switch (permission) { 660 switch (permission) {
656 case PermissionType::GEOLOCATION: 661 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
657 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation", 662 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation",
658 "Permissions.Action.SecureOrigin.Geolocation", 663 "Permissions.Action.SecureOrigin.Geolocation",
659 "Permissions.Action.InsecureOrigin.Geolocation", 664 "Permissions.Action.InsecureOrigin.Geolocation",
660 action); 665 action);
661 break; 666 break;
662 case PermissionType::NOTIFICATIONS: 667 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
663 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Notifications", 668 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Notifications",
664 "Permissions.Action.SecureOrigin.Notifications", 669 "Permissions.Action.SecureOrigin.Notifications",
665 "Permissions.Action.InsecureOrigin.Notifications", 670 "Permissions.Action.InsecureOrigin.Notifications",
666 action); 671 action);
667 break; 672 break;
668 case PermissionType::MIDI_SYSEX: 673 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
669 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.MidiSysEx", 674 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.MidiSysEx",
670 "Permissions.Action.SecureOrigin.MidiSysEx", 675 "Permissions.Action.SecureOrigin.MidiSysEx",
671 "Permissions.Action.InsecureOrigin.MidiSysEx", 676 "Permissions.Action.InsecureOrigin.MidiSysEx",
672 action); 677 action);
673 break; 678 break;
674 case PermissionType::PUSH_MESSAGING: 679 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
675 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.PushMessaging", 680 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.PushMessaging",
676 "Permissions.Action.SecureOrigin.PushMessaging", 681 "Permissions.Action.SecureOrigin.PushMessaging",
677 "Permissions.Action.InsecureOrigin.PushMessaging", 682 "Permissions.Action.InsecureOrigin.PushMessaging",
678 action); 683 action);
679 break; 684 break;
680 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: 685 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
681 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.ProtectedMedia", 686 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.ProtectedMedia",
682 "Permissions.Action.SecureOrigin.ProtectedMedia", 687 "Permissions.Action.SecureOrigin.ProtectedMedia",
683 "Permissions.Action.InsecureOrigin.ProtectedMedia", 688 "Permissions.Action.InsecureOrigin.ProtectedMedia",
684 action); 689 action);
685 break; 690 break;
686 case PermissionType::DURABLE_STORAGE: 691 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
687 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.DurableStorage", 692 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.DurableStorage",
688 "Permissions.Action.SecureOrigin.DurableStorage", 693 "Permissions.Action.SecureOrigin.DurableStorage",
689 "Permissions.Action.InsecureOrigin.DurableStorage", 694 "Permissions.Action.InsecureOrigin.DurableStorage",
690 action); 695 action);
691 break; 696 break;
692 case PermissionType::AUDIO_CAPTURE: 697 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
693 // Media permissions are disabled on insecure origins, so there's no 698 // Media permissions are disabled on insecure origins, so there's no
694 // need to record metrics for secure/insecue. 699 // need to record metrics for secure/insecue.
695 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.AudioCapture", action, 700 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.AudioCapture", action,
696 PERMISSION_ACTION_NUM); 701 PERMISSION_ACTION_NUM);
697 break; 702 break;
698 case PermissionType::VIDEO_CAPTURE: 703 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
699 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.VideoCapture", action, 704 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.VideoCapture", action,
700 PERMISSION_ACTION_NUM); 705 PERMISSION_ACTION_NUM);
701 break; 706 break;
702 case PermissionType::FLASH: 707 case CONTENT_SETTINGS_TYPE_PLUGINS:
703 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Flash", 708 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Flash",
704 "Permissions.Action.SecureOrigin.Flash", 709 "Permissions.Action.SecureOrigin.Flash",
705 "Permissions.Action.InsecureOrigin.Flash", action); 710 "Permissions.Action.InsecureOrigin.Flash", action);
706 break; 711 break;
707 // The user is not prompted for these permissions, thus there is no 712 // The user is not prompted for these permissions, thus there is no
708 // permission action recorded for them. 713 // permission action recorded for them.
709 case PermissionType::MIDI: 714 default:
710 case PermissionType::BACKGROUND_SYNC:
711 case PermissionType::NUM:
712 NOTREACHED() << "PERMISSION " 715 NOTREACHED() << "PERMISSION "
713 << PermissionUtil::GetPermissionString(permission) 716 << PermissionUtil::GetPermissionString(permission)
714 << " not accounted for"; 717 << " not accounted for";
715 } 718 }
716 719
717 // Retrieve the name of the RAPPOR metric. Currently, the new metric name is 720 // Retrieve the name of the RAPPOR metric. Currently, the new metric name is
718 // the deprecated name with "2" on the end, e.g. 721 // the deprecated name with "2" on the end, e.g.
719 // ContentSettings.PermissionActions_Geolocation.Granted.Url2. For simplicity, 722 // ContentSettings.PermissionActions_Geolocation.Granted.Url2. For simplicity,
720 // we retrieve the deprecated name and append the "2" for the new name. 723 // we retrieve the deprecated name and append the "2" for the new name.
721 // TODO(dominickn): remove the deprecated metric and replace it solely with 724 // TODO(dominickn): remove the deprecated metric and replace it solely with
722 // the new one in GetRapporMetric - crbug.com/605836. 725 // the new one in GetRapporMetric - crbug.com/605836.
723 const std::string deprecated_metric = GetRapporMetric(permission, action); 726 const std::string deprecated_metric = GetRapporMetric(permission, action);
724 rappor::RapporServiceImpl* rappor_service = 727 rappor::RapporServiceImpl* rappor_service =
725 g_browser_process->rappor_service(); 728 g_browser_process->rappor_service();
726 if (!deprecated_metric.empty() && rappor_service) { 729 if (!deprecated_metric.empty() && rappor_service) {
727 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, 730 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric,
728 requesting_origin); 731 requesting_origin);
729 732
730 std::string rappor_metric = deprecated_metric + "2"; 733 std::string rappor_metric = deprecated_metric + "2";
731 rappor_service->RecordSampleString( 734 rappor_service->RecordSampleString(
732 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 735 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
733 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 736 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
734 } 737 }
735 } 738 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698