OLD | NEW |
---|---|
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/search.h" | |
20 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 21 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
21 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 22 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
24 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 25 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
25 #include "components/rappor/rappor_service.h" | 26 #include "components/rappor/rappor_utils.h" |
26 #include "crypto/hmac.h" | 27 #include "crypto/hmac.h" |
27 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 28 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax; | 32 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax; |
32 | 33 |
33 } // namespace | 34 } // namespace |
34 | 35 |
35 PrefMetricsService::PrefMetricsService(Profile* profile) | 36 PrefMetricsService::PrefMetricsService(Profile* profile) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 // (pages that share a TLD+1 with a known engine but aren't actually search | 74 // (pages that share a TLD+1 with a known engine but aren't actually search |
74 // pages, e.g. plus.google.com). Additionally, record the TLD+1 of non-NTP | 75 // pages, e.g. plus.google.com). Additionally, record the TLD+1 of non-NTP |
75 // homepages through the privacy-preserving Rappor service. | 76 // homepages through the privacy-preserving Rappor service. |
76 if (!home_page_is_ntp) { | 77 if (!home_page_is_ntp) { |
77 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); | 78 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); |
78 if (homepage_url.is_valid()) { | 79 if (homepage_url.is_valid()) { |
79 UMA_HISTOGRAM_ENUMERATION( | 80 UMA_HISTOGRAM_ENUMERATION( |
80 "Settings.HomePageEngineType", | 81 "Settings.HomePageEngineType", |
81 TemplateURLPrepopulateData::GetEngineType(homepage_url), | 82 TemplateURLPrepopulateData::GetEngineType(homepage_url), |
82 SEARCH_ENGINE_MAX); | 83 SEARCH_ENGINE_MAX); |
83 if (g_browser_process->rappor_service()) { | 84 rappor::SampleETLDp1(g_browser_process->rappor_service(), |
84 g_browser_process->rappor_service()->RecordSample( | 85 "Settings.HomePage2", |
85 "Settings.HomePage2", | 86 homepage_url); |
86 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, | |
87 net::registry_controlled_domains::GetDomainAndRegistry(homepage_url, | |
88 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)); | |
89 } | |
90 } | 87 } |
91 } | 88 } |
92 | 89 |
90 GURL ntp_url = chrome::GetNewTabPageURL(profile_); | |
91 if (ntp_url.is_valid()) { | |
92 rappor::SampleETLDp1(g_browser_process->rappor_service(), | |
93 "Settings.NewTabPageURL", | |
94 ntp_url); | |
95 } | |
96 | |
93 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); | 97 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); |
94 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", | 98 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", |
95 restore_on_startup, kSessionStartupPrefValueMax); | 99 restore_on_startup, kSessionStartupPrefValueMax); |
96 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { | 100 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { |
97 const base::ListValue* url_list = | 101 const base::ListValue* url_list = |
98 prefs_->GetList(prefs::kURLsToRestoreOnStartup); | 102 prefs_->GetList(prefs::kURLsToRestoreOnStartup); |
99 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", | 103 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", |
100 url_list->GetSize(), 1, 50, 20); | 104 url_list->GetSize(), 1, 50, 20); |
101 // Similarly, check startup pages for known search engine TLD+1s. | 105 // Similarly, check startup pages for known search engine TLD+1s. |
102 std::string url_text; | 106 std::string url_text; |
103 for (size_t i = 0; i < url_list->GetSize(); ++i) { | 107 for (size_t i = 0; i < url_list->GetSize(); ++i) { |
104 if (url_list->GetString(i, &url_text)) { | 108 if (url_list->GetString(i, &url_text)) { |
105 GURL start_url(url_text); | 109 GURL start_url(url_text); |
106 if (start_url.is_valid()) { | 110 if (start_url.is_valid()) { |
107 UMA_HISTOGRAM_ENUMERATION( | 111 UMA_HISTOGRAM_ENUMERATION( |
108 "Settings.StartupPageEngineTypes", | 112 "Settings.StartupPageEngineTypes", |
109 TemplateURLPrepopulateData::GetEngineType(start_url), | 113 TemplateURLPrepopulateData::GetEngineType(start_url), |
110 SEARCH_ENGINE_MAX); | 114 SEARCH_ENGINE_MAX); |
115 rappor::SampleETLDp1(g_browser_process->rappor_service(), | |
Alexei Svitkine (slow)
2014/06/05 14:23:35
Is this doing really what you intend?
It looks li
Steven Holte
2014/06/05 20:17:07
My assumption is that this is when chrome://settin
Alexei Svitkine (slow)
2014/06/05 21:05:23
Ah, that makes sense. Please verify your assumptio
| |
116 "Settings.StartupPage", | |
Alexei Svitkine (slow)
2014/06/05 14:23:35
Not in this CL, but now that we're getting a non-t
| |
117 start_url); | |
111 } | 118 } |
112 } | 119 } |
113 } | 120 } |
114 } | 121 } |
115 | 122 |
116 #if !defined(OS_ANDROID) | 123 #if !defined(OS_ANDROID) |
117 StartupTabs startup_tabs = PinnedTabCodec::ReadPinnedTabs(profile_); | 124 StartupTabs startup_tabs = PinnedTabCodec::ReadPinnedTabs(profile_); |
118 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.PinnedTabs", | 125 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.PinnedTabs", |
119 startup_tabs.size(), 1, 50, 20); | 126 startup_tabs.size(), 1, 50, 20); |
120 for (size_t i = 0; i < startup_tabs.size(); ++i) { | 127 for (size_t i = 0; i < startup_tabs.size(); ++i) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 } | 230 } |
224 | 231 |
225 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 232 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
226 return false; | 233 return false; |
227 } | 234 } |
228 | 235 |
229 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 236 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
230 content::BrowserContext* context) const { | 237 content::BrowserContext* context) const { |
231 return chrome::GetBrowserContextRedirectedInIncognito(context); | 238 return chrome::GetBrowserContextRedirectedInIncognito(context); |
232 } | 239 } |
OLD | NEW |