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" |
| 11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browser_shutdown.h" | 15 #include "chrome/browser/browser_shutdown.h" |
| 16 // Accessing the Device ID API here is a layering violation. | 16 // Accessing the Device ID API here is a layering violation. |
| 17 // TODO(bbudge) Move the API so it's usable here. | 17 // TODO(bbudge) Move the API so it's usable here. |
| 18 // http://crbug.com/276485 | 18 // http://crbug.com/276485 |
| 19 #include "chrome/browser/extensions/api/music_manager_private/device_id.h" | 19 #include "chrome/browser/extensions/api/music_manager_private/device_id.h" |
| 20 #include "chrome/browser/extensions/extension_prefs.h" | |
| 21 #include "chrome/browser/prefs/pref_service_syncable.h" | 20 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 22 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 23 #include "chrome/browser/prefs/session_startup_pref.h" | 22 #include "chrome/browser/prefs/session_startup_pref.h" |
| 24 #include "chrome/browser/prefs/synced_pref_change_registrar.h" | 23 #include "chrome/browser/prefs/synced_pref_change_registrar.h" |
| 25 #include "chrome/browser/profiles/incognito_helpers.h" | 24 #include "chrome/browser/profiles/incognito_helpers.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 26 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 28 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 27 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 29 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 31 #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" |
| 32 #include "crypto/hmac.h" | 31 #include "crypto/hmac.h" |
| 33 #include "grit/browser_resources.h" | 32 #include "grit/browser_resources.h" |
| 34 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 35 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 36 | 35 |
| 37 namespace { | 36 namespace { |
| 38 | 37 |
| 39 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax; | 38 const int kSessionStartupPrefValueMax = SessionStartupPref::kPrefValueMax; |
| 40 | 39 |
| 40 // An unregistered preference to fill in indices in kTrackedPrefs below for | |
| 41 // preferences that aren't defined on every platform. This is fine as the code | |
| 42 // below (e.g. CheckTrackedPreferences()) skips unregistered preferences and | |
| 43 // should thus never report any data about that index on the platforms where | |
| 44 // that preference is unimplemented. | |
| 45 const char kUnregisteredPreference[] = "_"; | |
| 46 | |
| 41 // These preferences must be kept in sync with the TrackedPreference enum in | 47 // These preferences must be kept in sync with the TrackedPreference enum in |
| 42 // tools/metrics/histograms/histograms.xml. To add a new preference, append it | 48 // tools/metrics/histograms/histograms.xml. To add a new preference, append it |
| 43 // to the array and add a corresponding value to the histogram enum. | 49 // to the array and add a corresponding value to the histogram enum. |
| 44 const char* kTrackedPrefs[] = { | 50 const char* kTrackedPrefs[] = { |
| 45 prefs::kShowHomeButton, | 51 prefs::kShowHomeButton, |
| 46 prefs::kHomePageIsNewTabPage, | 52 prefs::kHomePageIsNewTabPage, |
| 47 prefs::kHomePage, | 53 prefs::kHomePage, |
| 48 prefs::kRestoreOnStartup, | 54 prefs::kRestoreOnStartup, |
| 49 prefs::kURLsToRestoreOnStartup, | 55 prefs::kURLsToRestoreOnStartup, |
| 50 prefs::kExtensionsPref, | 56 prefs::kExtensionsPref, |
| 51 prefs::kGoogleServicesLastUsername, | 57 prefs::kGoogleServicesLastUsername, |
| 52 prefs::kSearchProviderOverrides, | 58 prefs::kSearchProviderOverrides, |
| 53 prefs::kDefaultSearchProviderSearchURL, | 59 prefs::kDefaultSearchProviderSearchURL, |
| 54 prefs::kDefaultSearchProviderKeyword, | 60 prefs::kDefaultSearchProviderKeyword, |
| 55 prefs::kDefaultSearchProviderName, | 61 prefs::kDefaultSearchProviderName, |
| 56 #if !defined(OS_ANDROID) | 62 #if !defined(OS_ANDROID) |
| 57 prefs::kPinnedTabs, | 63 prefs::kPinnedTabs, |
| 64 #else | |
| 65 kUnregisteredPreference, | |
| 58 #endif | 66 #endif |
| 67 prefs::kExtensionKnownDisabled, | |
| 59 }; | 68 }; |
| 60 | 69 |
| 61 static const size_t kSHA256DigestSize = 32; | 70 static const size_t kSHA256DigestSize = 32; |
| 62 | 71 |
| 63 } // namespace | 72 } // namespace |
|
Bernhard Bauer
2013/10/16 12:45:38
Nit: Everything in here is const, which automatica
gab
2013/10/16 13:22:17
I'm happy to clean this up in a follow-up CL, I ag
| |
| 64 | 73 |
| 65 PrefMetricsService::PrefMetricsService(Profile* profile) | 74 PrefMetricsService::PrefMetricsService(Profile* profile) |
| 66 : profile_(profile), | 75 : profile_(profile), |
| 67 prefs_(profile_->GetPrefs()), | 76 prefs_(profile_->GetPrefs()), |
| 68 local_state_(g_browser_process->local_state()), | 77 local_state_(g_browser_process->local_state()), |
| 69 profile_name_(profile_->GetPath().AsUTF8Unsafe()), | 78 profile_name_(profile_->GetPath().AsUTF8Unsafe()), |
| 70 tracked_pref_paths_(kTrackedPrefs), | 79 tracked_pref_paths_(kTrackedPrefs), |
| 71 tracked_pref_path_count_(arraysize(kTrackedPrefs)), | 80 tracked_pref_path_count_(arraysize(kTrackedPrefs)), |
| 72 checked_tracked_prefs_(false), | 81 checked_tracked_prefs_(false), |
| 73 weak_factory_(this) { | 82 weak_factory_(this) { |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 } | 461 } |
| 453 | 462 |
| 454 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 463 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
| 455 return false; | 464 return false; |
| 456 } | 465 } |
| 457 | 466 |
| 458 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 467 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
| 459 content::BrowserContext* context) const { | 468 content::BrowserContext* context) const { |
| 460 return chrome::GetBrowserContextRedirectedInIncognito(context); | 469 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 461 } | 470 } |
| OLD | NEW |