| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // Make sure you update histograms.xml permission histogram_suffix if you | 210 // Make sure you update histograms.xml permission histogram_suffix if you |
| 211 // add new permission | 211 // add new permission |
| 212 void PermissionUmaUtil::PermissionRequested(PermissionType permission, | 212 void PermissionUmaUtil::PermissionRequested(PermissionType permission, |
| 213 const GURL& requesting_origin, | 213 const GURL& requesting_origin, |
| 214 const GURL& embedding_origin, | 214 const GURL& embedding_origin, |
| 215 Profile* profile) { | 215 Profile* profile) { |
| 216 RecordPermissionRequest(permission, requesting_origin, embedding_origin, | 216 RecordPermissionRequest(permission, requesting_origin, embedding_origin, |
| 217 profile); | 217 profile); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void PermissionUmaUtil::PermissionGranted(PermissionType permission, | 220 void PermissionUmaUtil::PermissionGranted( |
| 221 const GURL& requesting_origin, | 221 PermissionType permission, |
| 222 Profile* profile) { | 222 PermissionRequestGestureType gesture_type, |
| 223 const GURL& requesting_origin, |
| 224 Profile* profile) { |
| 223 RecordPermissionAction(permission, GRANTED, PermissionSourceUI::PROMPT, | 225 RecordPermissionAction(permission, GRANTED, PermissionSourceUI::PROMPT, |
| 224 requesting_origin, profile); | 226 gesture_type, requesting_origin, profile); |
| 225 } | 227 } |
| 226 | 228 |
| 227 void PermissionUmaUtil::PermissionDenied(PermissionType permission, | 229 void PermissionUmaUtil::PermissionDenied( |
| 228 const GURL& requesting_origin, | 230 PermissionType permission, |
| 229 Profile* profile) { | 231 PermissionRequestGestureType gesture_type, |
| 232 const GURL& requesting_origin, |
| 233 Profile* profile) { |
| 230 RecordPermissionAction(permission, DENIED, PermissionSourceUI::PROMPT, | 234 RecordPermissionAction(permission, DENIED, PermissionSourceUI::PROMPT, |
| 231 requesting_origin, profile); | 235 gesture_type, requesting_origin, profile); |
| 232 } | 236 } |
| 233 | 237 |
| 234 void PermissionUmaUtil::PermissionDismissed(PermissionType permission, | 238 void PermissionUmaUtil::PermissionDismissed( |
| 235 const GURL& requesting_origin, | 239 PermissionType permission, |
| 236 Profile* profile) { | 240 PermissionRequestGestureType gesture_type, |
| 241 const GURL& requesting_origin, |
| 242 Profile* profile) { |
| 237 RecordPermissionAction(permission, DISMISSED, PermissionSourceUI::PROMPT, | 243 RecordPermissionAction(permission, DISMISSED, PermissionSourceUI::PROMPT, |
| 238 requesting_origin, profile); | 244 gesture_type, requesting_origin, profile); |
| 239 } | 245 } |
| 240 | 246 |
| 241 void PermissionUmaUtil::PermissionIgnored(PermissionType permission, | 247 void PermissionUmaUtil::PermissionIgnored( |
| 242 const GURL& requesting_origin, | 248 PermissionType permission, |
| 243 Profile* profile) { | 249 PermissionRequestGestureType gesture_type, |
| 250 const GURL& requesting_origin, |
| 251 Profile* profile) { |
| 244 RecordPermissionAction(permission, IGNORED, PermissionSourceUI::PROMPT, | 252 RecordPermissionAction(permission, IGNORED, PermissionSourceUI::PROMPT, |
| 245 requesting_origin, profile); | 253 gesture_type, requesting_origin, profile); |
| 246 } | 254 } |
| 247 | 255 |
| 248 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, | 256 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, |
| 249 PermissionSourceUI source_ui, | 257 PermissionSourceUI source_ui, |
| 250 const GURL& revoked_origin, | 258 const GURL& revoked_origin, |
| 251 Profile* profile) { | 259 Profile* profile) { |
| 252 // TODO(tsergeant): Expand metrics definitions for revocation to include all | 260 // TODO(tsergeant): Expand metrics definitions for revocation to include all |
| 253 // permissions. | 261 // permissions. |
| 254 if (permission == PermissionType::NOTIFICATIONS || | 262 if (permission == PermissionType::NOTIFICATIONS || |
| 255 permission == PermissionType::GEOLOCATION || | 263 permission == PermissionType::GEOLOCATION || |
| 256 permission == PermissionType::AUDIO_CAPTURE || | 264 permission == PermissionType::AUDIO_CAPTURE || |
| 257 permission == PermissionType::VIDEO_CAPTURE) { | 265 permission == PermissionType::VIDEO_CAPTURE) { |
| 258 RecordPermissionAction(permission, REVOKED, source_ui, revoked_origin, | 266 // An unknown gesture type is passed in since gesture type is only |
| 259 profile); | 267 // applicable in prompt UIs where revocations are not possible. |
| 268 RecordPermissionAction(permission, REVOKED, source_ui, |
| 269 PermissionRequestGestureType::UNKNOWN, |
| 270 revoked_origin, profile); |
| 260 } | 271 } |
| 261 } | 272 } |
| 262 | 273 |
| 263 void PermissionUmaUtil::PermissionPromptShown( | 274 void PermissionUmaUtil::PermissionPromptShown( |
| 264 const std::vector<PermissionRequest*>& requests) { | 275 const std::vector<PermissionRequest*>& requests) { |
| 265 DCHECK(!requests.empty()); | 276 DCHECK(!requests.empty()); |
| 266 | 277 |
| 267 PermissionRequestType permission_prompt_type = | 278 PermissionRequestType permission_prompt_type = |
| 268 PermissionRequestType::MULTIPLE; | 279 PermissionRequestType::MULTIPLE; |
| 269 PermissionRequestGestureType permission_gesture_type = | 280 PermissionRequestGestureType permission_gesture_type = |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 syncer::ModelTypeSet preferred_data_types = | 381 syncer::ModelTypeSet preferred_data_types = |
| 371 profile_sync_service->GetPreferredDataTypes(); | 382 profile_sync_service->GetPreferredDataTypes(); |
| 372 if (!preferred_data_types.Has(syncer::PROXY_TABS)) | 383 if (!preferred_data_types.Has(syncer::PROXY_TABS)) |
| 373 return false; | 384 return false; |
| 374 if (!preferred_data_types.Has(syncer::PRIORITY_PREFERENCES)) | 385 if (!preferred_data_types.Has(syncer::PRIORITY_PREFERENCES)) |
| 375 return false; | 386 return false; |
| 376 | 387 |
| 377 return true; | 388 return true; |
| 378 } | 389 } |
| 379 | 390 |
| 380 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, | 391 void PermissionUmaUtil::RecordPermissionAction( |
| 381 PermissionAction action, | 392 PermissionType permission, |
| 382 PermissionSourceUI source_ui, | 393 PermissionAction action, |
| 383 const GURL& requesting_origin, | 394 PermissionSourceUI source_ui, |
| 384 Profile* profile) { | 395 PermissionRequestGestureType gesture_type, |
| 396 const GURL& requesting_origin, |
| 397 Profile* profile) { |
| 385 if (IsOptedIntoPermissionActionReporting(profile)) { | 398 if (IsOptedIntoPermissionActionReporting(profile)) { |
| 386 // TODO(stefanocs): Add browsertests to make sure the reports are being | 399 // TODO(stefanocs): Add browsertests to make sure the reports are being |
| 387 // sent. | 400 // sent. |
| 388 // TODO(stefanocs): Get the actual |user_gesture| from permission layer. | |
| 389 g_browser_process->safe_browsing_service() | 401 g_browser_process->safe_browsing_service() |
| 390 ->ui_manager() | 402 ->ui_manager() |
| 391 ->ReportPermissionAction(requesting_origin, permission, action, | 403 ->ReportPermissionAction(requesting_origin, permission, action, |
| 392 source_ui, | 404 source_ui, gesture_type); |
| 393 PermissionRequestGestureType::UNKNOWN); | |
| 394 } | 405 } |
| 395 | 406 |
| 396 bool secure_origin = content::IsOriginSecure(requesting_origin); | 407 bool secure_origin = content::IsOriginSecure(requesting_origin); |
| 397 | 408 |
| 398 switch (permission) { | 409 switch (permission) { |
| 399 case PermissionType::GEOLOCATION: | 410 case PermissionType::GEOLOCATION: |
| 400 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation", | 411 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation", |
| 401 "Permissions.Action.SecureOrigin.Geolocation", | 412 "Permissions.Action.SecureOrigin.Geolocation", |
| 402 "Permissions.Action.InsecureOrigin.Geolocation", | 413 "Permissions.Action.InsecureOrigin.Geolocation", |
| 403 action); | 414 action); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 if (!deprecated_metric.empty() && rappor_service) { | 474 if (!deprecated_metric.empty() && rappor_service) { |
| 464 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, | 475 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, |
| 465 requesting_origin); | 476 requesting_origin); |
| 466 | 477 |
| 467 std::string rappor_metric = deprecated_metric + "2"; | 478 std::string rappor_metric = deprecated_metric + "2"; |
| 468 rappor_service->RecordSample( | 479 rappor_service->RecordSample( |
| 469 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, | 480 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 470 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); | 481 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); |
| 471 } | 482 } |
| 472 } | 483 } |
| OLD | NEW |