Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: chrome/browser/permissions/permission_uma_util.cc

Issue 2510803003: Pass RapporService to content/browser/ (Closed)
Patch Set: Fix an Android compile error Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" 13 #include "chrome/browser/permissions/permission_decision_auto_blocker.h"
14 #include "chrome/browser/permissions/permission_manager.h" 14 #include "chrome/browser/permissions/permission_manager.h"
15 #include "chrome/browser/permissions/permission_request.h" 15 #include "chrome/browser/permissions/permission_request.h"
16 #include "chrome/browser/permissions/permission_util.h" 16 #include "chrome/browser/permissions/permission_util.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 18 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
19 #include "chrome/browser/safe_browsing/ui_manager.h" 19 #include "chrome/browser/safe_browsing/ui_manager.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 20 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "components/browser_sync/profile_sync_service.h" 23 #include "components/browser_sync/profile_sync_service.h"
24 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
25 #include "components/rappor/public/rappor_utils.h"
25 #include "components/rappor/rappor_service.h" 26 #include "components/rappor/rappor_service.h"
26 #include "components/rappor/rappor_utils.h"
27 #include "content/public/browser/permission_type.h" 27 #include "content/public/browser/permission_type.h"
28 #include "content/public/common/origin_util.h" 28 #include "content/public/common/origin_util.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
31 // UMA keys need to be statically initialized so plain function would not 31 // UMA keys need to be statically initialized so plain function would not
32 // work. Use macros instead. 32 // work. Use macros instead.
33 #define PERMISSION_ACTION_UMA(secure_origin, permission, permission_secure, \ 33 #define PERMISSION_ACTION_UMA(secure_origin, permission, permission_secure, \
34 permission_insecure, action) \ 34 permission_insecure, action) \
35 UMA_HISTOGRAM_ENUMERATION(permission, action, PERMISSION_ACTION_NUM); \ 35 UMA_HISTOGRAM_ENUMERATION(permission, action, PERMISSION_ACTION_NUM); \
36 if (secure_origin) { \ 36 if (secure_origin) { \
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 const GURL& requesting_origin, 97 const GURL& requesting_origin,
98 const GURL& embedding_origin, 98 const GURL& embedding_origin,
99 Profile* profile) { 99 Profile* profile) {
100 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); 100 rappor::RapporService* rappor_service = g_browser_process->rappor_service();
101 if (rappor_service) { 101 if (rappor_service) {
102 if (permission == PermissionType::GEOLOCATION) { 102 if (permission == PermissionType::GEOLOCATION) {
103 // TODO(dominickn): remove this deprecated metric - crbug.com/605836. 103 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
104 rappor::SampleDomainAndRegistryFromGURL( 104 rappor::SampleDomainAndRegistryFromGURL(
105 rappor_service, "ContentSettings.PermissionRequested.Geolocation.Url", 105 rappor_service, "ContentSettings.PermissionRequested.Geolocation.Url",
106 requesting_origin); 106 requesting_origin);
107 rappor_service->RecordSample( 107 rappor_service->RecordSampleString(
108 "ContentSettings.PermissionRequested.Geolocation.Url2", 108 "ContentSettings.PermissionRequested.Geolocation.Url2",
109 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 109 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
110 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 110 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
111 } else if (permission == PermissionType::NOTIFICATIONS) { 111 } else if (permission == PermissionType::NOTIFICATIONS) {
112 // TODO(dominickn): remove this deprecated metric - crbug.com/605836. 112 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
113 rappor::SampleDomainAndRegistryFromGURL( 113 rappor::SampleDomainAndRegistryFromGURL(
114 rappor_service, 114 rappor_service,
115 "ContentSettings.PermissionRequested.Notifications.Url", 115 "ContentSettings.PermissionRequested.Notifications.Url",
116 requesting_origin); 116 requesting_origin);
117 rappor_service->RecordSample( 117 rappor_service->RecordSampleString(
118 "ContentSettings.PermissionRequested.Notifications.Url2", 118 "ContentSettings.PermissionRequested.Notifications.Url2",
119 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 119 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
120 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 120 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
121 } else if (permission == PermissionType::MIDI || 121 } else if (permission == PermissionType::MIDI ||
122 permission == PermissionType::MIDI_SYSEX) { 122 permission == PermissionType::MIDI_SYSEX) {
123 // TODO(dominickn): remove this deprecated metric - crbug.com/605836. 123 // TODO(dominickn): remove this deprecated metric - crbug.com/605836.
124 rappor::SampleDomainAndRegistryFromGURL( 124 rappor::SampleDomainAndRegistryFromGURL(
125 rappor_service, "ContentSettings.PermissionRequested.Midi.Url", 125 rappor_service, "ContentSettings.PermissionRequested.Midi.Url",
126 requesting_origin); 126 requesting_origin);
127 rappor_service->RecordSample( 127 rappor_service->RecordSampleString(
128 "ContentSettings.PermissionRequested.Midi.Url2", 128 "ContentSettings.PermissionRequested.Midi.Url2",
129 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 129 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
130 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 130 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
131 } else if (permission == PermissionType::PROTECTED_MEDIA_IDENTIFIER) { 131 } else if (permission == PermissionType::PROTECTED_MEDIA_IDENTIFIER) {
132 rappor_service->RecordSample( 132 rappor_service->RecordSampleString(
133 "ContentSettings.PermissionRequested.ProtectedMedia.Url2", 133 "ContentSettings.PermissionRequested.ProtectedMedia.Url2",
134 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 134 rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
135 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 135 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
136 } 136 }
137 } 137 }
138 138
139 bool secure_origin = content::IsOriginSecure(requesting_origin); 139 bool secure_origin = content::IsOriginSecure(requesting_origin);
140 UMA_HISTOGRAM_ENUMERATION( 140 UMA_HISTOGRAM_ENUMERATION(
141 "ContentSettings.PermissionRequested", 141 "ContentSettings.PermissionRequested",
142 static_cast<base::HistogramBase::Sample>(permission), 142 static_cast<base::HistogramBase::Sample>(permission),
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 // we retrieve the deprecated name and append the "2" for the new name. 709 // we retrieve the deprecated name and append the "2" for the new name.
710 // TODO(dominickn): remove the deprecated metric and replace it solely with 710 // TODO(dominickn): remove the deprecated metric and replace it solely with
711 // the new one in GetRapporMetric - crbug.com/605836. 711 // the new one in GetRapporMetric - crbug.com/605836.
712 const std::string deprecated_metric = GetRapporMetric(permission, action); 712 const std::string deprecated_metric = GetRapporMetric(permission, action);
713 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); 713 rappor::RapporService* rappor_service = g_browser_process->rappor_service();
714 if (!deprecated_metric.empty() && rappor_service) { 714 if (!deprecated_metric.empty() && rappor_service) {
715 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric, 715 rappor::SampleDomainAndRegistryFromGURL(rappor_service, deprecated_metric,
716 requesting_origin); 716 requesting_origin);
717 717
718 std::string rappor_metric = deprecated_metric + "2"; 718 std::string rappor_metric = deprecated_metric + "2";
719 rappor_service->RecordSample( 719 rappor_service->RecordSampleString(
720 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, 720 rappor_metric, rappor::LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
721 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin)); 721 rappor::GetDomainAndRegistrySampleFromGURL(requesting_origin));
722 } 722 }
723 } 723 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698