Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: components/variations/variations_seed_store.cc

Issue 1437833004: Implemented clearing Java prefs after pulling variations first run seed from Java to C++ side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor code review fixes Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
Alexei Svitkine (slow) 2015/11/12 22:27:31 Put the header in an ifdef below since it won't bu
Alexander Agulenko 2015/11/12 23:43:39 Done.
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
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 defined(OS_ANDROID)
469 // If currently we do not have any stored pref then we mark seed storing as
470 // successful on the Java side of Chrome for Android to avoid repeated seed
471 // fetches and clear preferences on the Java side.
472 if (local_state_->GetString(prefs::kVariationsCompressedSeed).empty()) {
473 android::MarkVariationsSeedAsStored();
474 android::ClearJavaFirstRunPrefs();
475 }
476 #endif
477
467 // Update the saved country code only if one was returned from the server. 478 // 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 479 // Prefer the country code that was transmitted in the header over the one in
469 // the seed (which is deprecated). 480 // the seed (which is deprecated).
470 if (!country_code.empty()) 481 if (!country_code.empty())
471 local_state_->SetString(prefs::kVariationsCountry, country_code); 482 local_state_->SetString(prefs::kVariationsCountry, country_code);
472 else if (seed.has_country_code()) 483 else if (seed.has_country_code())
473 local_state_->SetString(prefs::kVariationsCountry, seed.country_code()); 484 local_state_->SetString(prefs::kVariationsCountry, seed.country_code());
474 485
475 local_state_->SetString(prefs::kVariationsCompressedSeed, base64_seed_data); 486 local_state_->SetString(prefs::kVariationsCompressedSeed, base64_seed_data);
476 UpdateSeedDateAndLogDayChange(date_fetched); 487 UpdateSeedDateAndLogDayChange(date_fetched);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 541 }
531 return true; 542 return true;
532 } 543 }
533 544
534 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { 545 void VariationsSeedStore::ReportUnsupportedSeedFormatError() {
535 RecordSeedStoreHistogram( 546 RecordSeedStoreHistogram(
536 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); 547 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT);
537 } 548 }
538 549
539 } // namespace variations 550 } // namespace variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698