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 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <limits> | 11 #include <limits> |
12 #include <memory> | 12 #include <memory> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/base64.h" | 16 #include "base/base64.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/guid.h" | 18 #include "base/guid.h" |
19 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/macros.h" | 21 #include "base/macros.h" |
22 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
23 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 26 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 27 #include "content/browser/browsing_data/browsing_data_remover_impl.h" |
27 #include "content/browser/download/download_manager_impl.h" | 28 #include "content/browser/download/download_manager_impl.h" |
28 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 29 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
29 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 30 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
30 #include "content/browser/push_messaging/push_messaging_router.h" | 31 #include "content/browser/push_messaging/push_messaging_router.h" |
31 #include "content/browser/storage_partition_impl_map.h" | 32 #include "content/browser/storage_partition_impl_map.h" |
32 #include "content/common/child_process_host_impl.h" | 33 #include "content/common/child_process_host_impl.h" |
33 #include "content/public/browser/blob_handle.h" | 34 #include "content/public/browser/blob_handle.h" |
34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/browser/content_browser_client.h" | 36 #include "content/public/browser/content_browser_client.h" |
36 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 69 |
69 const std::string& user_id() const { return user_id_; } | 70 const std::string& user_id() const { return user_id_; } |
70 | 71 |
71 private: | 72 private: |
72 std::string user_id_; | 73 std::string user_id_; |
73 | 74 |
74 DISALLOW_COPY_AND_ASSIGN(ServiceUserIdHolder); | 75 DISALLOW_COPY_AND_ASSIGN(ServiceUserIdHolder); |
75 }; | 76 }; |
76 | 77 |
77 // Key names on BrowserContext. | 78 // Key names on BrowserContext. |
| 79 const char kBrowsingDataRemoverKey[] = "browsing-data-remover"; |
78 const char kDownloadManagerKeyName[] = "download_manager"; | 80 const char kDownloadManagerKeyName[] = "download_manager"; |
79 const char kMojoWasInitialized[] = "mojo-was-initialized"; | 81 const char kMojoWasInitialized[] = "mojo-was-initialized"; |
80 const char kServiceManagerConnection[] = "service-manager-connection"; | 82 const char kServiceManagerConnection[] = "service-manager-connection"; |
81 const char kServiceUserId[] = "service-user-id"; | 83 const char kServiceUserId[] = "service-user-id"; |
82 const char kStoragePartitionMapKeyName[] = "content_storage_partition_map"; | 84 const char kStoragePartitionMapKeyName[] = "content_storage_partition_map"; |
83 | 85 |
84 #if defined(OS_CHROMEOS) | 86 #if defined(OS_CHROMEOS) |
85 const char kMountPointsKey[] = "mount_points"; | 87 const char kMountPointsKey[] = "mount_points"; |
86 #endif // defined(OS_CHROMEOS) | 88 #endif // defined(OS_CHROMEOS) |
87 | 89 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 new UserDataAdapter<storage::ExternalMountPoints>(mount_points.get())); | 229 new UserDataAdapter<storage::ExternalMountPoints>(mount_points.get())); |
228 } | 230 } |
229 | 231 |
230 return UserDataAdapter<storage::ExternalMountPoints>::Get(context, | 232 return UserDataAdapter<storage::ExternalMountPoints>::Get(context, |
231 kMountPointsKey); | 233 kMountPointsKey); |
232 #else | 234 #else |
233 return NULL; | 235 return NULL; |
234 #endif | 236 #endif |
235 } | 237 } |
236 | 238 |
| 239 // static |
| 240 content::BrowsingDataRemover* content::BrowserContext::GetBrowsingDataRemover( |
| 241 BrowserContext* context) { |
| 242 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 243 |
| 244 if (!context->GetUserData(kBrowsingDataRemoverKey)) { |
| 245 std::unique_ptr<BrowsingDataRemoverImpl> remover = |
| 246 base::MakeUnique<BrowsingDataRemoverImpl>(context); |
| 247 remover->SetEmbedderDelegate(context->GetBrowsingDataRemoverDelegate()); |
| 248 context->SetUserData(kBrowsingDataRemoverKey, std::move(remover)); |
| 249 } |
| 250 |
| 251 return static_cast<BrowsingDataRemoverImpl*>( |
| 252 context->GetUserData(kBrowsingDataRemoverKey)); |
| 253 } |
| 254 |
237 StoragePartition* BrowserContext::GetStoragePartition( | 255 StoragePartition* BrowserContext::GetStoragePartition( |
238 BrowserContext* browser_context, | 256 BrowserContext* browser_context, |
239 SiteInstance* site_instance) { | 257 SiteInstance* site_instance) { |
240 std::string partition_domain; | 258 std::string partition_domain; |
241 std::string partition_name; | 259 std::string partition_name; |
242 bool in_memory = false; | 260 bool in_memory = false; |
243 | 261 |
244 if (site_instance) { | 262 if (site_instance) { |
245 GetContentClient()->browser()->GetStoragePartitionConfigForSite( | 263 GetContentClient()->browser()->GetStoragePartitionConfigForSite( |
246 browser_context, site_instance->GetSiteURL(), true, | 264 browser_context, site_instance->GetSiteURL(), true, |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 } | 559 } |
542 | 560 |
543 // static | 561 // static |
544 std::string BrowserContext::CreateRandomMediaDeviceIDSalt() { | 562 std::string BrowserContext::CreateRandomMediaDeviceIDSalt() { |
545 std::string salt; | 563 std::string salt; |
546 base::Base64Encode(base::RandBytesAsString(16), &salt); | 564 base::Base64Encode(base::RandBytesAsString(16), &salt); |
547 DCHECK(!salt.empty()); | 565 DCHECK(!salt.empty()); |
548 return salt; | 566 return salt; |
549 } | 567 } |
550 | 568 |
| 569 BrowsingDataRemoverDelegate* BrowserContext::GetBrowsingDataRemoverDelegate() { |
| 570 return nullptr; |
| 571 } |
| 572 |
551 } // namespace content | 573 } // namespace content |
OLD | NEW |