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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 PrefService* local_state) | 71 PrefService* local_state) |
72 : profile_(profile), | 72 : profile_(profile), |
73 prefs_(profile->GetPrefs()), | 73 prefs_(profile->GetPrefs()), |
74 local_state_(local_state), | 74 local_state_(local_state), |
75 weak_factory_(this) { | 75 weak_factory_(this) { |
76 } | 76 } |
77 | 77 |
78 PrefMetricsService::~PrefMetricsService() { | 78 PrefMetricsService::~PrefMetricsService() { |
79 } | 79 } |
80 | 80 |
81 void PrefMetricsService::RecordLaunchPrefs() { | 81 // static |
82 bool show_home_button = prefs_->GetBoolean(prefs::kShowHomeButton); | 82 void PrefMetricsService::RecordHomePageLaunchMetrics(bool show_home_button, |
83 bool home_page_is_ntp = prefs_->GetBoolean(prefs::kHomePageIsNewTabPage); | 83 bool homepage_is_ntp, |
84 const GURL& homepage_url) { | |
84 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton", show_home_button); | 85 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton", show_home_button); |
85 if (show_home_button) { | 86 if (show_home_button) { |
86 UMA_HISTOGRAM_BOOLEAN("Settings.GivenShowHomeButton_HomePageIsNewTabPage", | 87 UMA_HISTOGRAM_BOOLEAN("Settings.GivenShowHomeButton_HomePageIsNewTabPage", |
87 home_page_is_ntp); | 88 homepage_is_ntp); |
88 } | 89 } |
89 | 90 |
90 // For non-NTP homepages, see if the URL comes from the same TLD+1 as a known | 91 // For non-NTP homepages, see if the URL comes from the same TLD+1 as a known |
91 // search engine. Note that this is only an approximation of search engine | 92 // search engine. Note that this is only an approximation of search engine |
92 // use, due to both false negatives (pages that come from unknown TLD+1 X but | 93 // use, due to both false negatives (pages that come from unknown TLD+1 X but |
93 // consist of a search box that sends to known TLD+1 Y) and false positives | 94 // consist of a search box that sends to known TLD+1 Y) and false positives |
94 // (pages that share a TLD+1 with a known engine but aren't actually search | 95 // (pages that share a TLD+1 with a known engine but aren't actually search |
95 // pages, e.g. plus.google.com). Additionally, record the TLD+1 of non-NTP | 96 // pages, e.g. plus.google.com). Additionally, record the TLD+1 of non-NTP |
96 // homepages through the privacy-preserving Rappor service. | 97 // homepages through the privacy-preserving Rappor service. |
97 if (!home_page_is_ntp) { | 98 if (!homepage_is_ntp) { |
98 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); | |
99 if (homepage_url.is_valid()) { | 99 if (homepage_url.is_valid()) { |
100 UMA_HISTOGRAM_ENUMERATION( | 100 UMA_HISTOGRAM_ENUMERATION( |
101 "Settings.HomePageEngineType", | 101 "Settings.HomePageEngineType", |
102 TemplateURLPrepopulateData::GetEngineType(homepage_url), | 102 TemplateURLPrepopulateData::GetEngineType(homepage_url), |
103 SEARCH_ENGINE_MAX); | 103 SEARCH_ENGINE_MAX); |
104 rappor::SampleDomainAndRegistryFromGURL( | 104 rappor::SampleDomainAndRegistryFromGURL( |
105 g_browser_process->rappor_service(), "Settings.HomePage2", | 105 g_browser_process->rappor_service(), "Settings.HomePage2", |
106 homepage_url); | 106 homepage_url); |
107 } | 107 } |
108 } | 108 } |
109 } | |
110 | |
111 void PrefMetricsService::RecordLaunchPrefs() { | |
112 #if !defined(OS_ANDROID) | |
Mark P
2016/05/24 18:41:53
Please comment here why we skip it on Android (by
Ted C
2016/05/24 19:01:32
Done.
| |
113 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); | |
114 RecordHomePageLaunchMetrics(prefs_->GetBoolean(prefs::kShowHomeButton), | |
115 prefs_->GetBoolean(prefs::kHomePageIsNewTabPage), | |
116 homepage_url); | |
117 #endif | |
109 | 118 |
110 SampleNewTabPageURL(profile_); | 119 SampleNewTabPageURL(profile_); |
Mark P
2016/05/24 18:41:53
Given your answers to the comments on the earlier
Ted C
2016/05/24 19:01:33
Done.
| |
111 | 120 |
112 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); | 121 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); |
113 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", | 122 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", |
114 restore_on_startup, kSessionStartupPrefValueMax); | 123 restore_on_startup, kSessionStartupPrefValueMax); |
115 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { | 124 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { |
116 const base::ListValue* url_list = | 125 const base::ListValue* url_list = |
117 prefs_->GetList(prefs::kURLsToRestoreOnStartup); | 126 prefs_->GetList(prefs::kURLsToRestoreOnStartup); |
118 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", | 127 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", |
119 url_list->GetSize(), 1, 50, 20); | 128 url_list->GetSize(), 1, 50, 20); |
120 // Similarly, check startup pages for known search engine TLD+1s. | 129 // Similarly, check startup pages for known search engine TLD+1s. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 } | 258 } |
250 | 259 |
251 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 260 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
252 return false; | 261 return false; |
253 } | 262 } |
254 | 263 |
255 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 264 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
256 content::BrowserContext* context) const { | 265 content::BrowserContext* context) const { |
257 return chrome::GetBrowserContextRedirectedInIncognito(context); | 266 return chrome::GetBrowserContextRedirectedInIncognito(context); |
258 } | 267 } |
OLD | NEW |