| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 const GURL& requesting_origin, | 190 const GURL& requesting_origin, |
| 191 const GURL& embedding_origin, | 191 const GURL& embedding_origin, |
| 192 Profile* profile) { | 192 Profile* profile) { |
| 193 RecordPermissionRequest(permission, requesting_origin, embedding_origin, | 193 RecordPermissionRequest(permission, requesting_origin, embedding_origin, |
| 194 profile); | 194 profile); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void PermissionUmaUtil::PermissionGranted(PermissionType permission, | 197 void PermissionUmaUtil::PermissionGranted(PermissionType permission, |
| 198 const GURL& requesting_origin, | 198 const GURL& requesting_origin, |
| 199 Profile* profile) { | 199 Profile* profile) { |
| 200 RecordPermissionAction(permission, GRANTED, requesting_origin, profile); | 200 RecordPermissionAction(permission, GRANTED, requesting_origin, PROMPT, |
| 201 profile); |
| 201 } | 202 } |
| 202 | 203 |
| 203 void PermissionUmaUtil::PermissionDenied(PermissionType permission, | 204 void PermissionUmaUtil::PermissionDenied(PermissionType permission, |
| 204 const GURL& requesting_origin, | 205 const GURL& requesting_origin, |
| 205 Profile* profile) { | 206 Profile* profile) { |
| 206 RecordPermissionAction(permission, DENIED, requesting_origin, profile); | 207 RecordPermissionAction(permission, DENIED, requesting_origin, PROMPT, |
| 208 profile); |
| 207 } | 209 } |
| 208 | 210 |
| 209 void PermissionUmaUtil::PermissionDismissed(PermissionType permission, | 211 void PermissionUmaUtil::PermissionDismissed(PermissionType permission, |
| 210 const GURL& requesting_origin, | 212 const GURL& requesting_origin, |
| 211 Profile* profile) { | 213 Profile* profile) { |
| 212 RecordPermissionAction(permission, DISMISSED, requesting_origin, profile); | 214 RecordPermissionAction(permission, DISMISSED, requesting_origin, PROMPT, |
| 215 profile); |
| 213 } | 216 } |
| 214 | 217 |
| 215 void PermissionUmaUtil::PermissionIgnored(PermissionType permission, | 218 void PermissionUmaUtil::PermissionIgnored(PermissionType permission, |
| 216 const GURL& requesting_origin, | 219 const GURL& requesting_origin, |
| 217 Profile* profile) { | 220 Profile* profile) { |
| 218 RecordPermissionAction(permission, IGNORED, requesting_origin, profile); | 221 RecordPermissionAction(permission, IGNORED, requesting_origin, PROMPT, |
| 222 profile); |
| 219 } | 223 } |
| 220 | 224 |
| 221 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, | 225 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, |
| 222 const GURL& revoked_origin, | 226 const GURL& revoked_origin, |
| 227 SourceUI source_ui, |
| 223 Profile* profile) { | 228 Profile* profile) { |
| 224 // TODO(tsergeant): Expand metrics definitions for revocation to include all | 229 // TODO(tsergeant): Expand metrics definitions for revocation to include all |
| 225 // permissions. | 230 // permissions. |
| 226 if (permission == PermissionType::NOTIFICATIONS || | 231 if (permission == PermissionType::NOTIFICATIONS || |
| 227 permission == PermissionType::GEOLOCATION || | 232 permission == PermissionType::GEOLOCATION || |
| 228 permission == PermissionType::AUDIO_CAPTURE || | 233 permission == PermissionType::AUDIO_CAPTURE || |
| 229 permission == PermissionType::VIDEO_CAPTURE) { | 234 permission == PermissionType::VIDEO_CAPTURE) { |
| 230 RecordPermissionAction(permission, REVOKED, revoked_origin, profile); | 235 RecordPermissionAction(permission, REVOKED, revoked_origin, source_ui, |
| 236 profile); |
| 231 } | 237 } |
| 232 } | 238 } |
| 233 | 239 |
| 234 void PermissionUmaUtil::PermissionPromptShown( | 240 void PermissionUmaUtil::PermissionPromptShown( |
| 235 const std::vector<PermissionBubbleRequest*>& requests) { | 241 const std::vector<PermissionBubbleRequest*>& requests) { |
| 236 DCHECK(!requests.empty()); | 242 DCHECK(!requests.empty()); |
| 237 | 243 |
| 238 PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; | 244 PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; |
| 239 if (requests.size() == 1) | 245 if (requests.size() == 1) |
| 240 permission_prompt_type = requests[0]->GetPermissionBubbleType(); | 246 permission_prompt_type = requests[0]->GetPermissionBubbleType(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 return false; | 331 return false; |
| 326 if (!preferred_data_types.Has(syncer::PREFERENCES)) | 332 if (!preferred_data_types.Has(syncer::PREFERENCES)) |
| 327 return false; | 333 return false; |
| 328 | 334 |
| 329 return true; | 335 return true; |
| 330 } | 336 } |
| 331 | 337 |
| 332 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, | 338 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, |
| 333 PermissionAction action, | 339 PermissionAction action, |
| 334 const GURL& requesting_origin, | 340 const GURL& requesting_origin, |
| 341 SourceUI source_ui, |
| 335 Profile* profile) { | 342 Profile* profile) { |
| 336 if (IsOptedIntoPermissionActionReporting(profile)) { | 343 if (IsOptedIntoPermissionActionReporting(profile)) { |
| 337 // TODO(stefanocs): Add browsertests to make sure the reports are being | 344 // TODO(stefanocs): Add browsertests to make sure the reports are being |
| 338 // sent. | 345 // sent. |
| 339 g_browser_process->safe_browsing_service() | 346 g_browser_process->safe_browsing_service() |
| 340 ->ui_manager() | 347 ->ui_manager() |
| 341 ->ReportPermissionAction(requesting_origin, permission, action); | 348 ->ReportPermissionAction(requesting_origin, permission, action, |
| 349 source_ui); |
| 342 } | 350 } |
| 343 | 351 |
| 344 bool secure_origin = content::IsOriginSecure(requesting_origin); | 352 bool secure_origin = content::IsOriginSecure(requesting_origin); |
| 345 | 353 |
| 346 switch (permission) { | 354 switch (permission) { |
| 347 case PermissionType::GEOLOCATION: | 355 case PermissionType::GEOLOCATION: |
| 348 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation", | 356 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation", |
| 349 "Permissions.Action.SecureOrigin.Geolocation", | 357 "Permissions.Action.SecureOrigin.Geolocation", |
| 350 "Permissions.Action.InsecureOrigin.Geolocation", | 358 "Permissions.Action.InsecureOrigin.Geolocation", |
| 351 action); | 359 action); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 if (!deprecated_metric.empty() && rappor_service) { | 419 if (!deprecated_metric.empty() && rappor_service) { |
| 412 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, | 420 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, |
| 413 requesting_origin); | 421 requesting_origin); |
| 414 | 422 |
| 415 std::string rappor_metric = deprecated_metric + "2"; | 423 std::string rappor_metric = deprecated_metric + "2"; |
| 416 rappor_service->RecordSample( | 424 rappor_service->RecordSample( |
| 417 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, | 425 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 418 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); | 426 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); |
| 419 } | 427 } |
| 420 } | 428 } |
| OLD | NEW |