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

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

Issue 1363243004: Allow embedders to share code to override UI strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 bdc3e2a2951a4ba6d79fa181d209ec9524397a59..7fb5909c4815f871d9312f5935fc5ab3d7941b45 100644
--- a/components/variations/service/variations_service.cc
+++ b/components/variations/service/variations_service.cc
@@ -203,8 +203,10 @@ VariationsService::VariationsService(
scoped_ptr<VariationsServiceClient> client,
scoped_ptr<web_resource::ResourceRequestAllowedNotifier> notifier,
PrefService* local_state,
- metrics::MetricsStateManager* state_manager)
+ metrics::MetricsStateManager* state_manager,
+ const UIStringOverrider& ui_string_overrider)
: client_(client.Pass()),
+ ui_string_overrider_(ui_string_overrider),
local_state_(local_state),
state_manager_(state_manager),
policy_pref_service_(local_state),
@@ -240,15 +242,15 @@ bool VariationsService::CreateTrialsFromSeed() {
const std::string latest_country =
local_state_->GetString(prefs::kVariationsCountry);
- // Note that passing |client_| via base::Unretained below is safe because
- // the callback is executed synchronously.
+ // Note that passing |&ui_string_overrider_| via base::Unretained below is
+ // safe because the callback is executed synchronously.
variations::VariationsSeedProcessor().CreateTrialsFromSeed(
seed, client_->GetApplicationLocale(),
GetReferenceDateForExpiryChecks(local_state_), current_version, channel,
GetCurrentFormFactor(), GetHardwareClass(), latest_country,
LoadPermanentConsistencyCountry(current_version, latest_country),
- base::Bind(&VariationsServiceClient::OverrideUIString,
- base::Unretained(client_.get())));
+ base::Bind(&UIStringOverrider::OverrideUIString,
+ base::Unretained(&ui_string_overrider_)));
Alexei Svitkine (slow) 2015/09/24 21:51:23 Can this pass a ref to the object instead of a cal
blundell 2015/09/25 13:06:56 //components/variations can't depend on //ui/base,
Alexei Svitkine (slow) 2015/09/25 14:45:56 Gotcha. Maybe worth mentioning that in the comment
sdefresne 2015/09/28 08:57:32 Acknowledged and added a comment.
const base::Time now = base::Time::Now();
@@ -415,7 +417,8 @@ scoped_ptr<VariationsService> VariationsService::Create(
scoped_ptr<VariationsServiceClient> client,
PrefService* local_state,
metrics::MetricsStateManager* state_manager,
- const char* disable_network_switch) {
+ const char* disable_network_switch,
+ const UIStringOverrider& ui_string_overrider) {
scoped_ptr<VariationsService> result;
#if !defined(GOOGLE_CHROME_BUILD)
// Unless the URL was provided, unsupported builds should return NULL to
@@ -431,7 +434,7 @@ scoped_ptr<VariationsService> VariationsService::Create(
client.Pass(),
make_scoped_ptr(new web_resource::ResourceRequestAllowedNotifier(
local_state, disable_network_switch)),
- local_state, state_manager));
+ local_state, state_manager, ui_string_overrider));
return result.Pass();
}
@@ -443,7 +446,7 @@ scoped_ptr<VariationsService> VariationsService::CreateForTesting(
client.Pass(),
make_scoped_ptr(new web_resource::ResourceRequestAllowedNotifier(
local_state, nullptr)),
- local_state, nullptr));
+ local_state, nullptr, UIStringOverrider()));
}
void VariationsService::DoActualFetch() {

Powered by Google App Engine
This is Rietveld 408576698