1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/web_resource/resource_request_allowed_notifier_test_util.h"
7 namespace web_resource
{
9 TestRequestAllowedNotifier::TestRequestAllowedNotifier(PrefService
* local_state
)
10 : ResourceRequestAllowedNotifier(local_state
, nullptr),
11 override_requests_allowed_(false),
12 requests_allowed_(true) {
15 TestRequestAllowedNotifier::~TestRequestAllowedNotifier() {
18 void TestRequestAllowedNotifier::InitWithEulaAcceptNotifier(
20 scoped_ptr
<EulaAcceptedNotifier
> eula_notifier
) {
21 test_eula_notifier_
.swap(eula_notifier
);
25 void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed
) {
26 override_requests_allowed_
= true;
27 requests_allowed_
= allowed
;
30 void TestRequestAllowedNotifier::NotifyObserver() {
31 // Force the allowed state and requested state to true. This forces
32 // MaybeNotifyObserver to always notify observers, as MaybeNotifyObserver
33 // checks ResourceRequestsAllowed and requested state.
34 override_requests_allowed_
= true;
35 requests_allowed_
= true;
36 SetObserverRequestedForTesting(true);
37 MaybeNotifyObserver();
40 ResourceRequestAllowedNotifier::State
41 TestRequestAllowedNotifier::GetResourceRequestsAllowedState() {
42 if (override_requests_allowed_
)
43 return requests_allowed_
? ALLOWED
: DISALLOWED_NETWORK_DOWN
;
44 return ResourceRequestAllowedNotifier::GetResourceRequestsAllowedState();
47 EulaAcceptedNotifier
* TestRequestAllowedNotifier::CreateEulaNotifier() {
48 return test_eula_notifier_
.release();
51 } // namespace web_resource