Chromium Code Reviews| 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_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 = { | |
| 34 "Settings.HomePage", 16 /* Bloom filter size bytes */, | |
|
Ilya Sherman
2014/01/10 11:00:32
Optional nit: One arg per line might be a little c
Steven Holte
2014/01/14 00:47:54
Done.
| |
| 35 4 /* Bloom filter hash count */, | |
| 36 rappor::PROBABILITY_75 /* Fake data probability */, | |
| 37 rappor::PROBABILITY_50 /* Fake one probability */, | |
| 38 rappor::PROBABILITY_75 /* One coin probability */, | |
| 39 rappor::PROBABILITY_50 /* Zero coin probability */ | |
|
Ilya Sherman
2014/01/10 11:00:32
This is a lot of manual configuration. Do all of
Steven Holte
2014/01/14 00:47:54
We should have defaults for this eventually, but w
Alexei Svitkine (slow)
2014/01/22 22:13:28
This is one area that still concerns me. If the AP
| |
| 40 }; | |
| 41 | |
| 32 } // namespace | 42 } // namespace |
| 33 | 43 |
| 34 PrefMetricsService::PrefMetricsService(Profile* profile) | 44 PrefMetricsService::PrefMetricsService(Profile* profile) |
| 35 : profile_(profile), | 45 : profile_(profile), |
| 36 prefs_(profile_->GetPrefs()), | 46 prefs_(profile_->GetPrefs()), |
| 37 local_state_(g_browser_process->local_state()), | 47 local_state_(g_browser_process->local_state()), |
| 38 weak_factory_(this) { | 48 weak_factory_(this) { |
| 39 RecordLaunchPrefs(); | 49 RecordLaunchPrefs(); |
| 40 | 50 |
| 41 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); | 51 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 | 81 // 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 | 82 // (pages that share a TLD+1 with a known engine but aren't actually search |
| 73 // pages, e.g. plus.google.com). | 83 // pages, e.g. plus.google.com). |
| 74 if (!home_page_is_ntp) { | 84 if (!home_page_is_ntp) { |
| 75 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); | 85 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); |
| 76 if (homepage_url.is_valid()) { | 86 if (homepage_url.is_valid()) { |
| 77 UMA_HISTOGRAM_ENUMERATION( | 87 UMA_HISTOGRAM_ENUMERATION( |
| 78 "Settings.HomePageEngineType", | 88 "Settings.HomePageEngineType", |
| 79 TemplateURLPrepopulateData::GetEngineType(homepage_url), | 89 TemplateURLPrepopulateData::GetEngineType(homepage_url), |
| 80 SEARCH_ENGINE_MAX); | 90 SEARCH_ENGINE_MAX); |
| 91 g_browser_process->rappor_service()->RecordUrl( | |
| 92 kHomePageRapporParameters, homepage_url); | |
| 81 } | 93 } |
| 82 } | 94 } |
| 83 | 95 |
| 84 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); | 96 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); |
| 85 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", | 97 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", |
| 86 restore_on_startup, kSessionStartupPrefValueMax); | 98 restore_on_startup, kSessionStartupPrefValueMax); |
| 87 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { | 99 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { |
| 88 const base::ListValue* url_list = | 100 const base::ListValue* url_list = |
| 89 prefs_->GetList(prefs::kURLsToRestoreOnStartup); | 101 prefs_->GetList(prefs::kURLsToRestoreOnStartup); |
| 90 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", | 102 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 } | 227 } |
| 216 | 228 |
| 217 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 229 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
| 218 return false; | 230 return false; |
| 219 } | 231 } |
| 220 | 232 |
| 221 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 233 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
| 222 content::BrowserContext* context) const { | 234 content::BrowserContext* context) const { |
| 223 return chrome::GetBrowserContextRedirectedInIncognito(context); | 235 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 224 } | 236 } |
| OLD | NEW |