| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/test/test_browser_context.h" | 5 #include "content/public/test/test_browser_context.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/test/null_task_runner.h" | 8 #include "base/test/null_task_runner.h" |
| 9 #include "content/public/browser/cookie_store_factory.h" |
| 10 #include "content/public/browser/storage_partition.h" |
| 9 #include "content/public/test/mock_resource_context.h" | 11 #include "content/public/test/mock_resource_context.h" |
| 10 #include "net/url_request/url_request_context.h" | 12 #include "net/url_request/url_request_context.h" |
| 11 #include "net/url_request/url_request_context_getter.h" | 13 #include "net/url_request/url_request_context_getter.h" |
| 12 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "webkit/browser/quota/special_storage_policy.h" | 16 #include "webkit/browser/quota/special_storage_policy.h" |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter { | 20 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 60 } |
| 59 | 61 |
| 60 base::FilePath TestBrowserContext::GetPath() const { | 62 base::FilePath TestBrowserContext::GetPath() const { |
| 61 return browser_context_dir_.path(); | 63 return browser_context_dir_.path(); |
| 62 } | 64 } |
| 63 | 65 |
| 64 bool TestBrowserContext::IsOffTheRecord() const { | 66 bool TestBrowserContext::IsOffTheRecord() const { |
| 65 return false; | 67 return false; |
| 66 } | 68 } |
| 67 | 69 |
| 70 CookieStoreConfig TestBrowserContext::GetCookieStoreConfig() { |
| 71 return CookieStoreConfig::InMemory(); |
| 72 } |
| 73 |
| 68 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() { | 74 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() { |
| 69 return NULL; | 75 return NULL; |
| 70 } | 76 } |
| 71 | 77 |
| 72 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() { | 78 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() { |
| 73 if (!request_context_.get()) { | 79 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
| 74 request_context_ = new TestContextURLRequestContextGetter(); | |
| 75 } | |
| 76 return request_context_.get(); | |
| 77 } | 80 } |
| 78 | 81 |
| 79 net::URLRequestContextGetter* | 82 net::URLRequestContextGetter* |
| 80 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) { | 83 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) { |
| 81 return NULL; | 84 return NULL; |
| 82 } | 85 } |
| 83 | 86 |
| 84 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() { | 87 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() { |
| 85 return NULL; | 88 return NULL; |
| 86 } | 89 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 102 int render_process_id, | 105 int render_process_id, |
| 103 int render_view_id, | 106 int render_view_id, |
| 104 const GURL& requesting_frame, | 107 const GURL& requesting_frame, |
| 105 const MIDISysExPermissionCallback& callback) { | 108 const MIDISysExPermissionCallback& callback) { |
| 106 // Always reject requests for testing. | 109 // Always reject requests for testing. |
| 107 callback.Run(false); | 110 callback.Run(false); |
| 108 } | 111 } |
| 109 | 112 |
| 110 ResourceContext* TestBrowserContext::GetResourceContext() { | 113 ResourceContext* TestBrowserContext::GetResourceContext() { |
| 111 if (!resource_context_) | 114 if (!resource_context_) |
| 112 resource_context_.reset(new MockResourceContext( | 115 resource_context_.reset(new MockResourceContext()); |
| 113 GetRequestContext()->GetURLRequestContext())); | |
| 114 return resource_context_.get(); | 116 return resource_context_.get(); |
| 115 } | 117 } |
| 116 | 118 |
| 117 GeolocationPermissionContext* | 119 GeolocationPermissionContext* |
| 118 TestBrowserContext::GetGeolocationPermissionContext() { | 120 TestBrowserContext::GetGeolocationPermissionContext() { |
| 119 return NULL; | 121 return NULL; |
| 120 } | 122 } |
| 121 | 123 |
| 122 quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() { | 124 quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() { |
| 123 return special_storage_policy_.get(); | 125 return special_storage_policy_.get(); |
| 124 } | 126 } |
| 125 | 127 |
| 126 } // namespace content | 128 } // namespace content |
| OLD | NEW |