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

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: init 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..91d327d74c943c3ad39dde644f9b935bcb74e2ac 100644
--- a/chrome/browser/metrics/variations/variations_service.cc
+++ b/chrome/browser/metrics/variations/variations_service.cc
@@ -28,6 +28,10 @@
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/wizard_controller.h"
Nikita (slow) 2012/09/10 14:48:55 nit: Should be removed as already included in the
SteveT 2012/09/10 16:33:02 Done.
+#endif
+
namespace chrome_variations {
namespace {
@@ -100,6 +104,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 +170,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 +199,34 @@ void VariationsService::SetWasOfflineDuringLastRequestAttemptForTesting(
was_offline_during_last_request_attempt_ = offline;
}
+#if defined(OS_CHROMEOS)
+ void VariationsService::OnScreenChanged(chromeos::WizardScreen* next_screen) {
+ }
+
+ void VariationsService::OnSessionStart() {
+ }
+
+ void VariationsService::OnEulaAccepted() {
+ // If an earlier request attempt was aborted because the EULA was not
+ // accepted, retry the request now.
+ 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