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

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

Issue 10917120: Activate the VariationsService for ChromeOS and ensure that it does not ping the server until the E… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: missed asvit nit Created 8 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: 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 2b95bf6e4aa1b2b0389b7f241fe50b541692edfa..fa4cbc2b24e2bdb21f7f1ce70c6ac22ffb0c6369 100644
--- a/chrome/browser/metrics/variations/variations_service.cc
+++ b/chrome/browser/metrics/variations/variations_service.cc
@@ -100,6 +100,9 @@ GURL GetVariationsServerURL() {
VariationsService::VariationsService()
: variations_server_url_(GetVariationsServerURL()),
create_trials_from_seed_called_(false),
+#if defined(OS_CHROMEOS)
+ waiting_for_user_to_accept_eula_(false),
+#endif
was_offline_during_last_request_attempt_(false) {
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
}
@@ -163,6 +166,16 @@ void VariationsService::FetchVariationsSeed() {
return;
}
+#if defined(OS_CHROMEOS)
+ if (!chromeos::WizardController::IsEulaAccepted()) {
+ // The WizardController should notify this class when the EULA has been
+ // accepted.
+ VLOG(1) << "EULA was not accepted.";
+ waiting_for_user_to_accept_eula_ = true;
+ return;
+ }
+#endif
+
pending_seed_request_.reset(net::URLFetcher::Create(
variations_server_url_, net::URLFetcher::GET, this));
pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
@@ -182,6 +195,37 @@ void VariationsService::SetWasOfflineDuringLastRequestAttemptForTesting(
was_offline_during_last_request_attempt_ = offline;
}
+#if defined(OS_CHROMEOS)
+void VariationsService::OnScreenChanged(chromeos::WizardScreen* next_screen) {
+ // Not implemented as VariationsService does not care about screen changes.
+}
+
+void VariationsService::OnSessionStart() {
+ // Not implemented as VariationsService does not care about session starts.
+}
+
+void VariationsService::OnEulaAccepted() {
+ // If an earlier request attempt was aborted because the EULA was not
+ // accepted, retry the request now.
+ // Note that if the EULA check succeeded earlier, this just returns.
+ if (!waiting_for_user_to_accept_eula_)
+ return;
+ DCHECK(chromeos::WizardController::IsEulaAccepted());
+ waiting_for_user_to_accept_eula_ = false;
+
+ DCHECK(chromeos::WizardController::default_controller());
+ chromeos::WizardController::default_controller()->RemoveObserver(this);
+
+ VLOG(1) << "Starting ping because the EULA was accepted.";
+ FetchVariationsSeed();
+
+ // Since FetchVariationsSeed was explicitly called here, reset the timer to
+ // avoid retrying for a full period.
+ if (timer_.IsRunning())
+ timer_.Reset();
+}
+#endif
+
// static
void VariationsService::RegisterPrefs(PrefService* prefs) {
prefs->RegisterStringPref(prefs::kVariationsSeed, std::string());

Powered by Google App Engine
This is Rietveld 408576698