1 // Copyright 2014 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 "ios/web/public/test/test_browser_state.h"
7 #include "base/files/file_path.h"
8 #include "base/test/null_task_runner.h"
9 #include "net/url_request/url_request_context.h"
10 #include "net/url_request/url_request_context_getter.h"
11 #include "net/url_request/url_request_test_util.h"
15 class TestContextURLRequestContextGetter
: public net::URLRequestContextGetter
{
17 TestContextURLRequestContextGetter()
18 : null_task_runner_(new base::NullTaskRunner
) {}
20 net::URLRequestContext
* GetURLRequestContext() override
{ return &context_
; }
22 scoped_refptr
<base::SingleThreadTaskRunner
>
23 GetNetworkTaskRunner() const override
{
24 return null_task_runner_
;
28 ~TestContextURLRequestContextGetter() override
{}
30 net::TestURLRequestContext context_
;
31 scoped_refptr
<base::SingleThreadTaskRunner
> null_task_runner_
;
37 TestBrowserState::TestBrowserState() : is_off_the_record_(false) {}
39 TestBrowserState::~TestBrowserState() {
42 bool TestBrowserState::IsOffTheRecord() const {
43 return is_off_the_record_
;
46 base::FilePath
TestBrowserState::GetStatePath() const {
47 return base::FilePath();
50 net::URLRequestContextGetter
* TestBrowserState::GetRequestContext() {
51 if (!request_context_
)
52 request_context_
= new TestContextURLRequestContextGetter();
53 return request_context_
.get();
56 void TestBrowserState::SetOffTheRecord(bool flag
) {
57 is_off_the_record_
= flag
;