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 std::unique_ptr<BrowsingDataRemoverImpl> remover = |
| 238 base::MakeUnique<BrowsingDataRemoverImpl>(context); |
| 239 remover->SetEmbedderDelegate(context->GetBrowsingDataRemoverDelegate()); |
| 240 context->SetUserData(kBrowsingDataRemoverKey, remover.release()); |
| 241 } |
| 242 |
| 243 return static_cast<BrowsingDataRemoverImpl*>( |
| 244 context->GetUserData(kBrowsingDataRemoverKey)); |
| 245 } |
| 246 |
229 StoragePartition* BrowserContext::GetStoragePartition( | 247 StoragePartition* BrowserContext::GetStoragePartition( |
230 BrowserContext* browser_context, | 248 BrowserContext* browser_context, |
231 SiteInstance* site_instance) { | 249 SiteInstance* site_instance) { |
232 std::string partition_domain; | 250 std::string partition_domain; |
233 std::string partition_name; | 251 std::string partition_name; |
234 bool in_memory = false; | 252 bool in_memory = false; |
235 | 253 |
236 if (site_instance) { | 254 if (site_instance) { |
237 GetContentClient()->browser()->GetStoragePartitionConfigForSite( | 255 GetContentClient()->browser()->GetStoragePartitionConfigForSite( |
238 browser_context, site_instance->GetSiteURL(), true, | 256 browser_context, site_instance->GetSiteURL(), true, |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 535 |
518 if (GetUserData(kDownloadManagerKeyName)) | 536 if (GetUserData(kDownloadManagerKeyName)) |
519 GetDownloadManager(this)->Shutdown(); | 537 GetDownloadManager(this)->Shutdown(); |
520 } | 538 } |
521 | 539 |
522 void BrowserContext::ShutdownStoragePartitions() { | 540 void BrowserContext::ShutdownStoragePartitions() { |
523 if (GetUserData(kStoragePartitionMapKeyName)) | 541 if (GetUserData(kStoragePartitionMapKeyName)) |
524 RemoveUserData(kStoragePartitionMapKeyName); | 542 RemoveUserData(kStoragePartitionMapKeyName); |
525 } | 543 } |
526 | 544 |
| 545 BrowsingDataRemoverDelegate* BrowserContext::GetBrowsingDataRemoverDelegate() { |
| 546 return nullptr; |
| 547 } |
| 548 |
527 } // namespace content | 549 } // namespace content |
OLD | NEW |