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"
8 const char kDisableNetworkSwitch
[] = "someSwitch";
11 TestRequestAllowedNotifier::TestRequestAllowedNotifier(PrefService
* local_state
)
12 : ResourceRequestAllowedNotifier(local_state
, kDisableNetworkSwitch
),
13 override_requests_allowed_(false),
14 requests_allowed_(true) {
17 TestRequestAllowedNotifier::~TestRequestAllowedNotifier() {
20 void TestRequestAllowedNotifier::InitWithEulaAcceptNotifier(
22 scoped_ptr
<EulaAcceptedNotifier
> eula_notifier
) {
23 test_eula_notifier_
.swap(eula_notifier
);
27 void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed
) {
28 override_requests_allowed_
= true;
29 requests_allowed_
= allowed
;
32 void TestRequestAllowedNotifier::NotifyObserver() {
33 // Force the allowed state and requested state to true. This forces
34 // MaybeNotifyObserver to always notify observers, as MaybeNotifyObserver
35 // checks ResourceRequestsAllowed and requested state.
36 override_requests_allowed_
= true;
37 requests_allowed_
= true;
38 SetObserverRequestedForTesting(true);
39 MaybeNotifyObserver();
42 ResourceRequestAllowedNotifier::State
43 TestRequestAllowedNotifier::GetResourceRequestsAllowedState() {
44 if (override_requests_allowed_
)
45 return requests_allowed_
? ALLOWED
: DISALLOWED_NETWORK_DOWN
;
46 return ResourceRequestAllowedNotifier::GetResourceRequestsAllowedState();
49 EulaAcceptedNotifier
* TestRequestAllowedNotifier::CreateEulaNotifier() {
50 return test_eula_notifier_
.release();