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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 // add new permission | 188 // add new permission |
| 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 bool user_gesture, | |
| 198 const GURL& requesting_origin, | 199 const GURL& requesting_origin, |
| 199 Profile* profile) { | 200 Profile* profile) { |
| 200 RecordPermissionAction(permission, GRANTED, PermissionSourceUI::PROMPT, | 201 RecordPermissionAction(permission, GRANTED, PermissionSourceUI::PROMPT, |
| 201 requesting_origin, profile); | 202 user_gesture, requesting_origin, profile); |
| 202 } | 203 } |
| 203 | 204 |
| 204 void PermissionUmaUtil::PermissionDenied(PermissionType permission, | 205 void PermissionUmaUtil::PermissionDenied(PermissionType permission, |
| 206 bool user_gesture, | |
| 205 const GURL& requesting_origin, | 207 const GURL& requesting_origin, |
| 206 Profile* profile) { | 208 Profile* profile) { |
| 207 RecordPermissionAction(permission, DENIED, PermissionSourceUI::PROMPT, | 209 RecordPermissionAction(permission, DENIED, PermissionSourceUI::PROMPT, |
| 208 requesting_origin, profile); | 210 user_gesture, requesting_origin, profile); |
| 209 } | 211 } |
| 210 | 212 |
| 211 void PermissionUmaUtil::PermissionDismissed(PermissionType permission, | 213 void PermissionUmaUtil::PermissionDismissed(PermissionType permission, |
| 214 bool user_gesture, | |
| 212 const GURL& requesting_origin, | 215 const GURL& requesting_origin, |
| 213 Profile* profile) { | 216 Profile* profile) { |
| 214 RecordPermissionAction(permission, DISMISSED, PermissionSourceUI::PROMPT, | 217 RecordPermissionAction(permission, DISMISSED, PermissionSourceUI::PROMPT, |
| 215 requesting_origin, profile); | 218 user_gesture, requesting_origin, profile); |
| 216 } | 219 } |
| 217 | 220 |
| 218 void PermissionUmaUtil::PermissionIgnored(PermissionType permission, | 221 void PermissionUmaUtil::PermissionIgnored(PermissionType permission, |
| 222 bool user_gesture, | |
| 219 const GURL& requesting_origin, | 223 const GURL& requesting_origin, |
| 220 Profile* profile) { | 224 Profile* profile) { |
| 221 RecordPermissionAction(permission, IGNORED, PermissionSourceUI::PROMPT, | 225 RecordPermissionAction(permission, IGNORED, PermissionSourceUI::PROMPT, |
| 222 requesting_origin, profile); | 226 user_gesture, requesting_origin, profile); |
| 223 } | 227 } |
| 224 | 228 |
| 225 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, | 229 void PermissionUmaUtil::PermissionRevoked(PermissionType permission, |
| 226 PermissionSourceUI source_ui, | 230 PermissionSourceUI source_ui, |
| 227 const GURL& revoked_origin, | 231 const GURL& revoked_origin, |
| 228 Profile* profile) { | 232 Profile* profile) { |
| 229 // TODO(tsergeant): Expand metrics definitions for revocation to include all | 233 // TODO(tsergeant): Expand metrics definitions for revocation to include all |
| 230 // permissions. | 234 // permissions. |
| 231 if (permission == PermissionType::NOTIFICATIONS || | 235 if (permission == PermissionType::NOTIFICATIONS || |
| 232 permission == PermissionType::GEOLOCATION || | 236 permission == PermissionType::GEOLOCATION || |
| 233 permission == PermissionType::AUDIO_CAPTURE || | 237 permission == PermissionType::AUDIO_CAPTURE || |
| 234 permission == PermissionType::VIDEO_CAPTURE) { | 238 permission == PermissionType::VIDEO_CAPTURE) { |
| 235 RecordPermissionAction(permission, REVOKED, source_ui, revoked_origin, | 239 RecordPermissionAction(permission, REVOKED, source_ui, |
| 236 profile); | 240 false /* user_gesture */, revoked_origin, profile); |
|
timvolodine
2016/07/25 13:58:58
is this because we don't have user gestures for re
stefanocs
2016/07/25 14:22:05
Yes, revocations can only be triggered when user c
| |
| 237 } | 241 } |
| 238 } | 242 } |
| 239 | 243 |
| 240 void PermissionUmaUtil::PermissionPromptShown( | 244 void PermissionUmaUtil::PermissionPromptShown( |
| 241 const std::vector<PermissionRequest*>& requests) { | 245 const std::vector<PermissionRequest*>& requests) { |
| 242 DCHECK(!requests.empty()); | 246 DCHECK(!requests.empty()); |
| 243 | 247 |
| 244 PermissionRequestType permission_prompt_type = | 248 PermissionRequestType permission_prompt_type = |
| 245 PermissionRequestType::MULTIPLE; | 249 PermissionRequestType::MULTIPLE; |
| 246 if (requests.size() == 1) | 250 if (requests.size() == 1) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 return false; | 334 return false; |
| 331 if (!preferred_data_types.Has(syncer::PRIORITY_PREFERENCES)) | 335 if (!preferred_data_types.Has(syncer::PRIORITY_PREFERENCES)) |
| 332 return false; | 336 return false; |
| 333 | 337 |
| 334 return true; | 338 return true; |
| 335 } | 339 } |
| 336 | 340 |
| 337 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, | 341 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, |
| 338 PermissionAction action, | 342 PermissionAction action, |
| 339 PermissionSourceUI source_ui, | 343 PermissionSourceUI source_ui, |
| 344 bool user_gesture, | |
|
timvolodine
2016/07/25 13:58:58
so this is passed but not used? am I missing somet
stefanocs
2016/07/25 14:22:05
Oh right, I missed this one, this should be passed
stefanocs
2016/07/26 00:37:10
Done.
| |
| 340 const GURL& requesting_origin, | 345 const GURL& requesting_origin, |
| 341 Profile* profile) { | 346 Profile* profile) { |
| 342 if (IsOptedIntoPermissionActionReporting(profile)) { | 347 if (IsOptedIntoPermissionActionReporting(profile)) { |
| 343 // TODO(stefanocs): Add browsertests to make sure the reports are being | 348 // TODO(stefanocs): Add browsertests to make sure the reports are being |
| 344 // sent. | 349 // sent. |
| 345 // TODO(stefanocs): Get the actual |user_gesture| from permission layer. | 350 // TODO(stefanocs): Get the actual |user_gesture| from permission layer. |
| 346 g_browser_process->safe_browsing_service() | 351 g_browser_process->safe_browsing_service() |
| 347 ->ui_manager() | 352 ->ui_manager() |
| 348 ->ReportPermissionAction(requesting_origin, permission, action, | 353 ->ReportPermissionAction(requesting_origin, permission, action, |
| 349 source_ui, false /* user_gesture */); | 354 source_ui, false /* user_gesture */); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 if (!deprecated_metric.empty() && rappor_service) { | 424 if (!deprecated_metric.empty() && rappor_service) { |
| 420 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, | 425 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, |
| 421 requesting_origin); | 426 requesting_origin); |
| 422 | 427 |
| 423 std::string rappor_metric = deprecated_metric + "2"; | 428 std::string rappor_metric = deprecated_metric + "2"; |
| 424 rappor_service->RecordSample( | 429 rappor_service->RecordSample( |
| 425 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, | 430 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 426 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); | 431 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); |
| 427 } | 432 } |
| 428 } | 433 } |
| OLD | NEW |