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 "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "components/profile_service/profile_app.h" | |
22 #include "components/profile_service/public/cpp/constants.h" | |
23 #include "components/profile_service/user_id_map.h" | |
24 #include "content/browser/download/download_manager_impl.h" | 21 #include "content/browser/download/download_manager_impl.h" |
25 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 22 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
26 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 23 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
27 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 24 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
28 #include "content/browser/mojo/browser_shell_connection.h" | 25 #include "content/browser/mojo/browser_shell_connection.h" |
29 #include "content/browser/mojo/constants.h" | 26 #include "content/browser/mojo/constants.h" |
30 #include "content/browser/push_messaging/push_messaging_router.h" | 27 #include "content/browser/push_messaging/push_messaging_router.h" |
31 #include "content/browser/storage_partition_impl_map.h" | 28 #include "content/browser/storage_partition_impl_map.h" |
32 #include "content/common/child_process_host_impl.h" | 29 #include "content/common/child_process_host_impl.h" |
33 #include "content/public/browser/blob_handle.h" | 30 #include "content/public/browser/blob_handle.h" |
34 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
36 #include "content/public/browser/site_instance.h" | 33 #include "content/public/browser/site_instance.h" |
37 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
38 #include "content/public/common/mojo_shell_connection.h" | 35 #include "content/public/common/mojo_shell_connection.h" |
39 #include "net/cookies/cookie_store.h" | 36 #include "net/cookies/cookie_store.h" |
40 #include "net/ssl/channel_id_service.h" | 37 #include "net/ssl/channel_id_service.h" |
41 #include "net/ssl/channel_id_store.h" | 38 #include "net/ssl/channel_id_store.h" |
42 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
43 #include "net/url_request/url_request_context_getter.h" | 40 #include "net/url_request/url_request_context_getter.h" |
44 #include "services/shell/public/cpp/connection.h" | 41 #include "services/shell/public/cpp/connection.h" |
45 #include "services/shell/public/cpp/connector.h" | 42 #include "services/shell/public/cpp/connector.h" |
46 #include "services/shell/public/interfaces/shell_client.mojom.h" | 43 #include "services/shell/public/interfaces/shell_client.mojom.h" |
| 44 #include "services/user/public/cpp/constants.h" |
| 45 #include "services/user/user_id_map.h" |
| 46 #include "services/user/user_shell_client.h" |
47 #include "storage/browser/database/database_tracker.h" | 47 #include "storage/browser/database/database_tracker.h" |
48 #include "storage/browser/fileapi/external_mount_points.h" | 48 #include "storage/browser/fileapi/external_mount_points.h" |
49 | 49 |
50 using base::UserDataAdapter; | 50 using base::UserDataAdapter; |
51 | 51 |
52 namespace content { | 52 namespace content { |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 base::LazyInstance<std::set<std::string>> g_used_user_ids = | 56 base::LazyInstance<std::set<std::string>> g_used_user_ids = |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 BrowserContext* browser_context, | 367 BrowserContext* browser_context, |
368 const base::FilePath& path) { | 368 const base::FilePath& path) { |
369 // Generate a GUID for |browser_context| to use as the Mojo user id. | 369 // Generate a GUID for |browser_context| to use as the Mojo user id. |
370 std::string new_id = base::GenerateGUID(); | 370 std::string new_id = base::GenerateGUID(); |
371 while (g_used_user_ids.Get().find(new_id) != g_used_user_ids.Get().end()) | 371 while (g_used_user_ids.Get().find(new_id) != g_used_user_ids.Get().end()) |
372 new_id = base::GenerateGUID(); | 372 new_id = base::GenerateGUID(); |
373 | 373 |
374 g_used_user_ids.Get().insert(new_id); | 374 g_used_user_ids.Get().insert(new_id); |
375 g_context_to_user_id.Get().push_back(std::make_pair(browser_context, new_id)); | 375 g_context_to_user_id.Get().push_back(std::make_pair(browser_context, new_id)); |
376 | 376 |
377 profile::AssociateMojoUserIDWithProfileDir(new_id, path); | 377 user_service::AssociateMojoUserIDWithUserDir(new_id, path); |
378 browser_context->SetUserData(kMojoWasInitialized, | 378 browser_context->SetUserData(kMojoWasInitialized, |
379 new base::SupportsUserData::Data); | 379 new base::SupportsUserData::Data); |
380 | 380 |
381 MojoShellConnection* shell = MojoShellConnection::Get(); | 381 MojoShellConnection* shell = MojoShellConnection::Get(); |
382 if (shell) { | 382 if (shell) { |
383 // NOTE: Many unit tests create a TestBrowserContext without initializing | 383 // NOTE: Many unit tests create a TestBrowserContext without initializing |
384 // Mojo or the global Mojo shell connection. | 384 // Mojo or the global Mojo shell connection. |
385 | 385 |
386 mojo::shell::mojom::ShellClientPtr shell_client; | 386 mojo::shell::mojom::ShellClientPtr shell_client; |
387 mojo::shell::mojom::ShellClientRequest shell_client_request = | 387 mojo::shell::mojom::ShellClientRequest shell_client_request = |
(...skipping 12 matching lines...) Expand all Loading... |
400 std::move(shell_client_request)); | 400 std::move(shell_client_request)); |
401 browser_context->SetUserData(kMojoShellConnection, connection_holder); | 401 browser_context->SetUserData(kMojoShellConnection, connection_holder); |
402 | 402 |
403 BrowserShellConnection* connection = connection_holder->shell_connection(); | 403 BrowserShellConnection* connection = connection_holder->shell_connection(); |
404 | 404 |
405 // New embedded application factories should be added to |connection| here. | 405 // New embedded application factories should be added to |connection| here. |
406 | 406 |
407 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 407 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
408 switches::kMojoLocalStorage)) { | 408 switches::kMojoLocalStorage)) { |
409 connection->AddEmbeddedApplication( | 409 connection->AddEmbeddedApplication( |
410 profile::kProfileMojoApplicationName, | 410 user_service::kUserServiceName, |
411 base::Bind( | 411 base::Bind( |
412 &profile::CreateProfileApp, | 412 &user_service::CreateUserShellClient, |
413 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 413 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
414 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)), | 414 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)), |
415 nullptr); | 415 nullptr); |
416 } | 416 } |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 // static | 420 // static |
421 const std::string& BrowserContext::GetMojoUserIdFor( | 421 const std::string& BrowserContext::GetMojoUserIdFor( |
422 BrowserContext* browser_context) { | 422 BrowserContext* browser_context) { |
(...skipping 24 matching lines...) Expand all Loading... |
447 BrowserContext::~BrowserContext() { | 447 BrowserContext::~BrowserContext() { |
448 CHECK(GetUserData(kMojoWasInitialized)) | 448 CHECK(GetUserData(kMojoWasInitialized)) |
449 << "Attempting to destroy a BrowserContext that never called " | 449 << "Attempting to destroy a BrowserContext that never called " |
450 << "Initialize()"; | 450 << "Initialize()"; |
451 | 451 |
452 if (GetUserData(kDownloadManagerKeyName)) | 452 if (GetUserData(kDownloadManagerKeyName)) |
453 GetDownloadManager(this)->Shutdown(); | 453 GetDownloadManager(this)->Shutdown(); |
454 } | 454 } |
455 | 455 |
456 } // namespace content | 456 } // namespace content |
OLD | NEW |