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

Unified Diff: components/variations/service/variations_service.cc

Issue 1903593002: Allows to manually change the stored permanent country in Variations from the translate-internals d… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UI polishing Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: components/variations/service/variations_service.cc
diff --git a/components/variations/service/variations_service.cc b/components/variations/service/variations_service.cc
index 9e0c4c75134475d3c52a05a06922c2ff01668938..8f03d7ba20d2f320f526da95e92d9c616c11c730 100644
--- a/components/variations/service/variations_service.cc
+++ b/components/variations/service/variations_service.cc
@@ -862,4 +862,36 @@ std::string VariationsService::GetStoredPermanentCountry() {
return stored_country;
}
+bool VariationsService::ForceSetStoredPermanentCountry(
+ const std::string& country_override) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ // FIXME: Can we check for valid country?
Alexei Svitkine (slow) 2016/04/20 20:30:24 Probably not really feasible.
hamelphi 2016/04/20 21:39:47 Acknowledged.
+ if(country_override.empty()) {
Alexei Svitkine (slow) 2016/04/20 20:30:24 Nit: space after if. Also, no {}'s on a one-line i
hamelphi 2016/04/20 21:39:47 Done.
+ return false;
+ }
+
+ const base::ListValue* list_value =
+ local_state_->GetList(prefs::kVariationsPermanentConsistencyCountry);
+
+ std::string stored_country;
+ const bool got_stored_country =
+ list_value->GetSize() == 2 && list_value->GetString(1, &stored_country);
+
+ const bool needs_update =
+ !got_stored_country || stored_country != country_override;
+
+ if (!needs_update) {
+ return false;
Alexei Svitkine (slow) 2016/04/20 20:30:24 Not sure we actually need this logic. What's the d
hamelphi 2016/04/20 21:39:47 There is no danger. However, this allows us to tel
Alexei Svitkine (slow) 2016/04/20 21:46:44 That makes sense. However, I feel it's strange to
+ }
+ std::string current_version = version_info::GetVersionNumber();
+
+ base::ListValue new_list_value;
+ new_list_value.AppendString(current_version);
+ new_list_value.AppendString(country_override);
+ local_state_->Set(prefs::kVariationsPermanentConsistencyCountry,
+ new_list_value);
Alexei Svitkine (slow) 2016/04/20 20:30:24 Can you make a helper function for this logic sinc
hamelphi 2016/04/20 21:39:47 Done.
+ return true;
+}
+
} // namespace variations

Powered by Google App Engine
This is Rietveld 408576698