1 // Copyright 2017 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 "content/public/test/test_storage_partition.h"
6 
7 #include "components/leveldb_proto/public/proto_database_provider.h"
8 #include "content/public/browser/native_file_system_entry_factory.h"
9 #include "services/network/public/mojom/cookie_manager.mojom.h"
10 
11 namespace content {
12 
TestStoragePartition()13 TestStoragePartition::TestStoragePartition() {}
~TestStoragePartition()14 TestStoragePartition::~TestStoragePartition() {}
15 
GetPath()16 base::FilePath TestStoragePartition::GetPath() {
17   return file_path_;
18 }
19 
GetNetworkContext()20 network::mojom::NetworkContext* TestStoragePartition::GetNetworkContext() {
21   return network_context_;
22 }
23 
24 scoped_refptr<network::SharedURLLoaderFactory>
GetURLLoaderFactoryForBrowserProcess()25 TestStoragePartition::GetURLLoaderFactoryForBrowserProcess() {
26   return nullptr;
27 }
28 
29 scoped_refptr<network::SharedURLLoaderFactory>
GetURLLoaderFactoryForBrowserProcessWithCORBEnabled()30 TestStoragePartition::GetURLLoaderFactoryForBrowserProcessWithCORBEnabled() {
31   return nullptr;
32 }
33 
34 std::unique_ptr<network::PendingSharedURLLoaderFactory>
GetURLLoaderFactoryForBrowserProcessIOThread()35 TestStoragePartition::GetURLLoaderFactoryForBrowserProcessIOThread() {
36   return nullptr;
37 }
38 
39 network::mojom::CookieManager*
GetCookieManagerForBrowserProcess()40 TestStoragePartition::GetCookieManagerForBrowserProcess() {
41   return cookie_manager_for_browser_process_;
42 }
43 
CreateHasTrustTokensAnswerer(mojo::PendingReceiver<network::mojom::HasTrustTokensAnswerer> receiver,const url::Origin & top_frame_origin)44 void TestStoragePartition::CreateHasTrustTokensAnswerer(
45     mojo::PendingReceiver<network::mojom::HasTrustTokensAnswerer> receiver,
46     const url::Origin& top_frame_origin) {
47   NOTREACHED() << "Not implemented.";
48 }
49 
GetQuotaManager()50 storage::QuotaManager* TestStoragePartition::GetQuotaManager() {
51   return quota_manager_;
52 }
53 
GetAppCacheService()54 AppCacheService* TestStoragePartition::GetAppCacheService() {
55   return app_cache_service_;
56 }
57 
GetBackgroundSyncContext()58 BackgroundSyncContext* TestStoragePartition::GetBackgroundSyncContext() {
59   return background_sync_context_;
60 }
61 
GetFileSystemContext()62 storage::FileSystemContext* TestStoragePartition::GetFileSystemContext() {
63   return file_system_context_;
64 }
65 
GetDatabaseTracker()66 storage::DatabaseTracker* TestStoragePartition::GetDatabaseTracker() {
67   return database_tracker_;
68 }
69 
GetDOMStorageContext()70 DOMStorageContext* TestStoragePartition::GetDOMStorageContext() {
71   return dom_storage_context_;
72 }
73 
GetIndexedDBControl()74 storage::mojom::IndexedDBControl& TestStoragePartition::GetIndexedDBControl() {
75   // Bind and throw away the receiver. If testing is required, then add a method
76   // to set the remote.
77   if (!indexed_db_control_.is_bound())
78     ignore_result(indexed_db_control_.BindNewPipeAndPassReceiver());
79   return *indexed_db_control_;
80 }
81 
82 NativeFileSystemEntryFactory*
GetNativeFileSystemEntryFactory()83 TestStoragePartition::GetNativeFileSystemEntryFactory() {
84   return nullptr;
85 }
86 
GetServiceWorkerContext()87 ServiceWorkerContext* TestStoragePartition::GetServiceWorkerContext() {
88   return service_worker_context_;
89 }
90 
GetDedicatedWorkerService()91 DedicatedWorkerService* TestStoragePartition::GetDedicatedWorkerService() {
92   return dedicated_worker_service_;
93 }
94 
GetSharedWorkerService()95 SharedWorkerService* TestStoragePartition::GetSharedWorkerService() {
96   return shared_worker_service_;
97 }
98 
GetCacheStorageContext()99 CacheStorageContext* TestStoragePartition::GetCacheStorageContext() {
100   return cache_storage_context_;
101 }
102 
103 GeneratedCodeCacheContext*
GetGeneratedCodeCacheContext()104 TestStoragePartition::GetGeneratedCodeCacheContext() {
105   return generated_code_cache_context_;
106 }
107 
108 PlatformNotificationContext*
GetPlatformNotificationContext()109 TestStoragePartition::GetPlatformNotificationContext() {
110   return platform_notification_context_;
111 }
112 
113 DevToolsBackgroundServicesContext*
GetDevToolsBackgroundServicesContext()114 TestStoragePartition::GetDevToolsBackgroundServicesContext() {
115   return devtools_background_services_context_;
116 }
117 
GetContentIndexContext()118 ContentIndexContext* TestStoragePartition::GetContentIndexContext() {
119   return content_index_context_;
120 }
121 
122 leveldb_proto::ProtoDatabaseProvider*
GetProtoDatabaseProvider()123 TestStoragePartition::GetProtoDatabaseProvider() {
124   return nullptr;
125 }
126 
SetProtoDatabaseProvider(std::unique_ptr<leveldb_proto::ProtoDatabaseProvider> proto_db_provider)127 void TestStoragePartition::SetProtoDatabaseProvider(
128     std::unique_ptr<leveldb_proto::ProtoDatabaseProvider> proto_db_provider) {}
129 
130 leveldb_proto::ProtoDatabaseProvider*
GetProtoDatabaseProviderForTesting()131 TestStoragePartition::GetProtoDatabaseProviderForTesting() {
132   return nullptr;
133 }
134 
135 #if !defined(OS_ANDROID)
GetHostZoomMap()136 HostZoomMap* TestStoragePartition::GetHostZoomMap() {
137   return host_zoom_map_;
138 }
139 
GetHostZoomLevelContext()140 HostZoomLevelContext* TestStoragePartition::GetHostZoomLevelContext() {
141   return host_zoom_level_context_;
142 }
143 
GetZoomLevelDelegate()144 ZoomLevelDelegate* TestStoragePartition::GetZoomLevelDelegate() {
145   return zoom_level_delegate_;
146 }
147 #endif  // !defined(OS_ANDROID)
148 
ClearDataForOrigin(uint32_t remove_mask,uint32_t quota_storage_remove_mask,const GURL & storage_origin)149 void TestStoragePartition::ClearDataForOrigin(
150     uint32_t remove_mask,
151     uint32_t quota_storage_remove_mask,
152     const GURL& storage_origin) {}
153 
ClearData(uint32_t remove_mask,uint32_t quota_storage_remove_mask,const GURL & storage_origin,const base::Time begin,const base::Time end,base::OnceClosure callback)154 void TestStoragePartition::ClearData(
155     uint32_t remove_mask,
156     uint32_t quota_storage_remove_mask,
157     const GURL& storage_origin,
158     const base::Time begin,
159     const base::Time end,
160     base::OnceClosure callback) {}
161 
ClearData(uint32_t remove_mask,uint32_t quota_storage_remove_mask,OriginMatcherFunction origin_matcher,network::mojom::CookieDeletionFilterPtr cookie_deletion_filter,bool perform_storage_cleanup,const base::Time begin,const base::Time end,base::OnceClosure callback)162 void TestStoragePartition::ClearData(
163     uint32_t remove_mask,
164     uint32_t quota_storage_remove_mask,
165     OriginMatcherFunction origin_matcher,
166     network::mojom::CookieDeletionFilterPtr cookie_deletion_filter,
167     bool perform_storage_cleanup,
168     const base::Time begin,
169     const base::Time end,
170     base::OnceClosure callback) {}
171 
ClearCodeCaches(const base::Time begin,const base::Time end,const base::RepeatingCallback<bool (const GURL &)> & url_matcher,base::OnceClosure callback)172 void TestStoragePartition::ClearCodeCaches(
173     const base::Time begin,
174     const base::Time end,
175     const base::RepeatingCallback<bool(const GURL&)>& url_matcher,
176     base::OnceClosure callback) {}
177 
Flush()178 void TestStoragePartition::Flush() {}
179 
ResetURLLoaderFactories()180 void TestStoragePartition::ResetURLLoaderFactories() {}
181 
AddObserver(DataRemovalObserver * observer)182 void TestStoragePartition::AddObserver(DataRemovalObserver* observer) {
183   data_removal_observer_count_++;
184 }
185 
RemoveObserver(DataRemovalObserver * observer)186 void TestStoragePartition::RemoveObserver(DataRemovalObserver* observer) {
187   data_removal_observer_count_--;
188 }
189 
GetDataRemovalObserverCount()190 int TestStoragePartition::GetDataRemovalObserverCount() {
191   return data_removal_observer_count_;
192 }
193 
ClearBluetoothAllowedDevicesMapForTesting()194 void TestStoragePartition::ClearBluetoothAllowedDevicesMapForTesting() {}
195 
FlushNetworkInterfaceForTesting()196 void TestStoragePartition::FlushNetworkInterfaceForTesting() {}
197 
WaitForDeletionTasksForTesting()198 void TestStoragePartition::WaitForDeletionTasksForTesting() {}
199 
WaitForCodeCacheShutdownForTesting()200 void TestStoragePartition::WaitForCodeCacheShutdownForTesting() {}
201 
SetNetworkContextForTesting(mojo::PendingRemote<network::mojom::NetworkContext> network_context_remote)202 void TestStoragePartition::SetNetworkContextForTesting(
203     mojo::PendingRemote<network::mojom::NetworkContext>
204         network_context_remote) {}
205 
206 }  // namespace content
207