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/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 Loading... | |
| 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_service.h" | |
| 32 #include "components/rappor/rappor_utils.h" | |
| 31 #include "crypto/hmac.h" | 33 #include "crypto/hmac.h" |
| 32 #include "grit/browser_resources.h" | 34 #include "grit/browser_resources.h" |
| 33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 35 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 34 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
| 35 | 37 |
| 36 namespace { | 38 namespace { |
| 37 | 39 |
| 38 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax; | 40 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax; |
| 39 | 41 |
| 40 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 64 #if !defined(OS_ANDROID) | 66 #if !defined(OS_ANDROID) |
| 65 prefs::kPinnedTabs, | 67 prefs::kPinnedTabs, |
| 66 #else | 68 #else |
| 67 kUnregisteredPreference, | 69 kUnregisteredPreference, |
| 68 #endif | 70 #endif |
| 69 prefs::kExtensionKnownDisabled, | 71 prefs::kExtensionKnownDisabled, |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 const size_t kSHA256DigestSize = 32; | 74 const size_t kSHA256DigestSize = 32; |
| 73 | 75 |
| 76 const rappor::RapporParameters kHomePageRapporParameters = { | |
| 77 "Settings.HomePage", 16 /* Bloom filter size bytes */, | |
| 78 4 /* Bloom filter hash count */, | |
| 79 rappor::PROBABILITY_75 /* Fake data probability */, | |
| 80 rappor::PROBABILITY_50 /* Fake one probability */, | |
| 81 rappor::PROBABILITY_75 /* One coin probability */, | |
| 82 rappor::PROBABILITY_50 /* Zero coin probability */ | |
| 83 }; | |
| 84 | |
| 74 } // namespace | 85 } // namespace |
| 75 | 86 |
| 76 PrefMetricsService::PrefMetricsService(Profile* profile) | 87 PrefMetricsService::PrefMetricsService(Profile* profile) |
| 77 : profile_(profile), | 88 : profile_(profile), |
| 78 prefs_(profile_->GetPrefs()), | 89 prefs_(profile_->GetPrefs()), |
| 79 local_state_(g_browser_process->local_state()), | 90 local_state_(g_browser_process->local_state()), |
| 80 profile_name_(profile_->GetPath().AsUTF8Unsafe()), | 91 profile_name_(profile_->GetPath().AsUTF8Unsafe()), |
| 81 tracked_pref_paths_(kTrackedPrefs), | 92 tracked_pref_paths_(kTrackedPrefs), |
| 82 tracked_pref_path_count_(arraysize(kTrackedPrefs)), | 93 tracked_pref_path_count_(arraysize(kTrackedPrefs)), |
| 83 checked_tracked_prefs_(false), | 94 checked_tracked_prefs_(false), |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 // consist of a search box that sends to known TLD+1 Y) and false positives | 155 // 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 | 156 // (pages that share a TLD+1 with a known engine but aren't actually search |
| 146 // pages, e.g. plus.google.com). | 157 // pages, e.g. plus.google.com). |
| 147 if (!home_page_is_ntp) { | 158 if (!home_page_is_ntp) { |
| 148 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); | 159 GURL homepage_url(prefs_->GetString(prefs::kHomePage)); |
| 149 if (homepage_url.is_valid()) { | 160 if (homepage_url.is_valid()) { |
| 150 UMA_HISTOGRAM_ENUMERATION( | 161 UMA_HISTOGRAM_ENUMERATION( |
| 151 "Settings.HomePageEngineType", | 162 "Settings.HomePageEngineType", |
| 152 TemplateURLPrepopulateData::GetEngineType(homepage_url), | 163 TemplateURLPrepopulateData::GetEngineType(homepage_url), |
| 153 SEARCH_ENGINE_MAX); | 164 SEARCH_ENGINE_MAX); |
| 165 std::vector<std::string> url_parts; | |
| 166 rappor::GetUrlParts(homepage_url, &url_parts); | |
|
Alexei Svitkine (slow)
2014/01/09 19:23:09
I think the service should just have a RecordURL()
Steven Holte
2014/01/09 22:03:01
Done.
| |
| 167 g_browser_process->rappor_service()->RecordSamples( | |
| 168 kHomePageRapporParameters, url_parts); | |
| 154 } | 169 } |
| 155 } | 170 } |
| 156 | 171 |
| 157 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); | 172 int restore_on_startup = prefs_->GetInteger(prefs::kRestoreOnStartup); |
| 158 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", | 173 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", |
| 159 restore_on_startup, kSessionStartupPrefValueMax); | 174 restore_on_startup, kSessionStartupPrefValueMax); |
| 160 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { | 175 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { |
| 161 const ListValue* url_list = prefs_->GetList(prefs::kURLsToRestoreOnStartup); | 176 const ListValue* url_list = prefs_->GetList(prefs::kURLsToRestoreOnStartup); |
| 162 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", | 177 UMA_HISTOGRAM_CUSTOM_COUNTS("Settings.StartupPageLoadURLs", |
| 163 url_list->GetSize(), 1, 50, 20); | 178 url_list->GetSize(), 1, 50, 20); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 } | 485 } |
| 471 | 486 |
| 472 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 487 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
| 473 return false; | 488 return false; |
| 474 } | 489 } |
| 475 | 490 |
| 476 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 491 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
| 477 content::BrowserContext* context) const { | 492 content::BrowserContext* context) const { |
| 478 return chrome::GetBrowserContextRedirectedInIncognito(context); | 493 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 479 } | 494 } |
| OLD | NEW |