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

Side by Side Diff: chrome/browser/prefs/pref_metrics_service.cc

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months 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
« no previous file with comments | « chrome/browser/prefs/browser_prefs.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/prefs/pref_metrics_service.h" 5 #include "chrome/browser/prefs/pref_metrics_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/browser_shutdown.h" 14 #include "chrome/browser/browser_shutdown.h"
15 #include "chrome/browser/prefs/pref_service_syncable.h" 15 #include "chrome/browser/prefs/pref_service_syncable.h"
16 #include "chrome/browser/prefs/session_startup_pref.h" 16 #include "chrome/browser/prefs/session_startup_pref.h"
17 #include "chrome/browser/prefs/synced_pref_change_registrar.h" 17 #include "chrome/browser/prefs/synced_pref_change_registrar.h"
18 #include "chrome/browser/profiles/incognito_helpers.h" 18 #include "chrome/browser/profiles/incognito_helpers.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 20 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
21 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" 21 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
22 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 24 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
25 #include "components/rappor/rappor_service.h"
25 #include "crypto/hmac.h" 26 #include "crypto/hmac.h"
26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 27 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
27 28
28 namespace { 29 namespace {
29 30
30 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax; 31 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax;
31 32
32 } // namespace 33 } // namespace
33 34
34 PrefMetricsService::PrefMetricsService(Profile* profile) 35 PrefMetricsService::PrefMetricsService(Profile* profile)
(...skipping 28 matching lines...) Expand all
63 if (show_home_button) { 64 if (show_home_button) {
64 UMA_HISTOGRAM_BOOLEAN("Settings.GivenShowHomeButton_HomePageIsNewTabPage", 65 UMA_HISTOGRAM_BOOLEAN("Settings.GivenShowHomeButton_HomePageIsNewTabPage",
65 home_page_is_ntp); 66 home_page_is_ntp);
66 } 67 }
67 68
68 // For non-NTP homepages, see if the URL comes from the same TLD+1 as a known 69 // For non-NTP homepages, see if the URL comes from the same TLD+1 as a known
69 // search engine. Note that this is only an approximation of search engine 70 // search engine. Note that this is only an approximation of search engine
70 // use, due to both false negatives (pages that come from unknown TLD+1 X but 71 // use, due to both false negatives (pages that come from unknown TLD+1 X but
71 // consist of a search box that sends to known TLD+1 Y) and false positives 72 // consist of a search box that sends to known TLD+1 Y) and false positives
72 // (pages that share a TLD+1 with a known engine but aren't actually search 73 // (pages that share a TLD+1 with a known engine but aren't actually search
73 // pages, e.g. plus.google.com). 74 // pages, e.g. plus.google.com). Additionally, record the TLD+1 of non-NTP
75 // homepages through the privacy-preserving Rappor service.
74 if (!home_page_is_ntp) { 76 if (!home_page_is_ntp) {
75 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); 77 GURL homepage_url(prefs_->GetString(prefs::kHomePage));
76 if (homepage_url.is_valid()) { 78 if (homepage_url.is_valid()) {
77 UMA_HISTOGRAM_ENUMERATION( 79 UMA_HISTOGRAM_ENUMERATION(
78 "Settings.HomePageEngineType", 80 "Settings.HomePageEngineType",
79 TemplateURLPrepopulateData::GetEngineType(homepage_url), 81 TemplateURLPrepopulateData::GetEngineType(homepage_url),
80 SEARCH_ENGINE_MAX); 82 SEARCH_ENGINE_MAX);
83 if (g_browser_process->rappor_service()) {
84 g_browser_process->rappor_service()->RecordSample(
85 "Settings.HomePage",
86 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE,
87 net::registry_controlled_domains::GetDomainAndRegistry(homepage_url,
88 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES));
89 }
81 } 90 }
82 } 91 }
83 92
84 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); 93 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup);
85 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", 94 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings",
86 restore_on_startup, kSessionStartupPrefValueMax); 95 restore_on_startup, kSessionStartupPrefValueMax);
87 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { 96 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) {
88 const base::ListValue* url_list = 97 const base::ListValue* url_list =
89 prefs_->GetList(prefs::kURLsToRestoreOnStartup); 98 prefs_->GetList(prefs::kURLsToRestoreOnStartup);
90 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", 99 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs",
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 224 }
216 225
217 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { 226 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const {
218 return false; 227 return false;
219 } 228 }
220 229
221 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( 230 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse(
222 content::BrowserContext* context) const { 231 content::BrowserContext* context) const {
223 return chrome::GetBrowserContextRedirectedInIncognito(context); 232 return chrome::GetBrowserContextRedirectedInIncognito(context);
224 } 233 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/browser_prefs.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698