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

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

Issue 2006023002: Log some information about the state of the homepage on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 6 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
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 <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
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 }
109 110
111 void PrefMetricsService::RecordLaunchPrefs() {
gab 2016/05/25 14:03:24 How about #if !defined(OS_ANDROID) on this entire
Mark P 2016/05/25 17:01:53 I know it looks weird, but (i) these are independe
gab 2016/05/25 17:13:11 Ok, works for me then.
112 // On Android, determining whether the homepage is enabled requires waiting
113 // for a response from a third party provider installed on the device. So,
114 // it will be logged later once all the dependent information is available.
115 // See DeferredStartupHandler.java.
116 #if !defined(OS_ANDROID)
117 GURL homepage_url(prefs_->GetString(prefs::kHomePage));
118 RecordHomePageLaunchMetrics(prefs_->GetBoolean(prefs::kShowHomeButton),
119 prefs_->GetBoolean(prefs::kHomePageIsNewTabPage),
120 homepage_url);
121 #endif
122
123 // Android does not support overriding the NTP URL.
124 #if !defined(OS_ANDROID)
110 SampleNewTabPageURL(profile_); 125 SampleNewTabPageURL(profile_);
126 #endif
111 127
128 // Tab restoring is always done on Android, so these metrics are not
129 // applicable. Also, startup pages are not supported on Android
130 #if !defined(OS_ANDROID)
112 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); 131 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup);
113 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", 132 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings",
114 restore_on_startup, kSessionStartupPrefValueMax); 133 restore_on_startup, kSessionStartupPrefValueMax);
115 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { 134 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) {
116 const base::ListValue* url_list = 135 const base::ListValue* url_list =
117 prefs_->GetList(prefs::kURLsToRestoreOnStartup); 136 prefs_->GetList(prefs::kURLsToRestoreOnStartup);
118 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", 137 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs",
119 url_list->GetSize(), 1, 50, 20); 138 url_list->GetSize(), 1, 50, 20);
120 // Similarly, check startup pages for known search engine TLD+1s. 139 // Similarly, check startup pages for known search engine TLD+1s.
121 std::string url_text; 140 std::string url_text;
122 for (size_t i = 0; i < url_list->GetSize(); ++i) { 141 for (size_t i = 0; i < url_list->GetSize(); ++i) {
123 if (url_list->GetString(i, &url_text)) { 142 if (url_list->GetString(i, &url_text)) {
124 GURL start_url(url_text); 143 GURL start_url(url_text);
125 if (start_url.is_valid()) { 144 if (start_url.is_valid()) {
126 UMA_HISTOGRAM_ENUMERATION( 145 UMA_HISTOGRAM_ENUMERATION(
127 "Settings.StartupPageEngineTypes", 146 "Settings.StartupPageEngineTypes",
128 TemplateURLPrepopulateData::GetEngineType(start_url), 147 TemplateURLPrepopulateData::GetEngineType(start_url),
129 SEARCH_ENGINE_MAX); 148 SEARCH_ENGINE_MAX);
130 if (i == 0) { 149 if (i == 0) {
131 rappor::SampleDomainAndRegistryFromGURL( 150 rappor::SampleDomainAndRegistryFromGURL(
132 g_browser_process->rappor_service(), 151 g_browser_process->rappor_service(),
133 "Settings.FirstStartupPage", start_url); 152 "Settings.FirstStartupPage", start_url);
134 } 153 }
135 } 154 }
136 } 155 }
137 } 156 }
138 } 157 }
158 #endif
139 159
160 // Android does not support pinned tabs.
140 #if !defined(OS_ANDROID) 161 #if !defined(OS_ANDROID)
141 StartupTabs startup_tabs = PinnedTabCodec::ReadPinnedTabs(profile_); 162 StartupTabs startup_tabs = PinnedTabCodec::ReadPinnedTabs(profile_);
142 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.PinnedTabs", 163 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.PinnedTabs",
143 startup_tabs.size(), 1, 50, 20); 164 startup_tabs.size(), 1, 50, 20);
144 for (size_t i = 0; i < startup_tabs.size(); ++i) { 165 for (size_t i = 0; i < startup_tabs.size(); ++i) {
145 GURL start_url(startup_tabs.at(i).url); 166 GURL start_url(startup_tabs.at(i).url);
146 if (start_url.is_valid()) { 167 if (start_url.is_valid()) {
147 UMA_HISTOGRAM_ENUMERATION( 168 UMA_HISTOGRAM_ENUMERATION(
148 "Settings.PinnedTabEngineTypes", 169 "Settings.PinnedTabEngineTypes",
149 TemplateURLPrepopulateData::GetEngineType(start_url), 170 TemplateURLPrepopulateData::GetEngineType(start_url),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 270 }
250 271
251 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { 272 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const {
252 return false; 273 return false;
253 } 274 }
254 275
255 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( 276 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse(
256 content::BrowserContext* context) const { 277 content::BrowserContext* context) const {
257 return chrome::GetBrowserContextRedirectedInIncognito(context); 278 return chrome::GetBrowserContextRedirectedInIncognito(context);
258 } 279 }
OLDNEW
« chrome/browser/prefs/pref_metrics_service.h ('K') | « chrome/browser/prefs/pref_metrics_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698