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

Side by Side Diff: chrome/browser/permissions/permission_uma_util.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_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::RecordPermissionEmbargoStatus( 372 void PermissionUmaUtil::RecordPermissionEmbargoStatus(
362 PermissionEmbargoStatus embargo_status) { 373 PermissionEmbargoStatus embargo_status) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 void PermissionUmaUtil::RecordPermissionPromptDenied( 479 void PermissionUmaUtil::RecordPermissionPromptDenied(
469 PermissionRequestType request_type, 480 PermissionRequestType request_type,
470 PermissionRequestGestureType gesture_type) { 481 PermissionRequestGestureType gesture_type) {
471 PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptDenied, request_type); 482 PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptDenied, request_type);
472 PERMISSION_BUBBLE_GESTURE_TYPE_UMA(kPermissionsPromptDeniedGesture, 483 PERMISSION_BUBBLE_GESTURE_TYPE_UMA(kPermissionsPromptDeniedGesture,
473 kPermissionsPromptDeniedNoGesture, 484 kPermissionsPromptDeniedNoGesture,
474 gesture_type, request_type); 485 gesture_type, request_type);
475 } 486 }
476 487
477 void PermissionUmaUtil::RecordPermissionPromptPriorCount( 488 void PermissionUmaUtil::RecordPermissionPromptPriorCount(
478 content::PermissionType permission, 489 ContentSettingsType permission,
479 const std::string& prefix, 490 const std::string& prefix,
480 int count) { 491 int count) {
481 // The user is not prompted for these permissions, thus there is no prompt 492 // The user is not prompted for this permissions, thus there is no prompt
482 // event to record a prior count for. 493 // event to record a prior count for.
483 DCHECK_NE(PermissionType::MIDI, permission); 494 DCHECK_NE(CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, permission);
484 DCHECK_NE(PermissionType::BACKGROUND_SYNC, permission);
485 DCHECK_NE(PermissionType::NUM, permission);
486 495
487 // Expand UMA_HISTOGRAM_COUNTS_100 so that we can use a dynamically suffixed 496 // Expand UMA_HISTOGRAM_COUNTS_100 so that we can use a dynamically suffixed
488 // histogram name. 497 // histogram name.
489 base::Histogram::FactoryGet( 498 base::Histogram::FactoryGet(
490 prefix + PermissionUtil::GetPermissionString(permission), 1, 100, 50, 499 prefix + PermissionUtil::GetPermissionString(permission), 1, 100, 50,
491 base::HistogramBase::kUmaTargetedHistogramFlag) 500 base::HistogramBase::kUmaTargetedHistogramFlag)
492 ->Add(count); 501 ->Add(count);
493 } 502 }
494 503
495 void PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle( 504 void PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle(
496 content::PermissionType permission, 505 ContentSettingsType permission,
497 bool toggle_enabled) { 506 bool toggle_enabled) {
498 switch (permission) { 507 switch (permission) {
499 case PermissionType::GEOLOCATION: 508 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
500 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Geolocation", 509 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Geolocation",
501 toggle_enabled); 510 toggle_enabled);
502 break; 511 break;
503 case PermissionType::NOTIFICATIONS: 512 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
504 UMA_HISTOGRAM_BOOLEAN( 513 UMA_HISTOGRAM_BOOLEAN(
505 "Permissions.Prompt.Accepted.Persisted.Notifications", 514 "Permissions.Prompt.Accepted.Persisted.Notifications",
506 toggle_enabled); 515 toggle_enabled);
507 break; 516 break;
508 case PermissionType::MIDI_SYSEX: 517 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
509 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.MidiSysEx", 518 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.MidiSysEx",
510 toggle_enabled); 519 toggle_enabled);
511 break; 520 break;
512 case PermissionType::PUSH_MESSAGING: 521 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
513 UMA_HISTOGRAM_BOOLEAN( 522 UMA_HISTOGRAM_BOOLEAN(
514 "Permissions.Prompt.Accepted.Persisted.PushMessaging", 523 "Permissions.Prompt.Accepted.Persisted.PushMessaging",
515 toggle_enabled); 524 toggle_enabled);
516 break; 525 break;
517 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: 526 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
518 UMA_HISTOGRAM_BOOLEAN( 527 UMA_HISTOGRAM_BOOLEAN(
519 "Permissions.Prompt.Accepted.Persisted.ProtectedMedia", 528 "Permissions.Prompt.Accepted.Persisted.ProtectedMedia",
520 toggle_enabled); 529 toggle_enabled);
521 break; 530 break;
522 case PermissionType::DURABLE_STORAGE: 531 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
523 UMA_HISTOGRAM_BOOLEAN( 532 UMA_HISTOGRAM_BOOLEAN(
524 "Permissions.Prompt.Accepted.Persisted.DurableStorage", 533 "Permissions.Prompt.Accepted.Persisted.DurableStorage",
525 toggle_enabled); 534 toggle_enabled);
526 break; 535 break;
527 case PermissionType::AUDIO_CAPTURE: 536 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
528 UMA_HISTOGRAM_BOOLEAN( 537 UMA_HISTOGRAM_BOOLEAN(
529 "Permissions.Prompt.Accepted.Persisted.AudioCapture", toggle_enabled); 538 "Permissions.Prompt.Accepted.Persisted.AudioCapture", toggle_enabled);
530 break; 539 break;
531 case PermissionType::VIDEO_CAPTURE: 540 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
532 UMA_HISTOGRAM_BOOLEAN( 541 UMA_HISTOGRAM_BOOLEAN(
533 "Permissions.Prompt.Accepted.Persisted.VideoCapture", toggle_enabled); 542 "Permissions.Prompt.Accepted.Persisted.VideoCapture", toggle_enabled);
534 break; 543 break;
535 case PermissionType::FLASH: 544 case CONTENT_SETTINGS_TYPE_PLUGINS:
536 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Flash", 545 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Accepted.Persisted.Flash",
537 toggle_enabled); 546 toggle_enabled);
538 break; 547 break;
539 // The user is not prompted for these permissions, thus there is no accept 548 // The user is not prompted for these permissions, thus there is no accept
540 // recorded for them. 549 // recorded for them.
541 case PermissionType::MIDI: 550 default:
542 case PermissionType::BACKGROUND_SYNC:
543 case PermissionType::NUM:
544 NOTREACHED() << "PERMISSION " 551 NOTREACHED() << "PERMISSION "
545 << PermissionUtil::GetPermissionString(permission) 552 << PermissionUtil::GetPermissionString(permission)
546 << " not accounted for"; 553 << " not accounted for";
547 } 554 }
548 } 555 }
549 556
550 void PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle( 557 void PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle(
551 content::PermissionType permission, 558 ContentSettingsType permission,
552 bool toggle_enabled) { 559 bool toggle_enabled) {
553 switch (permission) { 560 switch (permission) {
554 case PermissionType::GEOLOCATION: 561 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
555 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Geolocation", 562 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Geolocation",
556 toggle_enabled); 563 toggle_enabled);
557 break; 564 break;
558 case PermissionType::NOTIFICATIONS: 565 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
559 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Notifications", 566 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Notifications",
560 toggle_enabled); 567 toggle_enabled);
561 break; 568 break;
562 case PermissionType::MIDI_SYSEX: 569 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
563 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.MidiSysEx", 570 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.MidiSysEx",
564 toggle_enabled); 571 toggle_enabled);
565 break; 572 break;
566 case PermissionType::PUSH_MESSAGING: 573 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
567 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.PushMessaging", 574 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.PushMessaging",
568 toggle_enabled); 575 toggle_enabled);
569 break; 576 break;
570 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: 577 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
571 UMA_HISTOGRAM_BOOLEAN( 578 UMA_HISTOGRAM_BOOLEAN(
572 "Permissions.Prompt.Denied.Persisted.ProtectedMedia", toggle_enabled); 579 "Permissions.Prompt.Denied.Persisted.ProtectedMedia", toggle_enabled);
573 break; 580 break;
574 case PermissionType::DURABLE_STORAGE: 581 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
575 UMA_HISTOGRAM_BOOLEAN( 582 UMA_HISTOGRAM_BOOLEAN(
576 "Permissions.Prompt.Denied.Persisted.DurableStorage", toggle_enabled); 583 "Permissions.Prompt.Denied.Persisted.DurableStorage", toggle_enabled);
577 break; 584 break;
578 case PermissionType::AUDIO_CAPTURE: 585 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
579 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.AudioCapture", 586 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.AudioCapture",
580 toggle_enabled); 587 toggle_enabled);
581 break; 588 break;
582 case PermissionType::VIDEO_CAPTURE: 589 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
583 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.VideoCapture", 590 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.VideoCapture",
584 toggle_enabled); 591 toggle_enabled);
585 break; 592 break;
586 case PermissionType::FLASH: 593 case CONTENT_SETTINGS_TYPE_PLUGINS:
587 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Flash", 594 UMA_HISTOGRAM_BOOLEAN("Permissions.Prompt.Denied.Persisted.Flash",
588 toggle_enabled); 595 toggle_enabled);
589 break; 596 break;
590 // The user is not prompted for these permissions, thus there is no deny 597 // The user is not prompted for these permissions, thus there is no deny
591 // recorded for them. 598 // recorded for them.
592 case PermissionType::MIDI: 599 default:
593 case PermissionType::BACKGROUND_SYNC:
594 case PermissionType::NUM:
595 NOTREACHED() << "PERMISSION " 600 NOTREACHED() << "PERMISSION "
596 << PermissionUtil::GetPermissionString(permission) 601 << PermissionUtil::GetPermissionString(permission)
597 << " not accounted for"; 602 << " not accounted for";
598 } 603 }
599 } 604 }
600 605
601 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) { 606 bool PermissionUmaUtil::IsOptedIntoPermissionActionReporting(Profile* profile) {
602 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 607 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
603 switches::kDisablePermissionActionReporting)) { 608 switches::kDisablePermissionActionReporting)) {
604 return false; 609 return false;
(...skipping 25 matching lines...) Expand all
630 profile_sync_service->GetPreferredDataTypes(); 635 profile_sync_service->GetPreferredDataTypes();
631 if (!(preferred_data_types.Has(syncer::PROXY_TABS) && 636 if (!(preferred_data_types.Has(syncer::PROXY_TABS) &&
632 preferred_data_types.Has(syncer::PRIORITY_PREFERENCES))) { 637 preferred_data_types.Has(syncer::PRIORITY_PREFERENCES))) {
633 return false; 638 return false;
634 } 639 }
635 640
636 return true; 641 return true;
637 } 642 }
638 643
639 void PermissionUmaUtil::RecordPermissionAction( 644 void PermissionUmaUtil::RecordPermissionAction(
640 PermissionType permission, 645 ContentSettingsType permission,
641 PermissionAction action, 646 PermissionAction action,
642 PermissionSourceUI source_ui, 647 PermissionSourceUI source_ui,
643 PermissionRequestGestureType gesture_type, 648 PermissionRequestGestureType gesture_type,
644 const GURL& requesting_origin, 649 const GURL& requesting_origin,
645 Profile* profile) { 650 Profile* profile) {
646 if (IsOptedIntoPermissionActionReporting(profile)) { 651 if (IsOptedIntoPermissionActionReporting(profile)) {
647 PermissionDecisionAutoBlocker* autoblocker = 652 PermissionDecisionAutoBlocker* autoblocker =
648 PermissionDecisionAutoBlocker::GetForProfile(profile); 653 PermissionDecisionAutoBlocker::GetForProfile(profile);
649 // TODO(kcarattini): Pass in the actual persist decision when it becomes 654 // TODO(kcarattini): Pass in the actual persist decision when it becomes
650 // available. 655 // available.
651 PermissionReportInfo report_info( 656 PermissionReportInfo report_info(
652 requesting_origin, permission, action, source_ui, gesture_type, 657 requesting_origin, permission, action, source_ui, gesture_type,
653 PermissionPersistDecision::UNSPECIFIED, 658 PermissionPersistDecision::UNSPECIFIED,
654 autoblocker->GetDismissCount(requesting_origin, permission), 659 autoblocker->GetDismissCount(requesting_origin, permission),
655 autoblocker->GetIgnoreCount(requesting_origin, permission)); 660 autoblocker->GetIgnoreCount(requesting_origin, permission));
656 g_browser_process->safe_browsing_service() 661 g_browser_process->safe_browsing_service()
657 ->ui_manager()->ReportPermissionAction(report_info); 662 ->ui_manager()->ReportPermissionAction(report_info);
658 } 663 }
659 664
660 bool secure_origin = content::IsOriginSecure(requesting_origin); 665 bool secure_origin = content::IsOriginSecure(requesting_origin);
661 666
662 switch (permission) { 667 switch (permission) {
663 case PermissionType::GEOLOCATION: 668 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
664 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation", 669 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation",
665 "Permissions.Action.SecureOrigin.Geolocation", 670 "Permissions.Action.SecureOrigin.Geolocation",
666 "Permissions.Action.InsecureOrigin.Geolocation", 671 "Permissions.Action.InsecureOrigin.Geolocation",
667 action); 672 action);
668 break; 673 break;
669 case PermissionType::NOTIFICATIONS: 674 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
670 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Notifications", 675 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Notifications",
671 "Permissions.Action.SecureOrigin.Notifications", 676 "Permissions.Action.SecureOrigin.Notifications",
672 "Permissions.Action.InsecureOrigin.Notifications", 677 "Permissions.Action.InsecureOrigin.Notifications",
673 action); 678 action);
674 break; 679 break;
675 case PermissionType::MIDI_SYSEX: 680 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
676 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.MidiSysEx", 681 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.MidiSysEx",
677 "Permissions.Action.SecureOrigin.MidiSysEx", 682 "Permissions.Action.SecureOrigin.MidiSysEx",
678 "Permissions.Action.InsecureOrigin.MidiSysEx", 683 "Permissions.Action.InsecureOrigin.MidiSysEx",
679 action); 684 action);
680 break; 685 break;
681 case PermissionType::PUSH_MESSAGING: 686 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
682 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.PushMessaging", 687 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.PushMessaging",
683 "Permissions.Action.SecureOrigin.PushMessaging", 688 "Permissions.Action.SecureOrigin.PushMessaging",
684 "Permissions.Action.InsecureOrigin.PushMessaging", 689 "Permissions.Action.InsecureOrigin.PushMessaging",
685 action); 690 action);
686 break; 691 break;
687 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: 692 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
688 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.ProtectedMedia", 693 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.ProtectedMedia",
689 "Permissions.Action.SecureOrigin.ProtectedMedia", 694 "Permissions.Action.SecureOrigin.ProtectedMedia",
690 "Permissions.Action.InsecureOrigin.ProtectedMedia", 695 "Permissions.Action.InsecureOrigin.ProtectedMedia",
691 action); 696 action);
692 break; 697 break;
693 case PermissionType::DURABLE_STORAGE: 698 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
694 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.DurableStorage", 699 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.DurableStorage",
695 "Permissions.Action.SecureOrigin.DurableStorage", 700 "Permissions.Action.SecureOrigin.DurableStorage",
696 "Permissions.Action.InsecureOrigin.DurableStorage", 701 "Permissions.Action.InsecureOrigin.DurableStorage",
697 action); 702 action);
698 break; 703 break;
699 case PermissionType::AUDIO_CAPTURE: 704 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
700 // Media permissions are disabled on insecure origins, so there's no 705 // Media permissions are disabled on insecure origins, so there's no
701 // need to record metrics for secure/insecue. 706 // need to record metrics for secure/insecue.
702 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.AudioCapture", action, 707 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.AudioCapture", action,
703 PERMISSION_ACTION_NUM); 708 PERMISSION_ACTION_NUM);
704 break; 709 break;
705 case PermissionType::VIDEO_CAPTURE: 710 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
706 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.VideoCapture", action, 711 UMA_HISTOGRAM_ENUMERATION("Permissions.Action.VideoCapture", action,
707 PERMISSION_ACTION_NUM); 712 PERMISSION_ACTION_NUM);
708 break; 713 break;
709 case PermissionType::FLASH: 714 case CONTENT_SETTINGS_TYPE_PLUGINS:
710 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Flash", 715 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Flash",
711 "Permissions.Action.SecureOrigin.Flash", 716 "Permissions.Action.SecureOrigin.Flash",
712 "Permissions.Action.InsecureOrigin.Flash", action); 717 "Permissions.Action.InsecureOrigin.Flash", action);
713 break; 718 break;
714 // The user is not prompted for these permissions, thus there is no 719 // The user is not prompted for these permissions, thus there is no
715 // permission action recorded for them. 720 // permission action recorded for them.
716 case PermissionType::MIDI: 721 default:
717 case PermissionType::BACKGROUND_SYNC:
718 case PermissionType::NUM:
719 NOTREACHED() << "PERMISSION " 722 NOTREACHED() << "PERMISSION "
720 << PermissionUtil::GetPermissionString(permission) 723 << PermissionUtil::GetPermissionString(permission)
721 << " not accounted for"; 724 << " not accounted for";
722 } 725 }
723 726
724 // Retrieve the name of the RAPPOR metric. Currently, the new metric name is 727 // Retrieve the name of the RAPPOR metric. Currently, the new metric name is
725 // the deprecated name with "2" on the end, e.g. 728 // the deprecated name with "2" on the end, e.g.
726 // ContentSettings.PermissionActions_Geolocation.Granted.Url2. For simplicity, 729 // ContentSettings.PermissionActions_Geolocation.Granted.Url2. For simplicity,
727 // we retrieve the deprecated name and append the "2" for the new name. 730 // we retrieve the deprecated name and append the "2" for the new name.
728 // TODO(dominickn): remove the deprecated metric and replace it solely with 731 // TODO(dominickn): remove the deprecated metric and replace it solely with
729 // the new one in GetRapporMetric - crbug.com/605836. 732 // the new one in GetRapporMetric - crbug.com/605836.
730 const std::string deprecated_metric = GetRapporMetric(permission, action); 733 const std::string deprecated_metric = GetRapporMetric(permission, action);
731 rappor::RapporServiceImpl* rappor_service = 734 rappor::RapporServiceImpl* rappor_service =
732 g_browser_process->rappor_service(); 735 g_browser_process->rappor_service();
733 if (!deprecated_metric.empty() && rappor_service) { 736 if (!deprecated_metric.empty() && rappor_service) {
734 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, 737 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric,
735 requesting_origin); 738 requesting_origin);
736 739
737 std::string rappor_metric = deprecated_metric + "2"; 740 std::string rappor_metric = deprecated_metric + "2";
738 rappor_service->RecordSampleString( 741 rappor_service->RecordSampleString(
739 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 742 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
740 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 743 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
741 } 744 }
742 } 745 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_uma_util.h ('k') | chrome/browser/permissions/permission_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698