Chromium Code Reviews| Index: components/variations/variations_seed_store.cc |
| diff --git a/components/variations/variations_seed_store.cc b/components/variations/variations_seed_store.cc |
| index 89e1af214400935b73c4099d3897ec7cf29e221a..0861fb725b03b3922fad48d69215daec375521cf 100644 |
| --- a/components/variations/variations_seed_store.cc |
| +++ b/components/variations/variations_seed_store.cc |
| @@ -152,6 +152,11 @@ VariationsSeedStore::~VariationsSeedStore() { |
| bool VariationsSeedStore::LoadSeed(variations::VariationsSeed* seed) { |
| invalid_base64_signature_.clear(); |
| +#if defined(OS_ANDROID) |
| + if (!local_state_->HasPrefPath(prefs::kVariationsSeedSignature)) |
| + ImportFirstRunJavaSeed(); |
|
Bernhard Bauer
2015/11/03 09:44:49
Indent.
Alexander Agulenko
2015/11/04 08:00:59
Done.
|
| +#endif // OS_ANDROID |
| + |
| std::string seed_data; |
| if (!ReadSeedData(&seed_data)) |
| return false; |
| @@ -336,6 +341,34 @@ void VariationsSeedStore::ClearPrefs() { |
| local_state_->ClearPref(prefs::kVariationsSeedSignature); |
| } |
| +#if defined(OS_ANDROID) |
| +void VariationsSeedStore::ImportFirstRunJavaSeed() { |
| + DVLOG(1) << "Importing first run seed from Java preferences."; |
| + std::string seed_data; |
| + std::string seed_signature; |
| + std::string seed_country; |
| + get_variations_first_run_seed_.Run(&seed_data, &seed_signature, |
| + &seed_country); |
| + |
| + if (seed_data.empty()) { |
| + // TODO(agulenko): add a new UMA histogram for the state of failing |
| + // to import seed from Java preferences during Chrome first run. |
| + return; |
| + } |
| + |
| + // TODO(agulenko): Pull actual time from the response. |
| + base::Time current_time = base::Time::Now(); |
| + |
| + // TODO(agulenko): Support gzip compressed seed. |
| + if (!StoreSeedData(seed_data, seed_signature, seed_country, |
| + current_time, false, false, nullptr)) { |
| + LOG(WARNING) << "First run variations seed is invalid."; |
| + return; |
| + } |
| + // TODO(agulenko): Clear Java prefs. |
| +} |
| +#endif // OS_ANDROID |
| + |
| bool VariationsSeedStore::ReadSeedData(std::string* seed_data) { |
| std::string base64_seed_data = |
| local_state_->GetString(prefs::kVariationsCompressedSeed); |