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

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: 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..67e98840835abbd13ae944a47881c443940d94a0 100644
--- a/components/variations/service/variations_service.cc
+++ b/components/variations/service/variations_service.cc
@@ -31,7 +31,6 @@
#include "components/variations/variations_seed_simulator.h"
#include "components/variations/variations_switches.h"
#include "components/variations/variations_url_constants.h"
-#include "components/version_info/version_info.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/network_change_notifier.h"
@@ -842,12 +841,17 @@ std::string VariationsService::LoadPermanentConsistencyCountry(
}
// Otherwise, update the pref with the current Chrome version and country.
+ StorePermanentCountry(version, latest_country);
+ return latest_country;
+}
+
+void VariationsService::StorePermanentCountry(const base::Version& version,
+ const std::string& country) {
base::ListValue new_list_value;
new_list_value.AppendString(version.GetString());
- new_list_value.AppendString(latest_country);
+ new_list_value.AppendString(country);
local_state_->Set(prefs::kVariationsPermanentConsistencyCountry,
new_list_value);
- return latest_country;
}
std::string VariationsService::GetStoredPermanentCountry() {
@@ -862,4 +866,26 @@ std::string VariationsService::GetStoredPermanentCountry() {
return stored_country;
}
+bool VariationsService::OverrideStoredPermanentCountry(
+ const std::string& country_override) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ if (country_override.empty())
+ 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);
+
+ if (got_stored_country && stored_country == country_override)
+ return false;
+
+ base::Version version(version_info::GetVersionNumber());
+ StorePermanentCountry(version, country_override);
+ return true;
+}
+
} // namespace variations
« no previous file with comments | « components/variations/service/variations_service.h ('k') | components/variations/service/variations_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698