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

Unified Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 370463003: Add support for variations controlled overriding UI strings to the variations service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asvitkine's first round of comments Created 6 years, 5 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: chrome/browser/metrics/variations/variations_service.cc
diff --git a/chrome/browser/metrics/variations/variations_service.cc b/chrome/browser/metrics/variations/variations_service.cc
index e19b4521644b5fa0c81d021ea3ec5ddf85664951..e59b6f13f4c4d205834475959b5a40e4c675267f 100644
--- a/chrome/browser/metrics/variations/variations_service.cc
+++ b/chrome/browser/metrics/variations/variations_service.cc
@@ -17,6 +17,7 @@
#include "base/version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/metrics_state_manager.h"
+#include "chrome/browser/metrics/variations/generated_resources_map.h"
#include "chrome/browser/network_time/network_time_tracker.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -35,6 +36,7 @@
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h"
#include "ui/base/device_form_factor.h"
+#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
#if defined(OS_CHROMEOS)
@@ -198,6 +200,16 @@ base::Time GetReferenceDateForExpiryChecks(PrefService* local_state) {
return reference_date;
}
+// Overrides the string resource sepecified by |hash| with |string| in the
+// resource bundle. Used as a callback passed to the variations seed processor.
+void OverrideUIString(uint32_t hash, const base::string16& string) {
+ int index = GetResourceIndex(hash);
Alexei Svitkine (slow) 2014/07/15 16:44:52 Nit: It might be clearer to use |resource_id| term
jwd 2014/07/16 21:33:05 Done.
+ if (index == -1)
+ return;
+
+ ui::ResourceBundle::GetSharedInstance().OverrideStringResource(index, string);
Alexei Svitkine (slow) 2014/07/15 16:44:52 Has the method been renamed to OverrideLocaleStrin
jwd 2014/07/16 21:33:05 Yup, rebased now.
+}
+
} // namespace
VariationsService::VariationsService(
@@ -249,7 +261,8 @@ bool VariationsService::CreateTrialsFromSeed() {
VariationsSeedProcessor().CreateTrialsFromSeed(
seed, g_browser_process->GetApplicationLocale(),
GetReferenceDateForExpiryChecks(local_state_), current_version,
- GetChannelForVariations(), GetCurrentFormFactor(), GetHardwareClass());
+ GetChannelForVariations(), GetCurrentFormFactor(), GetHardwareClass(),
+ base::Bind(&OverrideUIString));
// Log the "freshness" of the seed that was just used. The freshness is the
// time between the last successful seed download and now.

Powered by Google App Engine
This is Rietveld 408576698