Chromium Code Reviews| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 void PermissionUmaUtil::PermissionRequested(PermissionType permission, | 189 void PermissionUmaUtil::PermissionRequested(PermissionType permission, |
| 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 SourceUI source_ui, | |
| 199 Profile* profile) { | 200 Profile* profile) { |
| 200 RecordPermissionAction(permission, GRANTED, requesting_origin, profile); | 201 RecordPermissionAction(permission, GRANTED, requesting_origin, source_ui, |
| 202 profile); | |
| 201 } | 203 } |
| 202 | 204 |
| 203 void PermissionUmaUtil::PermissionDenied(PermissionType permission, | 205 void PermissionUmaUtil::PermissionDenied(PermissionType permission, |
| 204 const GURL& requesting_origin, | 206 const GURL& requesting_origin, |
| 207 SourceUI source_ui, | |
| 205 Profile* profile) { | 208 Profile* profile) { |
| 206 RecordPermissionAction(permission, DENIED, requesting_origin, profile); | 209 RecordPermissionAction(permission, DENIED, requesting_origin, source_ui, |
| 210 profile); | |
| 207 } | 211 } |
| 208 | 212 |
| 209 void PermissionUmaUtil::PermissionDismissed(PermissionType permission, | 213 void PermissionUmaUtil::PermissionDismissed(PermissionType permission, |
| 210 const GURL& requesting_origin, | 214 const GURL& requesting_origin, |
| 215 SourceUI source_ui, | |
| 211 Profile* profile) { | 216 Profile* profile) { |
| 212 RecordPermissionAction(permission, DISMISSED, requesting_origin, profile); | 217 RecordPermissionAction(permission, DISMISSED, requesting_origin, source_ui, |
| 218 profile); | |
| 213 } | 219 } |
| 214 | 220 |
| 215 void PermissionUmaUtil::PermissionIgnored(PermissionType permission, | 221 void PermissionUmaUtil::PermissionIgnored(PermissionType permission, |
| 216 const GURL& requesting_origin, | 222 const GURL& requesting_origin, |
| 223 SourceUI source_ui, | |
| 217 Profile* profile) { | 224 Profile* profile) { |
| 218 RecordPermissionAction(permission, IGNORED, requesting_origin, profile); | 225 RecordPermissionAction(permission, IGNORED, requesting_origin, source_ui, |
| 226 profile); | |
| 219 } | 227 } |
| 220 | 228 |
| 221 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, | 229 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, |
| 222 const GURL& revoked_origin, | 230 const GURL& revoked_origin, |
| 231 SourceUI source_ui, | |
|
kcarattini
2016/07/06 06:54:08
Add a TODO to add reporting for revocations from t
stefanocs
2016/07/07 01:26:03
Done. Revocations from the Page Action bubbles had
| |
| 223 Profile* profile) { | 232 Profile* profile) { |
| 224 // TODO(tsergeant): Expand metrics definitions for revocation to include all | 233 // TODO(tsergeant): Expand metrics definitions for revocation to include all |
| 225 // permissions. | 234 // permissions. |
| 226 if (permission == PermissionType::NOTIFICATIONS || | 235 if (permission == PermissionType::NOTIFICATIONS || |
| 227 permission == PermissionType::GEOLOCATION || | 236 permission == PermissionType::GEOLOCATION || |
| 228 permission == PermissionType::AUDIO_CAPTURE || | 237 permission == PermissionType::AUDIO_CAPTURE || |
| 229 permission == PermissionType::VIDEO_CAPTURE) { | 238 permission == PermissionType::VIDEO_CAPTURE) { |
| 230 RecordPermissionAction(permission, REVOKED, revoked_origin, profile); | 239 RecordPermissionAction(permission, REVOKED, revoked_origin, source_ui, |
| 240 profile); | |
| 231 } | 241 } |
| 232 } | 242 } |
| 233 | 243 |
| 234 void PermissionUmaUtil::PermissionPromptShown( | 244 void PermissionUmaUtil::PermissionPromptShown( |
| 235 const std::vector<PermissionBubbleRequest*>& requests) { | 245 const std::vector<PermissionBubbleRequest*>& requests) { |
| 236 DCHECK(!requests.empty()); | 246 DCHECK(!requests.empty()); |
| 237 | 247 |
| 238 PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; | 248 PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; |
| 239 if (requests.size() == 1) | 249 if (requests.size() == 1) |
| 240 permission_prompt_type = requests[0]->GetPermissionBubbleType(); | 250 permission_prompt_type = requests[0]->GetPermissionBubbleType(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 return false; | 342 return false; |
| 333 // Do not report if Chrome Pref Sync is not enabled. | 343 // Do not report if Chrome Pref Sync is not enabled. |
| 334 if (!preferred_data_types.Has(syncer::PREFERENCES)) | 344 if (!preferred_data_types.Has(syncer::PREFERENCES)) |
| 335 return false; | 345 return false; |
| 336 return true; | 346 return true; |
| 337 } | 347 } |
| 338 | 348 |
| 339 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, | 349 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, |
| 340 PermissionAction action, | 350 PermissionAction action, |
| 341 const GURL& requesting_origin, | 351 const GURL& requesting_origin, |
| 352 SourceUI source_ui, | |
| 342 Profile* profile) { | 353 Profile* profile) { |
| 343 // Send permission action report to opted-in users. | 354 // Send permission action report to opted-in users. |
| 344 if (IsOptedInPermissionActionReporting(profile)) { | 355 if (IsOptedInPermissionActionReporting(profile)) { |
| 345 g_browser_process->safe_browsing_service() | 356 g_browser_process->safe_browsing_service() |
| 346 ->ui_manager() | 357 ->ui_manager() |
| 347 ->ReportPermissionAction(requesting_origin, permission, action); | 358 ->ReportPermissionAction(requesting_origin, permission, action, |
| 359 source_ui); | |
| 348 } | 360 } |
| 349 | 361 |
| 350 bool secure_origin = content::IsOriginSecure(requesting_origin); | 362 bool secure_origin = content::IsOriginSecure(requesting_origin); |
| 351 | 363 |
| 352 switch (permission) { | 364 switch (permission) { |
| 353 case PermissionType::GEOLOCATION: | 365 case PermissionType::GEOLOCATION: |
| 354 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation", | 366 PERMISSION_ACTION_UMA(secure_origin, "Permissions.Action.Geolocation", |
| 355 "Permissions.Action.SecureOrigin.Geolocation", | 367 "Permissions.Action.SecureOrigin.Geolocation", |
| 356 "Permissions.Action.InsecureOrigin.Geolocation", | 368 "Permissions.Action.InsecureOrigin.Geolocation", |
| 357 action); | 369 action); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 if (!deprecated_metric.empty() && rappor_service) { | 429 if (!deprecated_metric.empty() && rappor_service) { |
| 418 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, | 430 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, |
| 419 requesting_origin); | 431 requesting_origin); |
| 420 | 432 |
| 421 std::string rappor_metric = deprecated_metric + "2"; | 433 std::string rappor_metric = deprecated_metric + "2"; |
| 422 rappor_service->RecordSample( | 434 rappor_service->RecordSample( |
| 423 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, | 435 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 424 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); | 436 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); |
| 425 } | 437 } |
| 426 } | 438 } |
| OLD | NEW |