Chromium Code Reviews| 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 return false; | 458 return false; |
| 458 } | 459 } |
| 459 | 460 |
| 460 std::string base64_seed_data; | 461 std::string base64_seed_data; |
| 461 base::Base64Encode(compressed_seed_data, &base64_seed_data); | 462 base::Base64Encode(compressed_seed_data, &base64_seed_data); |
| 462 | 463 |
| 463 // TODO(asvitkine): This pref is no longer being used. Remove it completely | 464 // TODO(asvitkine): This pref is no longer being used. Remove it completely |
| 464 // in M45+. | 465 // in M45+. |
| 465 local_state_->ClearPref(prefs::kVariationsSeed); | 466 local_state_->ClearPref(prefs::kVariationsSeed); |
| 466 | 467 |
| 468 // If currently we do not have any stored pref then we clear prefs on the | |
|
Alexei Svitkine (slow)
2015/11/12 17:42:17
Add an ifdef around this block
Alexander Agulenko
2015/11/12 18:55:04
Done.
| |
| 469 // Java side of Chrome for Android. | |
| 470 if (local_state_->GetString(prefs::kVariationsCompressedSeed).empty()) { | |
|
Alexei Svitkine (slow)
2015/11/12 17:42:17
Nit: No {}'s
Alexander Agulenko
2015/11/12 18:55:04
Added another function call to this block, so {}'s
| |
| 471 android::ClearJavaFirstRunPrefs(); | |
| 472 } | |
| 473 | |
| 467 // Update the saved country code only if one was returned from the server. | 474 // Update the saved country code only if one was returned from the server. |
| 468 // Prefer the country code that was transmitted in the header over the one in | 475 // Prefer the country code that was transmitted in the header over the one in |
| 469 // the seed (which is deprecated). | 476 // the seed (which is deprecated). |
| 470 if (!country_code.empty()) | 477 if (!country_code.empty()) |
| 471 local_state_->SetString(prefs::kVariationsCountry, country_code); | 478 local_state_->SetString(prefs::kVariationsCountry, country_code); |
| 472 else if (seed.has_country_code()) | 479 else if (seed.has_country_code()) |
| 473 local_state_->SetString(prefs::kVariationsCountry, seed.country_code()); | 480 local_state_->SetString(prefs::kVariationsCountry, seed.country_code()); |
| 474 | 481 |
| 475 local_state_->SetString(prefs::kVariationsCompressedSeed, base64_seed_data); | 482 local_state_->SetString(prefs::kVariationsCompressedSeed, base64_seed_data); |
| 476 UpdateSeedDateAndLogDayChange(date_fetched); | 483 UpdateSeedDateAndLogDayChange(date_fetched); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 } | 537 } |
| 531 return true; | 538 return true; |
| 532 } | 539 } |
| 533 | 540 |
| 534 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { | 541 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { |
| 535 RecordSeedStoreHistogram( | 542 RecordSeedStoreHistogram( |
| 536 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); | 543 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); |
| 537 } | 544 } |
| 538 | 545 |
| 539 } // namespace variations | 546 } // namespace variations |
| OLD | NEW |