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

Unified Diff: chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.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: one more 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/resource_request_allowed_notifier_test_util.cc
diff --git a/chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.cc b/chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..665cf861c5a8e81b7c3fcb6f080500bbb457ddab
--- /dev/null
+++ b/chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.h"
+
+TestRequestAllowedNotifier::TestRequestAllowedNotifier() :
+#if defined(OS_CHROMEOS)
+ needs_eula_acceptance_(true),
+#endif
+ override_requests_allowed_(false),
+ requests_allowed_(true) {
+}
+
+TestRequestAllowedNotifier::~TestRequestAllowedNotifier() {
+}
+
+#if defined(OS_CHROMEOS)
+void TestRequestAllowedNotifier::SetNeedsEulaAcceptance(bool needs_acceptance) {
+ needs_eula_acceptance_ = needs_acceptance;
+}
+#endif
+
+void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) {
+ override_requests_allowed_ = true;
+ requests_allowed_ = allowed;
+}
+
+void TestRequestAllowedNotifier::NotifyObserver() {
+ // Force the allowed state to true. This forces MaybeNotifyObserver to always
+ // notify observers, as MaybeNotifyObserver checks ResourceRequestsAllowed.
+ override_requests_allowed_ = true;
+ requests_allowed_ = true;
+ MaybeNotifyObserver();
+}
+
+bool TestRequestAllowedNotifier::ResourceRequestsAllowed() {
+ // Call ResourceRequestAllowedNotifier::ResourceRequestsAllowed once to
+ // simulate that the user requested permission. Only return that result if
+ // the override flag was set.
+ bool requests_allowed =
+ ResourceRequestAllowedNotifier::ResourceRequestsAllowed();
+ if (override_requests_allowed_)
+ return requests_allowed_;
+ return requests_allowed;
+}
+
+#if defined(OS_CHROMEOS)
+bool TestRequestAllowedNotifier::NeedsEulaAcceptance() {
+ return needs_eula_acceptance_;
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698