OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/rappor/rappor_prefs.h" | 5 #include "components/rappor/rappor_prefs.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 void RecordLoadSecretResult(LoadResult reason) { | 32 void RecordLoadSecretResult(LoadResult reason) { |
33 UMA_HISTOGRAM_ENUMERATION(kLoadSecretHistogramName, | 33 UMA_HISTOGRAM_ENUMERATION(kLoadSecretHistogramName, |
34 reason, | 34 reason, |
35 NUM_LOAD_RESULTS); | 35 NUM_LOAD_RESULTS); |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 void RegisterPrefs(PrefRegistrySimple* registry) { | 40 void RegisterPrefs(PrefRegistrySimple* registry) { |
| 41 registry->RegisterBooleanPref(prefs::kRapporEnabled, true); |
41 registry->RegisterStringPref(prefs::kRapporSecret, std::string()); | 42 registry->RegisterStringPref(prefs::kRapporSecret, std::string()); |
42 registry->RegisterIntegerPref(prefs::kRapporCohortDeprecated, -1); | 43 registry->RegisterIntegerPref(prefs::kRapporCohortDeprecated, -1); |
43 registry->RegisterIntegerPref(prefs::kRapporCohortSeed, -1); | 44 registry->RegisterIntegerPref(prefs::kRapporCohortSeed, -1); |
44 metrics::DailyEvent::RegisterPref(registry, prefs::kRapporLastDailySample); | 45 metrics::DailyEvent::RegisterPref(registry, prefs::kRapporLastDailySample); |
45 } | 46 } |
46 | 47 |
47 int32_t LoadCohort(PrefService* pref_service) { | 48 int32_t LoadCohort(PrefService* pref_service) { |
48 // Ignore and delete old cohort parameter. | 49 // Ignore and delete old cohort parameter. |
49 pref_service->ClearPref(prefs::kRapporCohortDeprecated); | 50 pref_service->ClearPref(prefs::kRapporCohortDeprecated); |
50 | 51 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 DVLOG(2) << "Generated a new Rappor secret."; | 90 DVLOG(2) << "Generated a new Rappor secret."; |
90 secret = HmacByteVectorGenerator::GenerateEntropyInput(); | 91 secret = HmacByteVectorGenerator::GenerateEntropyInput(); |
91 base::Base64Encode(secret, &secret_base64); | 92 base::Base64Encode(secret, &secret_base64); |
92 pref_service->SetString(prefs::kRapporSecret, secret_base64); | 93 pref_service->SetString(prefs::kRapporSecret, secret_base64); |
93 return secret; | 94 return secret; |
94 } | 95 } |
95 | 96 |
96 } // namespace internal | 97 } // namespace internal |
97 | 98 |
98 } // namespace rappor | 99 } // namespace rappor |
OLD | NEW |