| 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 true /* user_gesture */, revoked_origin, profile); |
| 237 } | 241 } |
| 238 } | 242 } |
| 239 | 243 |
| 240 void PermissionUmaUtil::PermissionPromptShown( | 244 void PermissionUmaUtil::PermissionPromptShown( |
| 241 const std::vector<PermissionBubbleRequest*>& requests) { | 245 const std::vector<PermissionBubbleRequest*>& requests) { |
| 242 DCHECK(!requests.empty()); | 246 DCHECK(!requests.empty()); |
| 243 | 247 |
| 244 PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; | 248 PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; |
| 245 if (requests.size() == 1) | 249 if (requests.size() == 1) |
| 246 permission_prompt_type = requests[0]->GetPermissionBubbleType(); | 250 permission_prompt_type = requests[0]->GetPermissionBubbleType(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return false; | 331 return false; |
| 328 if (!preferred_data_types.Has(syncer::PRIORITY_PREFERENCES)) | 332 if (!preferred_data_types.Has(syncer::PRIORITY_PREFERENCES)) |
| 329 return false; | 333 return false; |
| 330 | 334 |
| 331 return true; | 335 return true; |
| 332 } | 336 } |
| 333 | 337 |
| 334 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, | 338 void PermissionUmaUtil::RecordPermissionAction(PermissionType permission, |
| 335 PermissionAction action, | 339 PermissionAction action, |
| 336 PermissionSourceUI source_ui, | 340 PermissionSourceUI source_ui, |
| 341 bool user_gesture, |
| 337 const GURL& requesting_origin, | 342 const GURL& requesting_origin, |
| 338 Profile* profile) { | 343 Profile* profile) { |
| 339 if (IsOptedIntoPermissionActionReporting(profile)) { | 344 if (IsOptedIntoPermissionActionReporting(profile)) { |
| 340 // TODO(stefanocs): Add browsertests to make sure the reports are being | 345 // TODO(stefanocs): Add browsertests to make sure the reports are being |
| 341 // sent. | 346 // sent. |
| 342 // TODO(stefanocs): Get the actual |user_gesture| from permission layer. | 347 // TODO(stefanocs): Get the actual |user_gesture| from permission layer. |
| 343 g_browser_process->safe_browsing_service() | 348 g_browser_process->safe_browsing_service() |
| 344 ->ui_manager() | 349 ->ui_manager() |
| 345 ->ReportPermissionAction(requesting_origin, permission, action, | 350 ->ReportPermissionAction(requesting_origin, permission, action, |
| 346 source_ui, false); | 351 source_ui, false); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 if (!deprecated_metric.empty() && rappor_service) { | 421 if (!deprecated_metric.empty() && rappor_service) { |
| 417 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, | 422 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, |
| 418 requesting_origin); | 423 requesting_origin); |
| 419 | 424 |
| 420 std::string rappor_metric = deprecated_metric + "2"; | 425 std::string rappor_metric = deprecated_metric + "2"; |
| 421 rappor_service->RecordSample( | 426 rappor_service->RecordSample( |
| 422 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, | 427 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 423 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); | 428 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); |
| 424 } | 429 } |
| 425 } | 430 } |
| OLD | NEW |