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

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

Issue 14268009: Support VariationsRestrictParameter in VariationsService for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed a test Created 7 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: 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 0828c1363584cb1b9f1670fcb8b2afe417982d26..1adf5657bc461eb172b4be5694f2ff766be72d30 100644
--- a/chrome/browser/metrics/variations/variations_service.cc
+++ b/chrome/browser/metrics/variations/variations_service.cc
@@ -32,6 +32,10 @@
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/settings/cros_settings.h"
+#endif
+
namespace chrome_variations {
namespace {
@@ -114,6 +118,20 @@ base::Time ConvertStudyDateToBaseTime(int64 date_time) {
return base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(date_time);
}
+// Gets the restrict parameter from |local_state| or from Chrome OS settings in
+// the case of that platform.
+std::string GetRestrictParameterPref(PrefService* local_state) {
+ std::string parameter;
+#if defined(OS_CHROMEOS)
+ chromeos::CrosSettings::Get()->GetString(
+ chromeos::kVariationsRestrictParameter, &parameter);
+#else
+ if (local_state)
+ parameter = local_state->GetString(prefs::kVariationsRestrictParameter);
+#endif
+ return parameter;
+}
+
} // namespace
VariationsService::VariationsService(PrefService* local_state)
@@ -211,14 +229,11 @@ GURL VariationsService::GetVariationsServerURL(PrefService* local_state) {
if (server_url_string.empty())
server_url_string = kDefaultVariationsServerURL;
GURL server_url = GURL(server_url_string);
- if (local_state) {
- // Append the "restrict" parameter if it is found in prefs.
- const std::string restrict_param =
- local_state->GetString(prefs::kVariationsRestrictParameter);
- if (!restrict_param.empty())
- server_url = net::AppendOrReplaceQueryParameter(server_url,
- "restrict",
- restrict_param);
+ const std::string restrict_param = GetRestrictParameterPref(local_state);
+ if (!restrict_param.empty()) {
+ server_url = net::AppendOrReplaceQueryParameter(server_url,
+ "restrict",
+ restrict_param);
}
DCHECK(server_url.is_valid());
return server_url;

Powered by Google App Engine
This is Rietveld 408576698