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. 4 5#include "chrome/browser/web_resource/resource_request_allowed_notifier_test_util.h" 6 7TestRequestAllowedNotifier::TestRequestAllowedNotifier() 8 : override_requests_allowed_(false), 9 requests_allowed_(true) { 10} 11 12TestRequestAllowedNotifier::~TestRequestAllowedNotifier() { 13} 14 15void TestRequestAllowedNotifier::InitWithEulaAcceptNotifier( 16 Observer* observer, 17 scoped_ptr<EulaAcceptedNotifier> eula_notifier) { 18 test_eula_notifier_.swap(eula_notifier); 19 Init(observer); 20} 21 22void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) { 23 override_requests_allowed_ = true; 24 requests_allowed_ = allowed; 25} 26 27void 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(); 35} 36 37ResourceRequestAllowedNotifier::State 38 TestRequestAllowedNotifier::GetResourceRequestsAllowedState() { 39 if (override_requests_allowed_) 40 return requests_allowed_ ? ALLOWED : DISALLOWED_NETWORK_DOWN; 41 return ResourceRequestAllowedNotifier::GetResourceRequestsAllowedState(); 42} 43 44EulaAcceptedNotifier* TestRequestAllowedNotifier::CreateEulaNotifier() { 45 return test_eula_notifier_.release(); 46} 47