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