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