Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / web_resource / resource_request_allowed_notifier_test_util.cc
blob9095416f791e770be996b779a1c8e14e5c0f350b
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 "chrome/browser/web_resource/resource_request_allowed_notifier_test_util.h"
7 TestRequestAllowedNotifier::TestRequestAllowedNotifier()
8 : override_requests_allowed_(false),
9 requests_allowed_(true) {
12 TestRequestAllowedNotifier::~TestRequestAllowedNotifier() {
15 void TestRequestAllowedNotifier::InitWithEulaAcceptNotifier(
16 Observer* observer,
17 scoped_ptr<EulaAcceptedNotifier> eula_notifier) {
18 test_eula_notifier_.swap(eula_notifier);
19 Init(observer);
22 void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) {
23 override_requests_allowed_ = true;
24 requests_allowed_ = allowed;
27 void TestRequestAllowedNotifier::NotifyObserver() {
28 // Force the allowed state and requested state to true. This forces
29 // MaybeNotifyObserver to always notify observers, as MaybeNotifyObserver
30 // checks ResourceRequestsAllowed and requested state.
31 override_requests_allowed_ = true;
32 requests_allowed_ = true;
33 SetObserverRequestedForTesting(true);
34 MaybeNotifyObserver();
37 ResourceRequestAllowedNotifier::State
38 TestRequestAllowedNotifier::GetResourceRequestsAllowedState() {
39 if (override_requests_allowed_)
40 return requests_allowed_ ? ALLOWED : DISALLOWED_NETWORK_DOWN;
41 return ResourceRequestAllowedNotifier::GetResourceRequestsAllowedState();
44 EulaAcceptedNotifier* TestRequestAllowedNotifier::CreateEulaNotifier() {
45 return test_eula_notifier_.release();