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

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: Seperated log generation and uploading Created 7 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 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/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/prefs/pref_service_syncable.h" 21 #include "chrome/browser/prefs/pref_service_syncable.h"
22 #include "chrome/browser/prefs/session_startup_pref.h" 22 #include "chrome/browser/prefs/session_startup_pref.h"
23 #include "chrome/browser/prefs/synced_pref_change_registrar.h" 23 #include "chrome/browser/prefs/synced_pref_change_registrar.h"
24 #include "chrome/browser/profiles/incognito_helpers.h" 24 #include "chrome/browser/profiles/incognito_helpers.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 26 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
27 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" 27 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
30 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 30 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
31 #include "components/rappor/rappor_recorder.h"
31 #include "crypto/hmac.h" 32 #include "crypto/hmac.h"
32 #include "grit/browser_resources.h" 33 #include "grit/browser_resources.h"
33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 34 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
35 36
36 namespace { 37 namespace {
37 38
38 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax; 39 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax;
39 40
40 #if defined(OS_ANDROID) 41 #if defined(OS_ANDROID)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 tracked_pref_path_count_(tracked_pref_path_count), 123 tracked_pref_path_count_(tracked_pref_path_count),
123 checked_tracked_prefs_(false), 124 checked_tracked_prefs_(false),
124 weak_factory_(this) { 125 weak_factory_(this) {
125 MarkNeedsEmptyValueForTrackedPreferences(); 126 MarkNeedsEmptyValueForTrackedPreferences();
126 CheckTrackedPreferences(); 127 CheckTrackedPreferences();
127 } 128 }
128 129
129 PrefMetricsService::~PrefMetricsService() { 130 PrefMetricsService::~PrefMetricsService() {
130 } 131 }
131 132
133 static void GetUrlParts(const GURL& url, std::vector<std::string>* strs) {
134 strs->push_back(url.spec());
135 strs->push_back(url.host());
136 // TODO(holte) break up host more
137 strs->push_back(url.query());
138 strs->push_back(url.path());
139 // strs.push_back(url.ref());
140 }
141
132 void PrefMetricsService::RecordLaunchPrefs() { 142 void PrefMetricsService::RecordLaunchPrefs() {
133 bool show_home_button = prefs_->GetBoolean(prefs::kShowHomeButton); 143 bool show_home_button = prefs_->GetBoolean(prefs::kShowHomeButton);
134 bool home_page_is_ntp = prefs_->GetBoolean(prefs::kHomePageIsNewTabPage); 144 bool home_page_is_ntp = prefs_->GetBoolean(prefs::kHomePageIsNewTabPage);
135 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton", show_home_button); 145 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton", show_home_button);
136 if (show_home_button) { 146 if (show_home_button) {
137 UMA_HISTOGRAM_BOOLEAN("Settings.GivenShowHomeButton_HomePageIsNewTabPage", 147 UMA_HISTOGRAM_BOOLEAN("Settings.GivenShowHomeButton_HomePageIsNewTabPage",
138 home_page_is_ntp); 148 home_page_is_ntp);
139 } 149 }
140 150
141 // For non-NTP homepages, see if the URL comes from the same TLD+1 as a known 151 // For non-NTP homepages, see if the URL comes from the same TLD+1 as a known
142 // search engine. Note that this is only an approximation of search engine 152 // search engine. Note that this is only an approximation of search engine
143 // use, due to both false negatives (pages that come from unknown TLD+1 X but 153 // use, due to both false negatives (pages that come from unknown TLD+1 X but
144 // consist of a search box that sends to known TLD+1 Y) and false positives 154 // consist of a search box that sends to known TLD+1 Y) and false positives
145 // (pages that share a TLD+1 with a known engine but aren't actually search 155 // (pages that share a TLD+1 with a known engine but aren't actually search
146 // pages, e.g. plus.google.com). 156 // pages, e.g. plus.google.com).
147 if (!home_page_is_ntp) { 157 if (!home_page_is_ntp) {
148 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); 158 GURL homepage_url(prefs_->GetString(prefs::kHomePage));
149 if (homepage_url.is_valid()) { 159 if (homepage_url.is_valid()) {
150 UMA_HISTOGRAM_ENUMERATION( 160 UMA_HISTOGRAM_ENUMERATION(
151 "Settings.HomePageEngineType", 161 "Settings.HomePageEngineType",
152 TemplateURLPrepopulateData::GetEngineType(homepage_url), 162 TemplateURLPrepopulateData::GetEngineType(homepage_url),
153 SEARCH_ENGINE_MAX); 163 SEARCH_ENGINE_MAX);
164 std::vector<std::string> url_parts;
165 GetUrlParts(homepage_url, &url_parts);
166 RAPPOR_SAMPLE("Settings.HomePage", url_parts);
154 } 167 }
155 } 168 }
156 169
157 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); 170 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup);
158 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", 171 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings",
159 restore_on_startup, kSessionStartupPrefValueMax); 172 restore_on_startup, kSessionStartupPrefValueMax);
160 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { 173 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) {
161 const ListValue* url_list = prefs_->GetList(prefs::kURLsToRestoreOnStartup); 174 const ListValue* url_list = prefs_->GetList(prefs::kURLsToRestoreOnStartup);
162 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", 175 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs",
163 url_list->GetSize(), 1, 50, 20); 176 url_list->GetSize(), 1, 50, 20);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 483 }
471 484
472 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { 485 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const {
473 return false; 486 return false;
474 } 487 }
475 488
476 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( 489 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse(
477 content::BrowserContext* context) const { 490 content::BrowserContext* context) const {
478 return chrome::GetBrowserContextRedirectedInIncognito(context); 491 return chrome::GetBrowserContextRedirectedInIncognito(context);
479 } 492 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698