Chromium Code Reviews| 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..a423b0b2fcda2102170c0ee3ee0316974d9be4b5 |
| --- /dev/null |
| +++ b/chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.cc |
| @@ -0,0 +1,48 @@ |
| +// 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() |
| + : requests_allowed_(true), |
| +#if defined(OS_CHROMEOS) |
| + eula_accepted_(false), |
| +#endif |
| + override_requests_allowed_(false) { |
| +} |
| + |
| +TestRequestAllowedNotifier::~TestRequestAllowedNotifier() { |
| +} |
| + |
| +#if defined(OS_CHROMEOS) |
| +void TestRequestAllowedNotifier::SetEulaAccepted(bool accepted) { |
| + eula_accepted_ = accepted; |
| +} |
| +#endif |
| + |
| +void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) { |
| + override_requests_allowed_ = true; |
| + requests_allowed_ = allowed; |
| +} |
| + |
| +void TestRequestAllowedNotifier::NotifyObservers() { |
| + // Force the allowed state to true. This forces MaybeNotifyObserver to always |
| + // notify observers. |
|
Alexei Svitkine (slow)
2012/09/24 15:59:36
Nit: Expand comment to say that MaybeNotifyObserve
SteveT
2012/09/24 18:04:27
Done.
|
| + override_requests_allowed_ = true; |
| + requests_allowed_ = true; |
| + MaybeNotifyObserver(); |
| +} |
| + |
| +#if defined(OS_CHROMEOS) |
| +bool TestRequestAllowedNotifier::IsEulaAccepted() { |
| + return eula_accepted_; |
| +} |
| +#endif |
| + |
| +bool TestRequestAllowedNotifier::ResourceRequestsAllowed() { |
| + SetObserverRequestedPermissionForTesting(true); |
| + if (override_requests_allowed_) |
| + return requests_allowed_; |
| + return ResourceRequestAllowedNotifier::ResourceRequestsAllowed(); |
| +} |