Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 |
| 33 const rappor::RapporParameters kHomePageRapporParameters = { | |
|
Alexei Svitkine (slow)
2014/02/03 22:34:18
As I said in a previous comment, I don't think we
Steven Holte
2014/02/03 23:58:06
Done. These parameters now live in components/rap
| |
| 34 "Settings.HomePage" /* Metric name */, | |
| 35 16 /* Bloom filter size bytes */, | |
| 36 2 /* Bloom filter hash count */, | |
| 37 rappor::PROBABILITY_75 /* Fake data probability */, | |
| 38 rappor::PROBABILITY_50 /* Fake one probability */, | |
| 39 rappor::PROBABILITY_75 /* One coin probability */, | |
| 40 rappor::PROBABILITY_50 /* Zero coin probability */ | |
| 41 }; | |
| 42 | |
| 32 } // namespace | 43 } // namespace |
| 33 | 44 |
| 34 PrefMetricsService::PrefMetricsService(Profile* profile) | 45 PrefMetricsService::PrefMetricsService(Profile* profile) |
| 35 : profile_(profile), | 46 : profile_(profile), |
| 36 prefs_(profile_->GetPrefs()), | 47 prefs_(profile_->GetPrefs()), |
| 37 local_state_(g_browser_process->local_state()), | 48 local_state_(g_browser_process->local_state()), |
| 38 weak_factory_(this) { | 49 weak_factory_(this) { |
| 39 RecordLaunchPrefs(); | 50 RecordLaunchPrefs(); |
| 40 | 51 |
| 41 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); | 52 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 71 // consist of a search box that sends to known TLD+1 Y) and false positives | 82 // 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 | 83 // (pages that share a TLD+1 with a known engine but aren't actually search |
| 73 // pages, e.g. plus.google.com). | 84 // pages, e.g. plus.google.com). |
| 74 if (!home_page_is_ntp) { | 85 if (!home_page_is_ntp) { |
| 75 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); | 86 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); |
| 76 if (homepage_url.is_valid()) { | 87 if (homepage_url.is_valid()) { |
| 77 UMA_HISTOGRAM_ENUMERATION( | 88 UMA_HISTOGRAM_ENUMERATION( |
| 78 "Settings.HomePageEngineType", | 89 "Settings.HomePageEngineType", |
| 79 TemplateURLPrepopulateData::GetEngineType(homepage_url), | 90 TemplateURLPrepopulateData::GetEngineType(homepage_url), |
| 80 SEARCH_ENGINE_MAX); | 91 SEARCH_ENGINE_MAX); |
| 92 g_browser_process->rappor_service()->RecordSample( | |
| 93 kHomePageRapporParameters, | |
| 94 net::registry_controlled_domains::GetDomainAndRegistry(homepage_url, | |
| 95 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)); | |
| 81 } | 96 } |
| 82 } | 97 } |
| 83 | 98 |
| 84 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); | 99 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); |
| 85 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", | 100 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", |
| 86 restore_on_startup, kSessionStartupPrefValueMax); | 101 restore_on_startup, kSessionStartupPrefValueMax); |
| 87 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { | 102 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { |
| 88 const base::ListValue* url_list = | 103 const base::ListValue* url_list = |
| 89 prefs_->GetList(prefs::kURLsToRestoreOnStartup); | 104 prefs_->GetList(prefs::kURLsToRestoreOnStartup); |
| 90 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", | 105 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 } | 230 } |
| 216 | 231 |
| 217 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 232 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
| 218 return false; | 233 return false; |
| 219 } | 234 } |
| 220 | 235 |
| 221 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 236 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
| 222 content::BrowserContext* context) const { | 237 content::BrowserContext* context) const { |
| 223 return chrome::GetBrowserContextRedirectedInIncognito(context); | 238 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 224 } | 239 } |
| OLD | NEW |