[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "content/public/browser/browser_context.h" |
| 6 | |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | #include <stdint.h> |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 9 | |
erg | e69130f5 | 2016-03-02 00:13:28 | [diff] [blame] | 10 | #include <algorithm> |
| 11 | #include <limits> |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 12 | #include <memory> |
Takuto Ikuta | 8332bf9d | 2019-01-05 03:58:00 | [diff] [blame] | 13 | #include <unordered_set> |
dcheng | 36b6aec9 | 2015-12-26 06:16:36 | [diff] [blame] | 14 | #include <utility> |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 15 | #include <vector> |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 16 | |
mmenke | c0b2b8b1 | 2017-04-21 16:27:52 | [diff] [blame] | 17 | #include "base/base64.h" |
Takashi Toyoshima | a12ecf4 | 2018-09-25 07:46:01 | [diff] [blame] | 18 | #include "base/bind.h" |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 19 | #include "base/command_line.h" |
Takashi Toyoshima | a12ecf4 | 2018-09-25 07:46:01 | [diff] [blame] | 20 | #include "base/feature_list.h" |
Chris Cunningham | a5b3801 | 2017-10-28 07:27:18 | [diff] [blame] | 21 | #include "base/files/file_path.h" |
ben | cccfe2a | 2016-03-05 16:54:14 | [diff] [blame] | 22 | #include "base/guid.h" |
erg | e69130f5 | 2016-03-02 00:13:28 | [diff] [blame] | 23 | #include "base/lazy_instance.h" |
mmenke | c0b2b8b1 | 2017-04-21 16:27:52 | [diff] [blame] | 24 | #include "base/logging.h" |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 25 | #include "base/macros.h" |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 26 | #include "base/memory/ptr_util.h" |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 27 | #include "base/memory/weak_ptr.h" |
Chris Cunningham | 4507edfa | 2019-05-30 20:15:54 | [diff] [blame] | 28 | #include "base/metrics/field_trial_params.h" |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 29 | #include "base/no_destructor.h" |
erg | e69130f5 | 2016-03-02 00:13:28 | [diff] [blame] | 30 | #include "base/rand_util.h" |
Takashi Toyoshima | 621e2bf | 2018-09-18 08:05:16 | [diff] [blame] | 31 | #include "base/supports_user_data.h" |
Gabriel Charette | 44db142 | 2018-08-06 11:19:33 | [diff] [blame] | 32 | #include "base/task/post_task.h" |
Ken Rockot | 84f58fd | 2018-06-22 21:54:14 | [diff] [blame] | 33 | #include "base/threading/sequenced_task_runner_handle.h" |
ben | 21a34c25 | 2016-06-29 22:24:37 | [diff] [blame] | 34 | #include "base/threading/thread_task_runner_handle.h" |
Andrey Lushnikov | d39d906 | 2018-04-24 17:33:35 | [diff] [blame] | 35 | #include "base/unguessable_token.h" |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 36 | #include "build/build_config.h" |
dmurph | 7ac019a | 2016-05-13 00:13:17 | [diff] [blame] | 37 | #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
msramek | e169ccb | 2017-04-26 05:21:41 | [diff] [blame] | 38 | #include "content/browser/browsing_data/browsing_data_remover_impl.h" |
Alex Moshchuk | 99b79542 | 2019-03-07 00:27:32 | [diff] [blame] | 39 | #include "content/browser/child_process_security_policy_impl.h" |
Ken Rockot | 84f58fd | 2018-06-22 21:54:14 | [diff] [blame] | 40 | #include "content/browser/content_service_delegate_impl.h" |
[email protected] | b441a849 | 2012-06-06 14:55:57 | [diff] [blame] | 41 | #include "content/browser/download/download_manager_impl.h" |
[email protected] | 3dcea37a | 2019-02-11 19:46:51 | [diff] [blame] | 42 | #include "content/browser/media/browser_feature_provider.h" |
Andrey Lushnikov | ebff044 | 2018-07-12 20:02:58 | [diff] [blame] | 43 | #include "content/browser/permissions/permission_controller_impl.h" |
mvanouwerkerk | 17205ea | 2014-11-07 17:30:15 | [diff] [blame] | 44 | #include "content/browser/push_messaging/push_messaging_router.h" |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 45 | #include "content/browser/storage_partition_impl_map.h" |
[email protected] | d7c7c98a | 2012-07-12 21:27:44 | [diff] [blame] | 46 | #include "content/common/child_process_host_impl.h" |
[email protected] | 393b6cb | 2014-05-15 00:55:12 | [diff] [blame] | 47 | #include "content/public/browser/blob_handle.h" |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 48 | #include "content/public/browser/browser_task_traits.h" |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 49 | #include "content/public/browser/browser_thread.h" |
[email protected] | b441a849 | 2012-06-06 14:55:57 | [diff] [blame] | 50 | #include "content/public/browser/content_browser_client.h" |
Daniel Murphy | d9a41e7b | 2019-05-09 17:56:54 | [diff] [blame] | 51 | #include "content/public/browser/indexed_db_context.h" |
falken | 04a6912a | 2016-09-23 21:06:29 | [diff] [blame] | 52 | #include "content/public/browser/render_process_host.h" |
Takashi Toyoshima | 0190a3b | 2019-01-21 07:39:06 | [diff] [blame] | 53 | #include "content/public/browser/shared_cors_origin_access_list.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 54 | #include "content/public/browser/site_instance.h" |
Ken Rockot | fd03e68 | 2019-06-20 21:13:54 | [diff] [blame] | 55 | #include "content/public/browser/system_connector.h" |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 56 | #include "content/public/common/content_switches.h" |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 57 | #include "content/public/common/service_manager_connection.h" |
ben | 51bb6c6 | 2016-11-17 20:15:57 | [diff] [blame] | 58 | #include "content/public/common/service_names.mojom.h" |
Chris Cunningham | 4507edfa | 2019-05-30 20:15:54 | [diff] [blame] | 59 | #include "media/base/media_switches.h" |
| 60 | #include "media/capabilities/in_memory_video_decode_stats_db_impl.h" |
Chris Cunningham | 9e66947 | 2017-11-15 21:03:11 | [diff] [blame] | 61 | #include "media/capabilities/video_decode_stats_db_impl.h" |
[email protected] | 3af28f1 | 2019-09-19 16:32:14 | [diff] [blame] | 62 | #include "media/learning/common/media_learning_tasks.h" |
Thomas Guilbert | a424bb2 | 2019-08-20 21:33:41 | [diff] [blame] | 63 | #include "media/learning/impl/learning_session_impl.h" |
Chris Cunningham | a5b3801 | 2017-10-28 07:27:18 | [diff] [blame] | 64 | #include "media/mojo/services/video_decode_perf_history.h" |
Ken Rockot | 40a1df79 | 2019-05-08 22:15:52 | [diff] [blame] | 65 | #include "mojo/public/cpp/bindings/remote.h" |
[email protected] | 4d7c4ef | 2012-03-16 01:47:12 | [diff] [blame] | 66 | #include "net/cookies/cookie_store.h" |
[email protected] | 6e2d3d2 | 2012-02-24 18:10:36 | [diff] [blame] | 67 | #include "net/url_request/url_request_context.h" |
Ken Rockot | 84f58fd | 2018-06-22 21:54:14 | [diff] [blame] | 68 | #include "services/content/public/mojom/constants.mojom.h" |
| 69 | #include "services/content/service.h" |
Takashi Toyoshima | a12ecf4 | 2018-09-25 07:46:01 | [diff] [blame] | 70 | #include "services/network/public/cpp/features.h" |
rockot | 734fb66 | 2016-10-15 16:41:30 | [diff] [blame] | 71 | #include "services/service_manager/public/cpp/connector.h" |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 72 | #include "services/service_manager/public/cpp/service.h" |
Ken Rockot | 543f5e3 | 2018-02-04 02:13:50 | [diff] [blame] | 73 | #include "services/service_manager/public/mojom/service.mojom.h" |
Xing Liu | 8986047 | 2018-02-09 20:07:02 | [diff] [blame] | 74 | #include "storage/browser/blob/blob_storage_context.h" |
pilgrim | e92c5fcd | 2014-09-10 23:31:23 | [diff] [blame] | 75 | #include "storage/browser/database/database_tracker.h" |
| 76 | #include "storage/browser/fileapi/external_mount_points.h" |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 77 | |
[email protected] | 314c3e2 | 2012-02-21 03:57:42 | [diff] [blame] | 78 | using base::UserDataAdapter; |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 79 | |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 80 | namespace content { |
| 81 | |
[email protected] | 735e20c | 2012-03-20 01:16:59 | [diff] [blame] | 82 | namespace { |
| 83 | |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 84 | using TokenToContextMap = std::map<base::Token, BrowserContext*>; |
| 85 | TokenToContextMap& GetTokenToContextMap() { |
| 86 | static base::NoDestructor<TokenToContextMap> map; |
| 87 | return *map; |
| 88 | } |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 89 | |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 90 | class ServiceInstanceGroupHolder : public base::SupportsUserData::Data { |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 91 | public: |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 92 | explicit ServiceInstanceGroupHolder(const base::Token& instance_group) |
| 93 | : instance_group_(instance_group) {} |
| 94 | ~ServiceInstanceGroupHolder() override {} |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 95 | |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 96 | const base::Token& instance_group() const { return instance_group_; } |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 97 | |
| 98 | private: |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 99 | base::Token instance_group_; |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 100 | |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 101 | DISALLOW_COPY_AND_ASSIGN(ServiceInstanceGroupHolder); |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 102 | }; |
erg | e69130f5 | 2016-03-02 00:13:28 | [diff] [blame] | 103 | |
Ken Rockot | 84f58fd | 2018-06-22 21:54:14 | [diff] [blame] | 104 | class ContentServiceDelegateHolder : public base::SupportsUserData::Data { |
| 105 | public: |
| 106 | explicit ContentServiceDelegateHolder(BrowserContext* browser_context) |
| 107 | : delegate_(browser_context) {} |
| 108 | ~ContentServiceDelegateHolder() override = default; |
| 109 | |
| 110 | ContentServiceDelegateImpl* delegate() { return &delegate_; } |
| 111 | |
| 112 | private: |
| 113 | ContentServiceDelegateImpl delegate_; |
| 114 | |
| 115 | DISALLOW_COPY_AND_ASSIGN(ContentServiceDelegateHolder); |
| 116 | }; |
| 117 | |
[email protected] | e0ce8a1e | 2012-09-18 10:26:36 | [diff] [blame] | 118 | // Key names on BrowserContext. |
msramek | e169ccb | 2017-04-26 05:21:41 | [diff] [blame] | 119 | const char kBrowsingDataRemoverKey[] = "browsing-data-remover"; |
Ken Rockot | 84f58fd | 2018-06-22 21:54:14 | [diff] [blame] | 120 | const char kContentServiceDelegateKey[] = "content-service-delegate"; |
[email protected] | 6ef0c391 | 2013-01-25 22:46:34 | [diff] [blame] | 121 | const char kDownloadManagerKeyName[] = "download_manager"; |
Takashi Toyoshima | 621e2bf | 2018-09-18 08:05:16 | [diff] [blame] | 122 | const char kPermissionControllerKey[] = "permission-controller"; |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 123 | const char kServiceManagerConnection[] = "service-manager-connection"; |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 124 | const char kServiceInstanceGroup[] = "service-instance-group"; |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 125 | const char kStoragePartitionMapKeyName[] = "content_storage_partition_map"; |
Chris Cunningham | a5b3801 | 2017-10-28 07:27:18 | [diff] [blame] | 126 | const char kVideoDecodePerfHistoryId[] = "video-decode-perf-history"; |
Thomas Guilbert | a424bb2 | 2019-08-20 21:33:41 | [diff] [blame] | 127 | const char kLearningSession[] = "learning-session"; |
erg | e69130f5 | 2016-03-02 00:13:28 | [diff] [blame] | 128 | |
[email protected] | 9afc14e2 | 2013-09-25 22:34:14 | [diff] [blame] | 129 | #if defined(OS_CHROMEOS) |
| 130 | const char kMountPointsKey[] = "mount_points"; |
| 131 | #endif // defined(OS_CHROMEOS) |
| 132 | |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 133 | void RemoveBrowserContextFromInstanceGroupMap(BrowserContext* browser_context) { |
| 134 | ServiceInstanceGroupHolder* holder = static_cast<ServiceInstanceGroupHolder*>( |
| 135 | browser_context->GetUserData(kServiceInstanceGroup)); |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 136 | if (holder) { |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 137 | auto it = GetTokenToContextMap().find(holder->instance_group()); |
| 138 | if (it != GetTokenToContextMap().end()) |
| 139 | GetTokenToContextMap().erase(it); |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 140 | } |
| 141 | } |
| 142 | |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 143 | StoragePartitionImplMap* GetStoragePartitionMap( |
| 144 | BrowserContext* browser_context) { |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 145 | StoragePartitionImplMap* partition_map = |
| 146 | static_cast<StoragePartitionImplMap*>( |
a.cavalcanti | ffab7376 | 2015-08-15 02:55:48 | [diff] [blame] | 147 | browser_context->GetUserData(kStoragePartitionMapKeyName)); |
[email protected] | d7c7c98a | 2012-07-12 21:27:44 | [diff] [blame] | 148 | if (!partition_map) { |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 149 | auto partition_map_owned = |
Jeremy Roman | 04f27c37 | 2017-10-27 15:20:55 | [diff] [blame] | 150 | std::make_unique<StoragePartitionImplMap>(browser_context); |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 151 | partition_map = partition_map_owned.get(); |
| 152 | browser_context->SetUserData(kStoragePartitionMapKeyName, |
| 153 | std::move(partition_map_owned)); |
[email protected] | d7c7c98a | 2012-07-12 21:27:44 | [diff] [blame] | 154 | } |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 155 | return partition_map; |
| 156 | } |
| 157 | |
| 158 | StoragePartition* GetStoragePartitionFromConfig( |
| 159 | BrowserContext* browser_context, |
| 160 | const std::string& partition_domain, |
| 161 | const std::string& partition_name, |
Dan Elphick | 6c0d849 | 2017-09-12 09:35:38 | [diff] [blame] | 162 | bool in_memory, |
| 163 | bool can_create) { |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 164 | StoragePartitionImplMap* partition_map = |
| 165 | GetStoragePartitionMap(browser_context); |
[email protected] | d7c7c98a | 2012-07-12 21:27:44 | [diff] [blame] | 166 | |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 167 | if (browser_context->IsOffTheRecord()) |
| 168 | in_memory = true; |
| 169 | |
Dan Elphick | 6c0d849 | 2017-09-12 09:35:38 | [diff] [blame] | 170 | return partition_map->Get(partition_domain, partition_name, in_memory, |
| 171 | can_create); |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 172 | } |
| 173 | |
Kinuko Yasuda | 48c47586 | 2019-07-29 15:08:26 | [diff] [blame] | 174 | void SaveSessionStateOnIOThread(AppCacheServiceImpl* appcache_service) { |
[email protected] | 6939075a | 2012-08-28 08:35:53 | [diff] [blame] | 175 | appcache_service->set_force_keep_session_state(); |
[email protected] | 6e2d3d2 | 2012-02-24 18:10:36 | [diff] [blame] | 176 | } |
| 177 | |
[email protected] | 89acda8 | 2013-06-25 20:52:50 | [diff] [blame] | 178 | void SaveSessionStateOnIndexedDBThread( |
Daniel Murphy | d9a41e7b | 2019-05-09 17:56:54 | [diff] [blame] | 179 | scoped_refptr<IndexedDBContext> indexed_db_context) { |
[email protected] | bf510ed | 2012-06-05 08:31:43 | [diff] [blame] | 180 | indexed_db_context->SetForceKeepSessionState(); |
[email protected] | 6e2d3d2 | 2012-02-24 18:10:36 | [diff] [blame] | 181 | } |
| 182 | |
falken | 41f417516 | 2014-10-29 07:03:41 | [diff] [blame] | 183 | void ShutdownServiceWorkerContext(StoragePartition* partition) { |
| 184 | ServiceWorkerContextWrapper* wrapper = |
| 185 | static_cast<ServiceWorkerContextWrapper*>( |
| 186 | partition->GetServiceWorkerContext()); |
| 187 | wrapper->process_manager()->Shutdown(); |
| 188 | } |
| 189 | |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 190 | void SetDownloadManager( |
| 191 | BrowserContext* context, |
| 192 | std::unique_ptr<content::DownloadManager> download_manager) { |
ttr314 | 81dc54b | 2015-08-06 20:11:26 | [diff] [blame] | 193 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 194 | DCHECK(download_manager); |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 195 | context->SetUserData(kDownloadManagerKeyName, std::move(download_manager)); |
ttr314 | 81dc54b | 2015-08-06 20:11:26 | [diff] [blame] | 196 | } |
| 197 | |
Ken Rockot | 499519e | 2018-12-04 06:57:44 | [diff] [blame] | 198 | std::unique_ptr<service_manager::Service> |
| 199 | CreateMainThreadServiceForBrowserContext( |
| 200 | BrowserContext* browser_context, |
| 201 | const std::string& service_name, |
| 202 | service_manager::mojom::ServiceRequest request) { |
| 203 | if (service_name == content::mojom::kServiceName) { |
| 204 | auto* delegate_holder = static_cast<ContentServiceDelegateHolder*>( |
| 205 | browser_context->GetUserData(kContentServiceDelegateKey)); |
| 206 | auto* delegate = delegate_holder->delegate(); |
| 207 | auto service = |
| 208 | std::make_unique<content::Service>(delegate, std::move(request)); |
| 209 | delegate->AddService(service.get()); |
| 210 | return service; |
| 211 | } |
| 212 | |
| 213 | return browser_context->HandleServiceRequest(service_name, |
| 214 | std::move(request)); |
| 215 | } |
| 216 | |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 217 | class BrowserContextServiceManagerConnectionHolder |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 218 | : public base::SupportsUserData::Data { |
| 219 | public: |
ben | aad37ecd | 2017-04-12 22:08:20 | [diff] [blame] | 220 | explicit BrowserContextServiceManagerConnectionHolder( |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 221 | BrowserContext* browser_context, |
Ken Rockot | 499519e | 2018-12-04 06:57:44 | [diff] [blame] | 222 | service_manager::mojom::ServiceRequest request, |
| 223 | scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner) |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 224 | : browser_context_(browser_context), |
Ken Rockot | 499519e | 2018-12-04 06:57:44 | [diff] [blame] | 225 | main_thread_task_runner_(std::move(main_thread_task_runner)), |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 226 | service_manager_connection_(ServiceManagerConnection::Create( |
rockot | cef3827 | 2016-07-15 22:47:47 | [diff] [blame] | 227 | std::move(request), |
Sami Kyostila | 8e4d5a9 | 2019-08-02 12:45:05 | [diff] [blame] | 228 | base::CreateSingleThreadTaskRunner({BrowserThread::IO}))) { |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 229 | service_manager_connection_->SetDefaultServiceRequestHandler( |
| 230 | base::BindRepeating( |
| 231 | &BrowserContextServiceManagerConnectionHolder::OnServiceRequest, |
| 232 | weak_ptr_factory_.GetWeakPtr())); |
| 233 | } |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 234 | ~BrowserContextServiceManagerConnectionHolder() override {} |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 235 | |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 236 | ServiceManagerConnection* service_manager_connection() { |
| 237 | return service_manager_connection_.get(); |
| 238 | } |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 239 | |
Ken Rockot | ad3c758 | 2018-12-12 17:04:14 | [diff] [blame] | 240 | void DestroyRunningServices() { running_services_.clear(); } |
| 241 | |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 242 | private: |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 243 | void OnServiceRequest(const std::string& service_name, |
| 244 | service_manager::mojom::ServiceRequest request) { |
| 245 | std::unique_ptr<service_manager::Service> service = |
Ken Rockot | 499519e | 2018-12-04 06:57:44 | [diff] [blame] | 246 | CreateMainThreadServiceForBrowserContext(browser_context_, service_name, |
| 247 | std::move(request)); |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 248 | if (!service) { |
| 249 | LOG(ERROR) << "Ignoring request for unknown per-browser-context service:" |
| 250 | << service_name; |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | auto* raw_service = service.get(); |
| 255 | service->set_termination_closure(base::BindOnce( |
| 256 | &BrowserContextServiceManagerConnectionHolder::OnServiceQuit, |
| 257 | base::Unretained(this), raw_service)); |
| 258 | running_services_.emplace(raw_service, std::move(service)); |
| 259 | } |
| 260 | |
| 261 | void OnServiceQuit(service_manager::Service* service) { |
| 262 | running_services_.erase(service); |
| 263 | } |
| 264 | |
| 265 | BrowserContext* const browser_context_; |
Ken Rockot | 499519e | 2018-12-04 06:57:44 | [diff] [blame] | 266 | const scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner_; |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 267 | std::unique_ptr<ServiceManagerConnection> service_manager_connection_; |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 268 | std::map<service_manager::Service*, std::unique_ptr<service_manager::Service>> |
| 269 | running_services_; |
| 270 | |
| 271 | base::WeakPtrFactory<BrowserContextServiceManagerConnectionHolder> |
| 272 | weak_ptr_factory_{this}; |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 273 | |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 274 | DISALLOW_COPY_AND_ASSIGN(BrowserContextServiceManagerConnectionHolder); |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 275 | }; |
| 276 | |
Jens Widell | 7ca8fb4 | 2018-02-21 14:11:54 | [diff] [blame] | 277 | base::WeakPtr<storage::BlobStorageContext> BlobStorageContextGetterForBrowser( |
Xing Liu | 8986047 | 2018-02-09 20:07:02 | [diff] [blame] | 278 | scoped_refptr<ChromeBlobStorageContext> blob_context) { |
| 279 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 280 | return blob_context->context()->AsWeakPtr(); |
| 281 | } |
| 282 | |
[email protected] | 735e20c | 2012-03-20 01:16:59 | [diff] [blame] | 283 | } // namespace |
| 284 | |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 285 | // static |
| 286 | void BrowserContext::AsyncObliterateStoragePartition( |
| 287 | BrowserContext* browser_context, |
[email protected] | 399583b | 2012-12-11 09:33:42 | [diff] [blame] | 288 | const GURL& site, |
| 289 | const base::Closure& on_gc_required) { |
Marijn Kruisselbrink | 83e5cdb | 2019-06-20 00:06:28 | [diff] [blame] | 290 | GetStoragePartitionMap(browser_context) |
| 291 | ->AsyncObliterate(site, on_gc_required); |
[email protected] | 399583b | 2012-12-11 09:33:42 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | // static |
| 295 | void BrowserContext::GarbageCollectStoragePartitions( |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 296 | BrowserContext* browser_context, |
Takuto Ikuta | 8332bf9d | 2019-01-05 03:58:00 | [diff] [blame] | 297 | std::unique_ptr<std::unordered_set<base::FilePath>> active_paths, |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 298 | const base::Closure& done) { |
dcheng | 36b6aec9 | 2015-12-26 06:16:36 | [diff] [blame] | 299 | GetStoragePartitionMap(browser_context) |
| 300 | ->GarbageCollect(std::move(active_paths), done); |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 301 | } |
| 302 | |
Marijn Kruisselbrink | 83e5cdb | 2019-06-20 00:06:28 | [diff] [blame] | 303 | DownloadManager* BrowserContext::GetDownloadManager(BrowserContext* context) { |
mostynb | fbcdc27a | 2015-03-13 17:58:52 | [diff] [blame] | 304 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | b441a849 | 2012-06-06 14:55:57 | [diff] [blame] | 305 | if (!context->GetUserData(kDownloadManagerKeyName)) { |
Min Qin | ddb40ce | 2017-10-28 03:38:26 | [diff] [blame] | 306 | DownloadManager* download_manager = new DownloadManagerImpl(context); |
[email protected] | d25fda1 | 2012-06-12 17:05:03 | [diff] [blame] | 307 | |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 308 | SetDownloadManager(context, base::WrapUnique(download_manager)); |
[email protected] | b441a849 | 2012-06-06 14:55:57 | [diff] [blame] | 309 | download_manager->SetDelegate(context->GetDownloadManagerDelegate()); |
[email protected] | b441a849 | 2012-06-06 14:55:57 | [diff] [blame] | 310 | } |
| 311 | |
[email protected] | eba4a4d | 2013-05-29 02:18:06 | [diff] [blame] | 312 | return static_cast<DownloadManager*>( |
| 313 | context->GetUserData(kDownloadManagerKeyName)); |
[email protected] | b441a849 | 2012-06-06 14:55:57 | [diff] [blame] | 314 | } |
| 315 | |
[email protected] | 6ef0c391 | 2013-01-25 22:46:34 | [diff] [blame] | 316 | // static |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 317 | storage::ExternalMountPoints* BrowserContext::GetMountPoints( |
[email protected] | 6ef0c391 | 2013-01-25 22:46:34 | [diff] [blame] | 318 | BrowserContext* context) { |
| 319 | // Ensure that these methods are called on the UI thread, except for |
| 320 | // unittests where a UI thread might not have been created. |
| 321 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
Gabriel Charette | 2983181c | 2018-03-28 17:01:09 | [diff] [blame] | 322 | !BrowserThread::IsThreadInitialized(BrowserThread::UI)); |
[email protected] | 6ef0c391 | 2013-01-25 22:46:34 | [diff] [blame] | 323 | |
| 324 | #if defined(OS_CHROMEOS) |
| 325 | if (!context->GetUserData(kMountPointsKey)) { |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 326 | scoped_refptr<storage::ExternalMountPoints> mount_points = |
| 327 | storage::ExternalMountPoints::CreateRefCounted(); |
[email protected] | 6ef0c391 | 2013-01-25 22:46:34 | [diff] [blame] | 328 | context->SetUserData( |
| 329 | kMountPointsKey, |
Jeremy Roman | 04f27c37 | 2017-10-27 15:20:55 | [diff] [blame] | 330 | std::make_unique<UserDataAdapter<storage::ExternalMountPoints>>( |
avi | cb129c0 | 2017-05-03 06:49:29 | [diff] [blame] | 331 | mount_points.get())); |
[email protected] | 6ef0c391 | 2013-01-25 22:46:34 | [diff] [blame] | 332 | } |
| 333 | |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 334 | return UserDataAdapter<storage::ExternalMountPoints>::Get(context, |
| 335 | kMountPointsKey); |
[email protected] | 6ef0c391 | 2013-01-25 22:46:34 | [diff] [blame] | 336 | #else |
Ivan Kotenkov | 2c0d2bb3 | 2017-11-01 15:41:28 | [diff] [blame] | 337 | return nullptr; |
[email protected] | 6ef0c391 | 2013-01-25 22:46:34 | [diff] [blame] | 338 | #endif |
| 339 | } |
| 340 | |
msramek | e169ccb | 2017-04-26 05:21:41 | [diff] [blame] | 341 | // static |
| 342 | content::BrowsingDataRemover* content::BrowserContext::GetBrowsingDataRemover( |
| 343 | BrowserContext* context) { |
| 344 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 345 | |
| 346 | if (!context->GetUserData(kBrowsingDataRemoverKey)) { |
| 347 | std::unique_ptr<BrowsingDataRemoverImpl> remover = |
Jeremy Roman | 04f27c37 | 2017-10-27 15:20:55 | [diff] [blame] | 348 | std::make_unique<BrowsingDataRemoverImpl>(context); |
msramek | e169ccb | 2017-04-26 05:21:41 | [diff] [blame] | 349 | remover->SetEmbedderDelegate(context->GetBrowsingDataRemoverDelegate()); |
| 350 | context->SetUserData(kBrowsingDataRemoverKey, std::move(remover)); |
| 351 | } |
| 352 | |
| 353 | return static_cast<BrowsingDataRemoverImpl*>( |
| 354 | context->GetUserData(kBrowsingDataRemoverKey)); |
| 355 | } |
| 356 | |
Andrey Lushnikov | ebff044 | 2018-07-12 20:02:58 | [diff] [blame] | 357 | // static |
| 358 | content::PermissionController* content::BrowserContext::GetPermissionController( |
| 359 | BrowserContext* context) { |
| 360 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 361 | |
| 362 | if (!context->GetUserData(kPermissionControllerKey)) { |
| 363 | context->SetUserData(kPermissionControllerKey, |
| 364 | std::make_unique<PermissionControllerImpl>(context)); |
| 365 | } |
| 366 | |
| 367 | return static_cast<PermissionControllerImpl*>( |
| 368 | context->GetUserData(kPermissionControllerKey)); |
| 369 | } |
| 370 | |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 371 | StoragePartition* BrowserContext::GetStoragePartition( |
| 372 | BrowserContext* browser_context, |
Dan Elphick | 6c0d849 | 2017-09-12 09:35:38 | [diff] [blame] | 373 | SiteInstance* site_instance, |
| 374 | bool can_create) { |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 375 | std::string partition_domain; |
| 376 | std::string partition_name; |
| 377 | bool in_memory = false; |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 378 | |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 379 | if (site_instance) { |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 380 | GetContentClient()->browser()->GetStoragePartitionConfigForSite( |
Marijn Kruisselbrink | 83e5cdb | 2019-06-20 00:06:28 | [diff] [blame] | 381 | browser_context, site_instance->GetSiteURL(), true, &partition_domain, |
| 382 | &partition_name, &in_memory); |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 383 | } |
| 384 | |
Dan Elphick | 6c0d849 | 2017-09-12 09:35:38 | [diff] [blame] | 385 | return GetStoragePartitionFromConfig(browser_context, partition_domain, |
| 386 | partition_name, in_memory, can_create); |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 387 | } |
| 388 | |
[email protected] | e94bbcb | 2012-09-07 05:33:57 | [diff] [blame] | 389 | StoragePartition* BrowserContext::GetStoragePartitionForSite( |
| 390 | BrowserContext* browser_context, |
Dan Elphick | 6c0d849 | 2017-09-12 09:35:38 | [diff] [blame] | 391 | const GURL& site, |
| 392 | bool can_create) { |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 393 | std::string partition_domain; |
| 394 | std::string partition_name; |
| 395 | bool in_memory; |
[email protected] | e94bbcb | 2012-09-07 05:33:57 | [diff] [blame] | 396 | |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 397 | GetContentClient()->browser()->GetStoragePartitionConfigForSite( |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 398 | browser_context, site, true, &partition_domain, &partition_name, |
| 399 | &in_memory); |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 400 | |
Dan Elphick | 6c0d849 | 2017-09-12 09:35:38 | [diff] [blame] | 401 | return GetStoragePartitionFromConfig(browser_context, partition_domain, |
| 402 | partition_name, in_memory, can_create); |
[email protected] | e94bbcb | 2012-09-07 05:33:57 | [diff] [blame] | 403 | } |
| 404 | |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 405 | void BrowserContext::ForEachStoragePartition( |
| 406 | BrowserContext* browser_context, |
| 407 | const StoragePartitionCallback& callback) { |
| 408 | StoragePartitionImplMap* partition_map = |
| 409 | static_cast<StoragePartitionImplMap*>( |
a.cavalcanti | ffab7376 | 2015-08-15 02:55:48 | [diff] [blame] | 410 | browser_context->GetUserData(kStoragePartitionMapKeyName)); |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 411 | if (!partition_map) |
| 412 | return; |
| 413 | |
| 414 | partition_map->ForEach(callback); |
| 415 | } |
| 416 | |
| 417 | StoragePartition* BrowserContext::GetDefaultStoragePartition( |
| 418 | BrowserContext* browser_context) { |
Ivan Kotenkov | 2c0d2bb3 | 2017-11-01 15:41:28 | [diff] [blame] | 419 | return GetStoragePartition(browser_context, nullptr); |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 420 | } |
| 421 | |
tbarzic | db71268 | 2015-03-06 06:05:41 | [diff] [blame] | 422 | // static |
[email protected] | 393b6cb | 2014-05-15 00:55:12 | [diff] [blame] | 423 | void BrowserContext::CreateMemoryBackedBlob(BrowserContext* browser_context, |
Marijn Kruisselbrink | 604fd7e7 | 2017-10-26 16:31:05 | [diff] [blame] | 424 | const char* data, |
| 425 | size_t length, |
| 426 | const std::string& content_type, |
| 427 | BlobCallback callback) { |
mostynb | fbcdc27a | 2015-03-13 17:58:52 | [diff] [blame] | 428 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 393b6cb | 2014-05-15 00:55:12 | [diff] [blame] | 429 | |
| 430 | ChromeBlobStorageContext* blob_context = |
| 431 | ChromeBlobStorageContext::GetFor(browser_context); |
Sami Kyostila | 8e4d5a9 | 2019-08-02 12:45:05 | [diff] [blame] | 432 | base::PostTaskAndReplyWithResult( |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 433 | FROM_HERE, {BrowserThread::IO}, |
Marijn Kruisselbrink | 604fd7e7 | 2017-10-26 16:31:05 | [diff] [blame] | 434 | base::BindOnce(&ChromeBlobStorageContext::CreateMemoryBackedBlob, |
| 435 | base::WrapRefCounted(blob_context), data, length, |
| 436 | content_type), |
| 437 | std::move(callback)); |
[email protected] | 393b6cb | 2014-05-15 00:55:12 | [diff] [blame] | 438 | } |
| 439 | |
[email protected] | 66e53d028 | 2014-08-07 10:04:35 | [diff] [blame] | 440 | // static |
Xing Liu | 8986047 | 2018-02-09 20:07:02 | [diff] [blame] | 441 | BrowserContext::BlobContextGetter BrowserContext::GetBlobStorageContext( |
| 442 | BrowserContext* browser_context) { |
| 443 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 444 | scoped_refptr<ChromeBlobStorageContext> chrome_blob_context = |
| 445 | ChromeBlobStorageContext::GetFor(browser_context); |
Jens Widell | 7ca8fb4 | 2018-02-21 14:11:54 | [diff] [blame] | 446 | return base::BindRepeating(&BlobStorageContextGetterForBrowser, |
| 447 | chrome_blob_context); |
Xing Liu | 8986047 | 2018-02-09 20:07:02 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | // static |
Julie Jeongeun Kim | bc4a76d | 2019-09-11 02:28:23 | [diff] [blame] | 451 | mojo::PendingRemote<blink::mojom::Blob> BrowserContext::GetBlobRemote( |
Marijn Kruisselbrink | 9e073a8 | 2018-06-18 17:48:58 | [diff] [blame] | 452 | BrowserContext* browser_context, |
| 453 | const std::string& uuid) { |
| 454 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Julie Jeongeun Kim | bc4a76d | 2019-09-11 02:28:23 | [diff] [blame] | 455 | return ChromeBlobStorageContext::GetBlobRemote(browser_context, uuid); |
Marijn Kruisselbrink | 9e073a8 | 2018-06-18 17:48:58 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | // static |
[email protected] | 66e53d028 | 2014-08-07 10:04:35 | [diff] [blame] | 459 | void BrowserContext::DeliverPushMessage( |
| 460 | BrowserContext* browser_context, |
| 461 | const GURL& origin, |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 462 | int64_t service_worker_registration_id, |
Rayan Kanso | 3b68620 | 2019-05-10 17:41:55 | [diff] [blame] | 463 | const std::string& message_id, |
Han Leon | c1deace | 2018-08-03 03:52:53 | [diff] [blame] | 464 | base::Optional<std::string> payload, |
Mario Sanchez Prada | d299011 | 2019-05-07 08:13:49 | [diff] [blame] | 465 | const base::Callback<void(blink::mojom::PushDeliveryStatus)>& callback) { |
mostynb | fbcdc27a | 2015-03-13 17:58:52 | [diff] [blame] | 466 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
harkness | dd4d2b2 | 2016-01-27 19:26:43 | [diff] [blame] | 467 | PushMessagingRouter::DeliverMessage(browser_context, origin, |
Han Leon | c1deace | 2018-08-03 03:52:53 | [diff] [blame] | 468 | service_worker_registration_id, |
Rayan Kanso | 3b68620 | 2019-05-10 17:41:55 | [diff] [blame] | 469 | message_id, std::move(payload), callback); |
[email protected] | 66e53d028 | 2014-08-07 10:04:35 | [diff] [blame] | 470 | } |
| 471 | |
falken | 41f417516 | 2014-10-29 07:03:41 | [diff] [blame] | 472 | // static |
| 473 | void BrowserContext::NotifyWillBeDestroyed(BrowserContext* browser_context) { |
Lukasz Anforowicz | 58d0dac | 2018-03-23 15:48:10 | [diff] [blame] | 474 | // Make sure NotifyWillBeDestroyed is idempotent. This helps facilitate the |
| 475 | // pattern where NotifyWillBeDestroyed is called from *both* |
Kent Tamura | 21d1de6 | 2018-12-10 04:45:20 | [diff] [blame] | 476 | // ShellBrowserContext and its derived classes (e.g. WebTestBrowserContext). |
Lukasz Anforowicz | 58d0dac | 2018-03-23 15:48:10 | [diff] [blame] | 477 | if (browser_context->was_notify_will_be_destroyed_called_) |
| 478 | return; |
| 479 | browser_context->was_notify_will_be_destroyed_called_ = true; |
| 480 | |
Ken Rockot | d101189 | 2019-07-25 22:17:07 | [diff] [blame] | 481 | // Stop the ServiceManagerConnection from handling any new incoming requests |
| 482 | // before we tear anything down. This prevents races at shutdown. |
| 483 | BrowserContextServiceManagerConnectionHolder* connection_holder = |
| 484 | static_cast<BrowserContextServiceManagerConnectionHolder*>( |
| 485 | browser_context->GetUserData(kServiceManagerConnection)); |
| 486 | if (connection_holder) |
| 487 | connection_holder->service_manager_connection()->Stop(); |
| 488 | |
Ken Rockot | 99c5bc74 | 2018-07-12 15:36:56 | [diff] [blame] | 489 | // Subclasses of BrowserContext may expect there to be no more |
| 490 | // RenderProcessHosts using them by the time this function returns. We |
| 491 | // therefore explicitly tear down embedded Content Service instances now to |
| 492 | // ensure that all their WebContents (and therefore RPHs) are torn down too. |
| 493 | browser_context->RemoveUserData(kContentServiceDelegateKey); |
| 494 | |
Ken Rockot | ad3c758 | 2018-12-12 17:04:14 | [diff] [blame] | 495 | // Tear down all running service instances which were started on behalf of |
| 496 | // this BrowserContext. Note that we leave the UserData itself in place |
| 497 | // because it's possible for someone to call |
| 498 | // |GetServiceManagerConnectionFor()| between now and actual BrowserContext |
| 499 | // destruction. |
Ken Rockot | ad3c758 | 2018-12-12 17:04:14 | [diff] [blame] | 500 | if (connection_holder) |
| 501 | connection_holder->DestroyRunningServices(); |
| 502 | |
falken | 41f417516 | 2014-10-29 07:03:41 | [diff] [blame] | 503 | // Service Workers must shutdown before the browser context is destroyed, |
| 504 | // since they keep render process hosts alive and the codebase assumes that |
| 505 | // render process hosts die before their profile (browser context) dies. |
| 506 | ForEachStoragePartition(browser_context, |
| 507 | base::Bind(ShutdownServiceWorkerContext)); |
falken | 04a6912a | 2016-09-23 21:06:29 | [diff] [blame] | 508 | |
| 509 | // Shared workers also keep render process hosts alive, and are expected to |
Darin Fisher | d3768b2f6 | 2017-10-07 01:00:16 | [diff] [blame] | 510 | // return ref counts to 0 after documents close. However, to ensure that |
| 511 | // hosts are destructed now, forcibly release their ref counts here. |
falken | 04a6912a | 2016-09-23 21:06:29 | [diff] [blame] | 512 | for (RenderProcessHost::iterator host_iterator = |
| 513 | RenderProcessHost::AllHostsIterator(); |
| 514 | !host_iterator.IsAtEnd(); host_iterator.Advance()) { |
| 515 | RenderProcessHost* host = host_iterator.GetCurrentValue(); |
Benoit Lize | ab08362c | 2017-07-19 14:50:54 | [diff] [blame] | 516 | if (host->GetBrowserContext() == browser_context) { |
| 517 | // This will also clean up spare RPH references. |
Yutaka Hirano | 09a9afb9 | 2017-08-16 09:11:45 | [diff] [blame] | 518 | host->DisableKeepAliveRefCount(); |
Benoit Lize | ab08362c | 2017-07-19 14:50:54 | [diff] [blame] | 519 | } |
falken | 04a6912a | 2016-09-23 21:06:29 | [diff] [blame] | 520 | } |
Alex Moshchuk | 99b79542 | 2019-03-07 00:27:32 | [diff] [blame] | 521 | |
Aaron Colwell | 67f93006c | 2019-04-01 22:45:28 | [diff] [blame] | 522 | // Clean up any isolated origins associated with this BrowserContext. This |
Alex Moshchuk | 99b79542 | 2019-03-07 00:27:32 | [diff] [blame] | 523 | // should be safe now that all RenderProcessHosts are destroyed, since future |
| 524 | // navigations or security decisions shouldn't ever need to consult these |
Aaron Colwell | 67f93006c | 2019-04-01 22:45:28 | [diff] [blame] | 525 | // isolated origins. |
Alex Moshchuk | 99b79542 | 2019-03-07 00:27:32 | [diff] [blame] | 526 | ChildProcessSecurityPolicyImpl* policy = |
| 527 | ChildProcessSecurityPolicyImpl::GetInstance(); |
Aaron Colwell | 67f93006c | 2019-04-01 22:45:28 | [diff] [blame] | 528 | policy->RemoveIsolatedOriginsForBrowserContext(*browser_context); |
falken | 41f417516 | 2014-10-29 07:03:41 | [diff] [blame] | 529 | } |
| 530 | |
[email protected] | 314c3e2 | 2012-02-21 03:57:42 | [diff] [blame] | 531 | void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) { |
[email protected] | 7e26ac9 | 2012-02-27 20:15:05 | [diff] [blame] | 532 | // This will be enough to tickle initialization of BrowserContext if |
| 533 | // necessary, which initializes ResourceContext. The reason we don't call |
[email protected] | 4c3a2358 | 2012-08-18 08:54:34 | [diff] [blame] | 534 | // ResourceContext::InitializeResourceContext() directly here is that |
| 535 | // ResourceContext initialization may call back into BrowserContext |
| 536 | // and when that call returns it'll end rewriting its UserData map. It will |
| 537 | // end up rewriting the same value but this still causes a race condition. |
| 538 | // |
| 539 | // See http://crbug.com/115678. |
| 540 | GetDefaultStoragePartition(context); |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 541 | } |
| 542 | |
[email protected] | 6e2d3d2 | 2012-02-24 18:10:36 | [diff] [blame] | 543 | void BrowserContext::SaveSessionState(BrowserContext* browser_context) { |
[email protected] | b1b502e | 2012-09-16 07:31:43 | [diff] [blame] | 544 | StoragePartition* storage_partition = |
| 545 | BrowserContext::GetDefaultStoragePartition(browser_context); |
[email protected] | 6e2d3d2 | 2012-02-24 18:10:36 | [diff] [blame] | 546 | |
Joshua Bell | 607cb14 | 2017-07-24 19:17:16 | [diff] [blame] | 547 | storage::DatabaseTracker* database_tracker = |
| 548 | storage_partition->GetDatabaseTracker(); |
| 549 | database_tracker->task_runner()->PostTask( |
| 550 | FROM_HERE, |
| 551 | base::BindOnce(&storage::DatabaseTracker::SetForceKeepSessionState, |
kylechar | da69d88 | 2017-10-04 05:49:52 | [diff] [blame] | 552 | base::WrapRefCounted(database_tracker))); |
Joshua Bell | 607cb14 | 2017-07-24 19:17:16 | [diff] [blame] | 553 | |
Gabriel Charette | 2983181c | 2018-03-28 17:01:09 | [diff] [blame] | 554 | if (BrowserThread::IsThreadInitialized(BrowserThread::IO)) { |
Sami Kyostila | 8e4d5a9 | 2019-08-02 12:45:05 | [diff] [blame] | 555 | base::PostTask( |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 556 | FROM_HERE, {BrowserThread::IO}, |
Kinuko Yasuda | 48c47586 | 2019-07-29 15:08:26 | [diff] [blame] | 557 | base::BindOnce(&SaveSessionStateOnIOThread, |
John Abd-El-Malek | b175a61 | 2018-12-03 20:11:58 | [diff] [blame] | 558 | static_cast<AppCacheServiceImpl*>( |
| 559 | storage_partition->GetAppCacheService()))); |
[email protected] | 6e2d3d2 | 2012-02-24 18:10:36 | [diff] [blame] | 560 | } |
| 561 | |
Clark DuVall | 385b5a5 | 2018-06-14 21:33:32 | [diff] [blame] | 562 | storage_partition->GetCookieManagerForBrowserProcess() |
| 563 | ->SetForceKeepSessionState(); |
| 564 | |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 565 | DOMStorageContextWrapper* dom_storage_context_proxy = |
| 566 | static_cast<DOMStorageContextWrapper*>( |
[email protected] | b1b502e | 2012-09-16 07:31:43 | [diff] [blame] | 567 | storage_partition->GetDOMStorageContext()); |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 568 | dom_storage_context_proxy->SetForceKeepSessionState(); |
[email protected] | 735e20c | 2012-03-20 01:16:59 | [diff] [blame] | 569 | |
Daniel Murphy | d9a41e7b | 2019-05-09 17:56:54 | [diff] [blame] | 570 | scoped_refptr<IndexedDBContext> indexed_db_context = |
| 571 | storage_partition->GetIndexedDBContext(); |
Victor Costan | 4b8909d5 | 2019-05-28 19:25:51 | [diff] [blame] | 572 | IndexedDBContext* const indexed_db_context_ptr = indexed_db_context.get(); |
| 573 | indexed_db_context_ptr->TaskRunner()->PostTask( |
| 574 | FROM_HERE, base::BindOnce(&SaveSessionStateOnIndexedDBThread, |
| 575 | std::move(indexed_db_context))); |
[email protected] | 6e2d3d2 | 2012-02-24 18:10:36 | [diff] [blame] | 576 | } |
| 577 | |
ttr314 | 81dc54b | 2015-08-06 20:11:26 | [diff] [blame] | 578 | void BrowserContext::SetDownloadManagerForTesting( |
| 579 | BrowserContext* browser_context, |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 580 | std::unique_ptr<content::DownloadManager> download_manager) { |
| 581 | SetDownloadManager(browser_context, std::move(download_manager)); |
ttr314 | 81dc54b | 2015-08-06 20:11:26 | [diff] [blame] | 582 | } |
| 583 | |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 584 | // static |
Marijn Kruisselbrink | 83e5cdb | 2019-06-20 00:06:28 | [diff] [blame] | 585 | void BrowserContext::Initialize(BrowserContext* browser_context, |
| 586 | const base::FilePath& path) { |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 587 | const base::Token new_group = base::Token::CreateRandom(); |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 588 | RemoveBrowserContextFromInstanceGroupMap(browser_context); |
| 589 | GetTokenToContextMap()[new_group] = browser_context; |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 590 | browser_context->SetUserData( |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 591 | kServiceInstanceGroup, |
| 592 | std::make_unique<ServiceInstanceGroupHolder>(new_group)); |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 593 | |
Ken Rockot | fd03e68 | 2019-06-20 21:13:54 | [diff] [blame] | 594 | auto* system_connector = GetSystemConnector(); |
| 595 | if (system_connector && base::ThreadTaskRunnerHandle::IsSet()) { |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 596 | // NOTE: Many unit tests create a TestBrowserContext without initializing |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 597 | // Mojo or the global service manager connection. |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 598 | |
Ken Rockot | 40a1df79 | 2019-05-08 22:15:52 | [diff] [blame] | 599 | mojo::PendingRemote<service_manager::mojom::Service> service; |
| 600 | auto service_receiver = service.InitWithNewPipeAndPassReceiver(); |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 601 | |
Ken Rockot | 40a1df79 | 2019-05-08 22:15:52 | [diff] [blame] | 602 | mojo::Remote<service_manager::mojom::ProcessMetadata> metadata; |
Ken Rockot | a86fa54 | 2018-11-13 21:47:13 | [diff] [blame] | 603 | service_manager::Identity identity(mojom::kBrowserServiceName, new_group, |
| 604 | base::Token{}, |
| 605 | base::Token::CreateRandom()); |
Ken Rockot | fd03e68 | 2019-06-20 21:13:54 | [diff] [blame] | 606 | system_connector->RegisterServiceInstance( |
Ken Rockot | 40a1df79 | 2019-05-08 22:15:52 | [diff] [blame] | 607 | identity, std::move(service), metadata.BindNewPipeAndPassReceiver()); |
| 608 | metadata->SetPID(base::GetCurrentProcId()); |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 609 | |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 610 | BrowserContextServiceManagerConnectionHolder* connection_holder = |
| 611 | new BrowserContextServiceManagerConnectionHolder( |
Ken Rockot | 40a1df79 | 2019-05-08 22:15:52 | [diff] [blame] | 612 | browser_context, std::move(service_receiver), |
Ken Rockot | 499519e | 2018-12-04 06:57:44 | [diff] [blame] | 613 | base::SequencedTaskRunnerHandle::Get()); |
avi | 1ed4a437 | 2017-04-25 05:39:41 | [diff] [blame] | 614 | browser_context->SetUserData(kServiceManagerConnection, |
| 615 | base::WrapUnique(connection_holder)); |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 616 | ServiceManagerConnection* connection = |
| 617 | connection_holder->service_manager_connection(); |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 618 | |
Ken Rockot | 84f58fd | 2018-06-22 21:54:14 | [diff] [blame] | 619 | browser_context->SetUserData( |
| 620 | kContentServiceDelegateKey, |
| 621 | std::make_unique<ContentServiceDelegateHolder>(browser_context)); |
| 622 | |
sammc | 030f501 | 2017-03-13 02:28:45 | [diff] [blame] | 623 | connection->Start(); |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 624 | } |
erg | e69130f5 | 2016-03-02 00:13:28 | [diff] [blame] | 625 | } |
| 626 | |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 627 | // static |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 628 | const base::Token& BrowserContext::GetServiceInstanceGroupFor( |
ben | cccfe2a | 2016-03-05 16:54:14 | [diff] [blame] | 629 | BrowserContext* browser_context) { |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 630 | ServiceInstanceGroupHolder* holder = static_cast<ServiceInstanceGroupHolder*>( |
| 631 | browser_context->GetUserData(kServiceInstanceGroup)); |
| 632 | CHECK(holder) << "Attempting to get the instance group for a BrowserContext " |
| 633 | << "that was never Initialized()."; |
| 634 | return holder->instance_group(); |
erg | e69130f5 | 2016-03-02 00:13:28 | [diff] [blame] | 635 | } |
| 636 | |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 637 | // static |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 638 | BrowserContext* BrowserContext::GetBrowserContextForServiceInstanceGroup( |
| 639 | const base::Token& instance_group) { |
| 640 | auto it = GetTokenToContextMap().find(instance_group); |
| 641 | return it != GetTokenToContextMap().end() ? it->second : nullptr; |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | // static |
rockot | 400ea35b | 2016-10-15 19:15:32 | [diff] [blame] | 645 | service_manager::Connector* BrowserContext::GetConnectorFor( |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 646 | BrowserContext* browser_context) { |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 647 | ServiceManagerConnection* connection = |
| 648 | GetServiceManagerConnectionFor(browser_context); |
ben | 5be0b913 | 2016-08-03 00:17:18 | [diff] [blame] | 649 | return connection ? connection->GetConnector() : nullptr; |
| 650 | } |
| 651 | |
| 652 | // static |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 653 | ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor( |
ben | 5be0b913 | 2016-08-03 00:17:18 | [diff] [blame] | 654 | BrowserContext* browser_context) { |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 655 | BrowserContextServiceManagerConnectionHolder* connection_holder = |
| 656 | static_cast<BrowserContextServiceManagerConnectionHolder*>( |
| 657 | browser_context->GetUserData(kServiceManagerConnection)); |
| 658 | return connection_holder ? connection_holder->service_manager_connection() |
| 659 | : nullptr; |
rockot | 963ad3e8 | 2016-04-13 16:33:23 | [diff] [blame] | 660 | } |
| 661 | |
mmenke | c0b2b8b1 | 2017-04-21 16:27:52 | [diff] [blame] | 662 | BrowserContext::BrowserContext() |
Takashi Toyoshima | 0190a3b | 2019-01-21 07:39:06 | [diff] [blame] | 663 | : unique_id_(base::UnguessableToken::Create().ToString()) {} |
mmenke | c0b2b8b1 | 2017-04-21 16:27:52 | [diff] [blame] | 664 | |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 665 | BrowserContext::~BrowserContext() { |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 666 | CHECK(GetUserData(kServiceInstanceGroup)) |
erg | e69130f5 | 2016-03-02 00:13:28 | [diff] [blame] | 667 | << "Attempting to destroy a BrowserContext that never called " |
| 668 | << "Initialize()"; |
| 669 | |
kinuko | f6ed359c | 2016-07-26 13:27:21 | [diff] [blame] | 670 | DCHECK(!GetUserData(kStoragePartitionMapKeyName)) |
| 671 | << "StoragePartitionMap is not shut down properly"; |
| 672 | |
Lukasz Anforowicz | 58d0dac | 2018-03-23 15:48:10 | [diff] [blame] | 673 | DCHECK(was_notify_will_be_destroyed_called_); |
| 674 | |
Ken Rockot | da7edc6 | 2018-11-10 01:01:45 | [diff] [blame] | 675 | RemoveBrowserContextFromInstanceGroupMap(this); |
ben | 6c85c449 | 2016-06-16 20:40:51 | [diff] [blame] | 676 | |
[email protected] | b441a849 | 2012-06-06 14:55:57 | [diff] [blame] | 677 | if (GetUserData(kDownloadManagerKeyName)) |
| 678 | GetDownloadManager(this)->Shutdown(); |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 679 | } |
| 680 | |
kinuko | f6ed359c | 2016-07-26 13:27:21 | [diff] [blame] | 681 | void BrowserContext::ShutdownStoragePartitions() { |
| 682 | if (GetUserData(kStoragePartitionMapKeyName)) |
| 683 | RemoveUserData(kStoragePartitionMapKeyName); |
| 684 | } |
| 685 | |
mmenke | c0b2b8b1 | 2017-04-21 16:27:52 | [diff] [blame] | 686 | std::string BrowserContext::GetMediaDeviceIDSalt() { |
Andrey Lushnikov | d39d906 | 2018-04-24 17:33:35 | [diff] [blame] | 687 | return unique_id_; |
mmenke | c0b2b8b1 | 2017-04-21 16:27:52 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | // static |
| 691 | std::string BrowserContext::CreateRandomMediaDeviceIDSalt() { |
Andrey Lushnikov | d39d906 | 2018-04-24 17:33:35 | [diff] [blame] | 692 | return base::UnguessableToken::Create().ToString(); |
| 693 | } |
| 694 | |
Ken Rockot | 43513269 | 2018-11-20 21:46:10 | [diff] [blame] | 695 | std::unique_ptr<service_manager::Service> BrowserContext::HandleServiceRequest( |
| 696 | const std::string& service_name, |
| 697 | service_manager::mojom::ServiceRequest request) { |
| 698 | return nullptr; |
| 699 | } |
| 700 | |
Lucas Furukawa Gadani | f4522386 | 2019-06-21 23:11:14 | [diff] [blame] | 701 | const std::string& BrowserContext::UniqueId() { |
Andrey Lushnikov | d39d906 | 2018-04-24 17:33:35 | [diff] [blame] | 702 | return unique_id_; |
mmenke | c0b2b8b1 | 2017-04-21 16:27:52 | [diff] [blame] | 703 | } |
| 704 | |
Chris Cunningham | a5b3801 | 2017-10-28 07:27:18 | [diff] [blame] | 705 | media::VideoDecodePerfHistory* BrowserContext::GetVideoDecodePerfHistory() { |
| 706 | media::VideoDecodePerfHistory* decode_history = |
| 707 | static_cast<media::VideoDecodePerfHistory*>( |
| 708 | GetUserData(kVideoDecodePerfHistoryId)); |
| 709 | |
| 710 | // Lazily created. Note, this does not trigger loading the DB from disk. That |
| 711 | // occurs later upon first VideoDecodePerfHistory API request that requires DB |
| 712 | // access. DB operations will not block the UI thread. |
| 713 | if (!decode_history) { |
Chris Cunningham | 4507edfa | 2019-05-30 20:15:54 | [diff] [blame] | 714 | const char kUseInMemoryDBParamName[] = "db_in_memory"; |
| 715 | const bool kUseInMemoryDBDefault = false; |
| 716 | bool use_in_memory_db = base::GetFieldTrialParamByFeatureAsBool( |
| 717 | media::kMediaCapabilitiesWithParameters, kUseInMemoryDBParamName, |
| 718 | kUseInMemoryDBDefault); |
| 719 | |
| 720 | std::unique_ptr<media::VideoDecodeStatsDB> stats_db; |
| 721 | if (use_in_memory_db) { |
| 722 | stats_db = |
| 723 | std::make_unique<media::InMemoryVideoDecodeStatsDBImpl>(nullptr); |
| 724 | } else { |
ssid | 554500e | 2019-08-14 22:15:01 | [diff] [blame] | 725 | auto* db_provider = |
| 726 | GetDefaultStoragePartition(this)->GetProtoDatabaseProvider(); |
| 727 | |
Chris Cunningham | 4507edfa | 2019-05-30 20:15:54 | [diff] [blame] | 728 | stats_db = media::VideoDecodeStatsDBImpl::Create( |
ssid | 554500e | 2019-08-14 22:15:01 | [diff] [blame] | 729 | GetPath().Append(FILE_PATH_LITERAL("VideoDecodeStats")), db_provider); |
Chris Cunningham | 4507edfa | 2019-05-30 20:15:54 | [diff] [blame] | 730 | } |
| 731 | |
[email protected] | 3dcea37a | 2019-02-11 19:46:51 | [diff] [blame] | 732 | auto new_decode_history = std::make_unique<media::VideoDecodePerfHistory>( |
| 733 | std::move(stats_db), BrowserFeatureProvider::GetFactoryCB()); |
chcunningham | 06b8109 | 2018-09-24 20:20:51 | [diff] [blame] | 734 | decode_history = new_decode_history.get(); |
| 735 | |
| 736 | SetUserData(kVideoDecodePerfHistoryId, std::move(new_decode_history)); |
Chris Cunningham | a5b3801 | 2017-10-28 07:27:18 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | return decode_history; |
| 740 | } |
| 741 | |
Thomas Guilbert | a424bb2 | 2019-08-20 21:33:41 | [diff] [blame] | 742 | media::learning::LearningSession* BrowserContext::GetLearningSession() { |
| 743 | media::learning::LearningSession* learning_session = |
| 744 | static_cast<media::learning::LearningSession*>( |
| 745 | GetUserData(kLearningSession)); |
| 746 | |
| 747 | if (!learning_session) { |
| 748 | auto new_learning_session = |
| 749 | std::make_unique<media::learning::LearningSessionImpl>( |
| 750 | base::SequencedTaskRunnerHandle::Get()); |
| 751 | |
[email protected] | 3af28f1 | 2019-09-19 16:32:14 | [diff] [blame] | 752 | // Register all the LearningTasks. |
| 753 | auto cb = base::BindRepeating( |
| 754 | [](media::learning::LearningSessionImpl* session, |
| 755 | const media::learning::LearningTask& task) { |
| 756 | session->RegisterTask(task); |
| 757 | }, |
| 758 | new_learning_session.get()); |
| 759 | media::learning::MediaLearningTasks::Register(std::move(cb)); |
| 760 | |
Thomas Guilbert | a424bb2 | 2019-08-20 21:33:41 | [diff] [blame] | 761 | learning_session = new_learning_session.get(); |
| 762 | |
| 763 | SetUserData(kLearningSession, std::move(new_learning_session)); |
| 764 | } |
| 765 | |
| 766 | return learning_session; |
| 767 | } |
| 768 | |
Min Qin | d3ff2ed6 | 2018-07-21 06:46:59 | [diff] [blame] | 769 | download::InProgressDownloadManager* |
| 770 | BrowserContext::RetriveInProgressDownloadManager() { |
| 771 | return nullptr; |
| 772 | } |
| 773 | |
Takashi Toyoshima | 0190a3b | 2019-01-21 07:39:06 | [diff] [blame] | 774 | void BrowserContext::SetCorsOriginAccessListForOrigin( |
| 775 | const url::Origin& source_origin, |
| 776 | std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns, |
| 777 | std::vector<network::mojom::CorsOriginPatternPtr> block_patterns, |
| 778 | base::OnceClosure closure) { |
| 779 | NOTREACHED() << "Sub-classes should implement this method to communicate " |
| 780 | "with NetworkService to bypass CORS checks."; |
| 781 | } |
| 782 | |
Lucas Furukawa Gadani | 0a70be9 | 2019-06-28 17:31:26 | [diff] [blame] | 783 | SharedCorsOriginAccessList* BrowserContext::GetSharedCorsOriginAccessList() { |
Takashi Toyoshima | 0190a3b | 2019-01-21 07:39:06 | [diff] [blame] | 784 | // Need to return a valid instance regardless of CORS bypass supports. |
| 785 | static const base::NoDestructor<scoped_refptr<SharedCorsOriginAccessList>> |
| 786 | empty_list(SharedCorsOriginAccessList::Create()); |
| 787 | return empty_list->get(); |
| 788 | } |
| 789 | |
Takashi Toyoshima | 12844146 | 2019-10-16 04:19:17 | [diff] [blame^] | 790 | bool BrowserContext::ShouldEnableOutOfBlinkCors() { |
| 791 | return base::FeatureList::IsEnabled(network::features::kOutOfBlinkCors); |
| 792 | } |
| 793 | |
Marijn Kruisselbrink | 83e5cdb | 2019-06-20 00:06:28 | [diff] [blame] | 794 | NativeFileSystemPermissionContext* |
| 795 | BrowserContext::GetNativeFileSystemPermissionContext() { |
| 796 | return nullptr; |
| 797 | } |
| 798 | |
Rayan Kanso | 03a847b | 2019-06-27 21:00:09 | [diff] [blame] | 799 | ContentIndexProvider* BrowserContext::GetContentIndexProvider() { |
| 800 | return nullptr; |
| 801 | } |
| 802 | |
[email protected] | 55eb70e76 | 2012-02-20 17:38:39 | [diff] [blame] | 803 | } // namespace content |