OLD | NEW |
---|---|
1 // Copyright 2014 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 "components/variations/variations_seed_store.h" | 5 #include "components/variations/variations_seed_store.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/numerics/safe_math.h" | 9 #include "base/numerics/safe_math.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/sha1.h" | 12 #include "base/sha1.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "components/compression/compression_utils.h" | 14 #include "components/compression/compression_utils.h" |
15 #include "components/variations/android/variations_seed_bridge.h" | |
15 #include "components/variations/pref_names.h" | 16 #include "components/variations/pref_names.h" |
16 #include "components/variations/proto/variations_seed.pb.h" | 17 #include "components/variations/proto/variations_seed.pb.h" |
17 #include "crypto/signature_verifier.h" | 18 #include "crypto/signature_verifier.h" |
18 #include "third_party/protobuf/src/google/protobuf/io/coded_stream.h" | 19 #include "third_party/protobuf/src/google/protobuf/io/coded_stream.h" |
19 | 20 |
20 namespace variations { | 21 namespace variations { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Signature verification is disabled on mobile platforms for now, since it | 25 // Signature verification is disabled on mobile platforms for now, since it |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 DVLOG(1) << "Importing first run seed from Java preferences."; | 362 DVLOG(1) << "Importing first run seed from Java preferences."; |
362 if (get_variations_first_run_seed_.is_null()) { | 363 if (get_variations_first_run_seed_.is_null()) { |
363 RecordFirstRunResult(FIRST_RUN_SEED_IMPORT_FAIL_NO_CALLBACK); | 364 RecordFirstRunResult(FIRST_RUN_SEED_IMPORT_FAIL_NO_CALLBACK); |
364 return; | 365 return; |
365 } | 366 } |
366 | 367 |
367 std::string seed_data; | 368 std::string seed_data; |
368 std::string seed_signature; | 369 std::string seed_signature; |
369 std::string seed_country; | 370 std::string seed_country; |
370 get_variations_first_run_seed_.Run(&seed_data, &seed_signature, | 371 get_variations_first_run_seed_.Run(&seed_data, &seed_signature, |
371 &seed_country); | 372 &seed_country); |
Alexei Svitkine (slow)
2015/11/12 16:30:11
Per offline discussion, I suggested the below woul
Alexander Agulenko
2015/11/12 17:40:25
Done.
| |
373 android::ClearJavaPrefs(); | |
Alexei Svitkine (slow)
2015/11/12 16:30:11
This needs an ifdef android. Also probably the inc
Alexander Agulenko
2015/11/12 17:25:25
I am not sure that it is really necessary: the who
Alexei Svitkine (slow)
2015/11/12 17:36:28
Sorry, you're right. However, see my other comment
| |
372 if (seed_data.empty()) { | 374 if (seed_data.empty()) { |
373 RecordFirstRunResult(FIRST_RUN_SEED_IMPORT_FAIL_NO_FIRST_RUN_SEED); | 375 RecordFirstRunResult(FIRST_RUN_SEED_IMPORT_FAIL_NO_FIRST_RUN_SEED); |
374 return; | 376 return; |
375 } | 377 } |
376 | 378 |
377 // TODO(agulenko): Pull actual time from the response. | 379 // TODO(agulenko): Pull actual time from the response. |
378 base::Time current_time = base::Time::Now(); | 380 base::Time current_time = base::Time::Now(); |
379 | 381 |
380 // TODO(agulenko): Support gzip compressed seed. | 382 // TODO(agulenko): Support gzip compressed seed. |
381 if (!StoreSeedData(seed_data, seed_signature, seed_country, current_time, | 383 if (!StoreSeedData(seed_data, seed_signature, seed_country, current_time, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 } | 532 } |
531 return true; | 533 return true; |
532 } | 534 } |
533 | 535 |
534 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { | 536 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { |
535 RecordSeedStoreHistogram( | 537 RecordSeedStoreHistogram( |
536 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); | 538 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); |
537 } | 539 } |
538 | 540 |
539 } // namespace variations | 541 } // namespace variations |
OLD | NEW |