Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / public / test / test_browser_context.cc
blob107dbb25f1482e7a52bc22c107cf1e1d05e0e05b
1 // Copyright (c) 2012 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 "content/public/test/test_browser_context.h"
7 #include "base/files/file_path.h"
8 #include "base/test/null_task_runner.h"
9 #include "content/public/test/mock_resource_context.h"
10 #include "net/url_request/url_request_context.h"
11 #include "net/url_request/url_request_context_getter.h"
12 #include "net/url_request/url_request_test_util.h"
13 #include "storage/browser/quota/special_storage_policy.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 namespace {
18 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter {
19 public:
20 TestContextURLRequestContextGetter()
21 : null_task_runner_(new base::NullTaskRunner) {
24 net::URLRequestContext* GetURLRequestContext() override { return &context_; }
26 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
27 const override {
28 return null_task_runner_;
31 private:
32 ~TestContextURLRequestContextGetter() override {}
34 net::TestURLRequestContext context_;
35 scoped_refptr<base::SingleThreadTaskRunner> null_task_runner_;
38 } // namespace
40 namespace content {
42 TestBrowserContext::TestBrowserContext() {
43 EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir());
46 TestBrowserContext::~TestBrowserContext() {
49 base::FilePath TestBrowserContext::TakePath() {
50 return browser_context_dir_.Take();
53 void TestBrowserContext::SetSpecialStoragePolicy(
54 storage::SpecialStoragePolicy* policy) {
55 special_storage_policy_ = policy;
58 base::FilePath TestBrowserContext::GetPath() const {
59 return browser_context_dir_.path();
62 scoped_ptr<ZoomLevelDelegate> TestBrowserContext::CreateZoomLevelDelegate(
63 const base::FilePath& partition_path) {
64 return scoped_ptr<ZoomLevelDelegate>();
67 bool TestBrowserContext::IsOffTheRecord() const {
68 return false;
71 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
72 return NULL;
75 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() {
76 if (!request_context_.get()) {
77 request_context_ = new TestContextURLRequestContextGetter();
79 return request_context_.get();
82 net::URLRequestContextGetter*
83 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
84 return NULL;
87 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() {
88 return NULL;
91 net::URLRequestContextGetter*
92 TestBrowserContext::GetMediaRequestContextForRenderProcess(
93 int renderer_child_id) {
94 return NULL;
97 net::URLRequestContextGetter*
98 TestBrowserContext::GetMediaRequestContextForStoragePartition(
99 const base::FilePath& partition_path,
100 bool in_memory) {
101 return NULL;
104 ResourceContext* TestBrowserContext::GetResourceContext() {
105 if (!resource_context_)
106 resource_context_.reset(new MockResourceContext(
107 GetRequestContext()->GetURLRequestContext()));
108 return resource_context_.get();
111 BrowserPluginGuestManager* TestBrowserContext::GetGuestManager() {
112 return NULL;
115 storage::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() {
116 return special_storage_policy_.get();
119 PushMessagingService* TestBrowserContext::GetPushMessagingService() {
120 return NULL;
123 SSLHostStateDelegate* TestBrowserContext::GetSSLHostStateDelegate() {
124 return NULL;
127 PermissionManager* TestBrowserContext::GetPermissionManager() {
128 return NULL;
131 } // namespace content