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

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

Issue 2914163003: Add a command-line flag for overriding variations country. (Closed)
Patch Set: Add missing include. Created 3 years, 7 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
« no previous file with comments | « no previous file | components/variations/variations_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/service/variations_service.cc
diff --git a/components/variations/service/variations_service.cc b/components/variations/service/variations_service.cc
index 826fe0d864f2ebcb388d3d97f6030d450a60fe3d..e669699c2cdeb152dfc3820abfac56610c5e31e1 100644
--- a/components/variations/service/variations_service.cc
+++ b/components/variations/service/variations_service.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <utility>
+#include <vector>
#include "base/build_time.h"
#include "base/command_line.h"
@@ -336,9 +337,7 @@ bool VariationsService::CreateTrialsFromSeed(base::FeatureList* feature_list) {
GetChannelForVariations(client_->GetChannel());
UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel);
- const std::string latest_country =
- local_state_->GetString(prefs::kVariationsCountry);
-
+ const std::string latest_country = GetLatestCountry();
std::unique_ptr<const base::FieldTrial::EntropyProvider> low_entropy_provider(
CreateLowEntropyProvider());
// Note that passing |&ui_string_overrider_| via base::Unretained below is
@@ -780,8 +779,7 @@ void VariationsService::PerformSimulationWithVersion(
variations::VariationsSeedSimulator seed_simulator(*default_provider,
*low_provider);
- const std::string latest_country =
- local_state_->GetString(prefs::kVariationsCountry);
+ const std::string latest_country = GetLatestCountry();
const variations::VariationsSeedSimulator::Result result =
seed_simulator.SimulateSeedStudies(
*seed, client_->GetApplicationLocale(),
@@ -823,6 +821,12 @@ std::string VariationsService::LoadPermanentConsistencyCountry(
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(version.IsValid());
+ const std::string override_country =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kVariationsOverrideCountry);
+ if (!override_country.empty())
+ return override_country;
+
const base::ListValue* list_value =
local_state_->GetList(prefs::kVariationsPermanentConsistencyCountry);
std::string stored_version_string;
@@ -930,7 +934,12 @@ bool VariationsService::OverrideStoredPermanentCountry(
}
std::string VariationsService::GetLatestCountry() const {
- return local_state_->GetString(prefs::kVariationsCountry);
+ const std::string override_country =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kVariationsOverrideCountry);
+ return !override_country.empty()
+ ? override_country
+ : local_state_->GetString(prefs::kVariationsCountry);
}
} // namespace variations
« no previous file with comments | « no previous file | components/variations/variations_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698