OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/public/browser/browser_context.h" | 5 #include "content/public/browser/browser_context.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/guid.h" | 16 #include "base/guid.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 22 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
23 #include "content/browser/browsing_data/browsing_data_remover_impl.h" | |
23 #include "content/browser/download/download_manager_impl.h" | 24 #include "content/browser/download/download_manager_impl.h" |
24 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 25 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
25 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 26 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
26 #include "content/browser/push_messaging/push_messaging_router.h" | 27 #include "content/browser/push_messaging/push_messaging_router.h" |
27 #include "content/browser/storage_partition_impl_map.h" | 28 #include "content/browser/storage_partition_impl_map.h" |
28 #include "content/common/child_process_host_impl.h" | 29 #include "content/common/child_process_host_impl.h" |
29 #include "content/public/browser/blob_handle.h" | 30 #include "content/public/browser/blob_handle.h" |
30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
32 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 | 65 |
65 const std::string& user_id() const { return user_id_; } | 66 const std::string& user_id() const { return user_id_; } |
66 | 67 |
67 private: | 68 private: |
68 std::string user_id_; | 69 std::string user_id_; |
69 | 70 |
70 DISALLOW_COPY_AND_ASSIGN(ServiceUserIdHolder); | 71 DISALLOW_COPY_AND_ASSIGN(ServiceUserIdHolder); |
71 }; | 72 }; |
72 | 73 |
73 // Key names on BrowserContext. | 74 // Key names on BrowserContext. |
75 const char kBrowsingDataRemoverKey[] = "browsing-data-remover"; | |
74 const char kDownloadManagerKeyName[] = "download_manager"; | 76 const char kDownloadManagerKeyName[] = "download_manager"; |
75 const char kMojoWasInitialized[] = "mojo-was-initialized"; | 77 const char kMojoWasInitialized[] = "mojo-was-initialized"; |
76 const char kServiceManagerConnection[] = "service-manager-connection"; | 78 const char kServiceManagerConnection[] = "service-manager-connection"; |
77 const char kServiceUserId[] = "service-user-id"; | 79 const char kServiceUserId[] = "service-user-id"; |
78 const char kStoragePartitionMapKeyName[] = "content_storage_partition_map"; | 80 const char kStoragePartitionMapKeyName[] = "content_storage_partition_map"; |
79 | 81 |
80 #if defined(OS_CHROMEOS) | 82 #if defined(OS_CHROMEOS) |
81 const char kMountPointsKey[] = "mount_points"; | 83 const char kMountPointsKey[] = "mount_points"; |
82 #endif // defined(OS_CHROMEOS) | 84 #endif // defined(OS_CHROMEOS) |
83 | 85 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 new UserDataAdapter<storage::ExternalMountPoints>(mount_points.get())); | 221 new UserDataAdapter<storage::ExternalMountPoints>(mount_points.get())); |
220 } | 222 } |
221 | 223 |
222 return UserDataAdapter<storage::ExternalMountPoints>::Get(context, | 224 return UserDataAdapter<storage::ExternalMountPoints>::Get(context, |
223 kMountPointsKey); | 225 kMountPointsKey); |
224 #else | 226 #else |
225 return NULL; | 227 return NULL; |
226 #endif | 228 #endif |
227 } | 229 } |
228 | 230 |
231 // static | |
232 content::BrowsingDataRemover* content::BrowserContext::GetBrowsingDataRemover( | |
233 BrowserContext* context) { | |
234 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
235 | |
236 if (!context->GetUserData(kBrowsingDataRemoverKey)) { | |
237 BrowsingDataRemoverImpl* remover = new BrowsingDataRemoverImpl(context); | |
Bernhard Bauer
2017/04/19 12:39:38
Nit: put this into a std::unique_ptr<> and use bas
msramek
2017/04/19 13:39:18
Done.
A small downside is that we can no longer u
| |
238 remover->SetEmbedderDelegate(context->GetBrowsingDataRemoverDelegate()); | |
239 context->SetUserData(kBrowsingDataRemoverKey, remover); | |
240 } | |
241 | |
242 return static_cast<BrowsingDataRemoverImpl*>( | |
243 context->GetUserData(kBrowsingDataRemoverKey)); | |
244 } | |
245 | |
229 StoragePartition* BrowserContext::GetStoragePartition( | 246 StoragePartition* BrowserContext::GetStoragePartition( |
230 BrowserContext* browser_context, | 247 BrowserContext* browser_context, |
231 SiteInstance* site_instance) { | 248 SiteInstance* site_instance) { |
232 std::string partition_domain; | 249 std::string partition_domain; |
233 std::string partition_name; | 250 std::string partition_name; |
234 bool in_memory = false; | 251 bool in_memory = false; |
235 | 252 |
236 if (site_instance) { | 253 if (site_instance) { |
237 GetContentClient()->browser()->GetStoragePartitionConfigForSite( | 254 GetContentClient()->browser()->GetStoragePartitionConfigForSite( |
238 browser_context, site_instance->GetSiteURL(), true, | 255 browser_context, site_instance->GetSiteURL(), true, |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 | 534 |
518 if (GetUserData(kDownloadManagerKeyName)) | 535 if (GetUserData(kDownloadManagerKeyName)) |
519 GetDownloadManager(this)->Shutdown(); | 536 GetDownloadManager(this)->Shutdown(); |
520 } | 537 } |
521 | 538 |
522 void BrowserContext::ShutdownStoragePartitions() { | 539 void BrowserContext::ShutdownStoragePartitions() { |
523 if (GetUserData(kStoragePartitionMapKeyName)) | 540 if (GetUserData(kStoragePartitionMapKeyName)) |
524 RemoveUserData(kStoragePartitionMapKeyName); | 541 RemoveUserData(kStoragePartitionMapKeyName); |
525 } | 542 } |
526 | 543 |
544 BrowsingDataRemoverDelegate* BrowserContext::GetBrowsingDataRemoverDelegate() { | |
545 return nullptr; | |
546 } | |
547 | |
527 } // namespace content | 548 } // namespace content |
OLD | NEW |