| 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 "chrome/browser/profiles/profile_impl_io_data.h" | 5 #include "chrome/browser/profiles/profile_impl_io_data.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 main_context->set_ct_policy_enforcer( | 483 main_context->set_ct_policy_enforcer( |
| 484 io_thread_globals->ct_policy_enforcer.get()); | 484 io_thread_globals->ct_policy_enforcer.get()); |
| 485 | 485 |
| 486 main_context->set_net_log(io_thread->net_log()); | 486 main_context->set_net_log(io_thread->net_log()); |
| 487 | 487 |
| 488 main_context->set_http_auth_handler_factory( | 488 main_context->set_http_auth_handler_factory( |
| 489 io_thread_globals->http_auth_handler_factory.get()); | 489 io_thread_globals->http_auth_handler_factory.get()); |
| 490 | 490 |
| 491 main_context->set_proxy_service(proxy_service()); | 491 main_context->set_proxy_service(proxy_service()); |
| 492 | 492 |
| 493 // Set up cookie store. | |
| 494 DCHECK(!lazy_params_->cookie_path.empty()); | |
| 495 | |
| 496 content::CookieStoreConfig cookie_config( | |
| 497 lazy_params_->cookie_path, lazy_params_->session_cookie_mode, | |
| 498 lazy_params_->special_storage_policy.get(), | |
| 499 profile_params->cookie_monster_delegate.get()); | |
| 500 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); | |
| 501 main_context_storage->set_cookie_store( | |
| 502 content::CreateCookieStore(cookie_config)); | |
| 503 | |
| 504 // Set up server bound cert service. | 493 // Set up server bound cert service. |
| 505 DCHECK(!lazy_params_->channel_id_path.empty()); | 494 DCHECK(!lazy_params_->channel_id_path.empty()); |
| 506 scoped_refptr<QuotaPolicyChannelIDStore> channel_id_db = | 495 scoped_refptr<QuotaPolicyChannelIDStore> channel_id_db = |
| 507 new QuotaPolicyChannelIDStore( | 496 new QuotaPolicyChannelIDStore( |
| 508 lazy_params_->channel_id_path, | 497 lazy_params_->channel_id_path, |
| 509 base::CreateSequencedTaskRunnerWithTraits( | 498 base::CreateSequencedTaskRunnerWithTraits( |
| 510 {base::MayBlock(), base::TaskPriority::BACKGROUND}), | 499 {base::MayBlock(), base::TaskPriority::BACKGROUND}), |
| 511 lazy_params_->special_storage_policy.get()); | 500 lazy_params_->special_storage_policy.get()); |
| 512 main_context_storage->set_channel_id_service( | 501 main_context_storage->set_channel_id_service( |
| 513 base::MakeUnique<net::ChannelIDService>( | 502 base::MakeUnique<net::ChannelIDService>( |
| 514 new net::DefaultChannelIDStore(channel_id_db.get()))); | 503 new net::DefaultChannelIDStore(channel_id_db.get()))); |
| 515 | 504 |
| 505 // Set up cookie store. |
| 506 DCHECK(!lazy_params_->cookie_path.empty()); |
| 507 |
| 508 content::CookieStoreConfig cookie_config( |
| 509 lazy_params_->cookie_path, lazy_params_->session_cookie_mode, |
| 510 lazy_params_->special_storage_policy.get(), |
| 511 profile_params->cookie_monster_delegate.get()); |
| 512 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); |
| 513 cookie_config.channel_id_service = main_context->channel_id_service(); |
| 514 main_context_storage->set_cookie_store( |
| 515 content::CreateCookieStore(cookie_config)); |
| 516 |
| 516 main_context->cookie_store()->SetChannelIDServiceID( | 517 main_context->cookie_store()->SetChannelIDServiceID( |
| 517 main_context->channel_id_service()->GetUniqueID()); | 518 main_context->channel_id_service()->GetUniqueID()); |
| 518 | 519 |
| 519 std::unique_ptr<net::HttpCache::BackendFactory> main_backend( | 520 std::unique_ptr<net::HttpCache::BackendFactory> main_backend( |
| 520 new net::HttpCache::DefaultBackend( | 521 new net::HttpCache::DefaultBackend( |
| 521 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path, | 522 net::DISK_CACHE, ChooseCacheBackendType(), lazy_params_->cache_path, |
| 522 lazy_params_->cache_max_size, | 523 lazy_params_->cache_max_size, |
| 523 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); | 524 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); |
| 524 main_context_storage->set_http_network_session( | 525 main_context_storage->set_http_network_session( |
| 525 CreateHttpNetworkSession(*profile_params)); | 526 CreateHttpNetworkSession(*profile_params)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 579 |
| 579 extensions_context->set_net_log(io_thread->net_log()); | 580 extensions_context->set_net_log(io_thread->net_log()); |
| 580 | 581 |
| 581 content::CookieStoreConfig cookie_config( | 582 content::CookieStoreConfig cookie_config( |
| 582 lazy_params_->extensions_cookie_path, | 583 lazy_params_->extensions_cookie_path, |
| 583 lazy_params_->session_cookie_mode, | 584 lazy_params_->session_cookie_mode, |
| 584 NULL, NULL); | 585 NULL, NULL); |
| 585 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); | 586 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); |
| 586 // Enable cookies for chrome-extension URLs. | 587 // Enable cookies for chrome-extension URLs. |
| 587 cookie_config.cookieable_schemes.push_back(extensions::kExtensionScheme); | 588 cookie_config.cookieable_schemes.push_back(extensions::kExtensionScheme); |
| 589 cookie_config.channel_id_service = extensions_context->channel_id_service(); |
| 588 extensions_cookie_store_ = content::CreateCookieStore(cookie_config); | 590 extensions_cookie_store_ = content::CreateCookieStore(cookie_config); |
| 589 extensions_context->set_cookie_store(extensions_cookie_store_.get()); | 591 extensions_context->set_cookie_store(extensions_cookie_store_.get()); |
| 590 if (extensions_context->channel_id_service()) { | 592 if (extensions_context->channel_id_service()) { |
| 591 extensions_cookie_store_->SetChannelIDServiceID( | 593 extensions_cookie_store_->SetChannelIDServiceID( |
| 592 extensions_context->channel_id_service()->GetUniqueID()); | 594 extensions_context->channel_id_service()->GetUniqueID()); |
| 593 } | 595 } |
| 594 | 596 |
| 595 std::unique_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 597 std::unique_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |
| 596 new net::URLRequestJobFactoryImpl()); | 598 new net::URLRequestJobFactoryImpl()); |
| 597 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 599 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } else { | 635 } else { |
| 634 app_backend.reset(new net::HttpCache::DefaultBackend( | 636 app_backend.reset(new net::HttpCache::DefaultBackend( |
| 635 net::DISK_CACHE, ChooseCacheBackendType(), cache_path, | 637 net::DISK_CACHE, ChooseCacheBackendType(), cache_path, |
| 636 app_cache_max_size_, | 638 app_cache_max_size_, |
| 637 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); | 639 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); |
| 638 } | 640 } |
| 639 | 641 |
| 640 std::unique_ptr<net::CookieStore> cookie_store; | 642 std::unique_ptr<net::CookieStore> cookie_store; |
| 641 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; | 643 scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; |
| 642 if (partition_descriptor.in_memory) { | 644 if (partition_descriptor.in_memory) { |
| 643 cookie_store = content::CreateCookieStore(content::CookieStoreConfig()); | 645 cookie_path = base::FilePath(); |
| 644 } else { | 646 } |
| 647 content::CookieStoreConfig cookie_config( |
| 648 cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, |
| 649 nullptr, nullptr); |
| 650 if (!partition_descriptor.in_memory) { |
| 645 // Use an app-specific cookie store. | 651 // Use an app-specific cookie store. |
| 646 DCHECK(!cookie_path.empty()); | 652 DCHECK(!cookie_path.empty()); |
| 647 | 653 |
| 648 // TODO(creis): We should have a cookie delegate for notifying the cookie | 654 // TODO(creis): We should have a cookie delegate for notifying the cookie |
| 649 // extensions API, but we need to update it to understand isolated apps | 655 // extensions API, but we need to update it to understand isolated apps |
| 650 // first. | 656 // first. |
| 651 content::CookieStoreConfig cookie_config( | |
| 652 cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, | |
| 653 nullptr, nullptr); | |
| 654 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); | 657 cookie_config.crypto_delegate = cookie_config::GetCookieCryptoDelegate(); |
| 655 cookie_store = content::CreateCookieStore(cookie_config); | |
| 656 channel_id_db = new net::SQLiteChannelIDStore( | 658 channel_id_db = new net::SQLiteChannelIDStore( |
| 657 channel_id_path, | 659 channel_id_path, |
| 658 base::CreateSequencedTaskRunnerWithTraits( | 660 base::CreateSequencedTaskRunnerWithTraits( |
| 659 {base::MayBlock(), base::TaskPriority::BACKGROUND})); | 661 {base::MayBlock(), base::TaskPriority::BACKGROUND})); |
| 660 } | 662 } |
| 661 std::unique_ptr<net::ChannelIDService> channel_id_service( | 663 std::unique_ptr<net::ChannelIDService> channel_id_service( |
| 662 new net::ChannelIDService( | 664 new net::ChannelIDService( |
| 663 new net::DefaultChannelIDStore(channel_id_db.get()))); | 665 new net::DefaultChannelIDStore(channel_id_db.get()))); |
| 666 cookie_config.channel_id_service = channel_id_service.get(); |
| 667 cookie_store = content::CreateCookieStore(cookie_config); |
| 664 cookie_store->SetChannelIDServiceID(channel_id_service->GetUniqueID()); | 668 cookie_store->SetChannelIDServiceID(channel_id_service->GetUniqueID()); |
| 665 | 669 |
| 666 // Build a new HttpNetworkSession that uses the new ChannelIDService. | 670 // Build a new HttpNetworkSession that uses the new ChannelIDService. |
| 667 // TODO(mmenke): It weird to combine state from | 671 // TODO(mmenke): It weird to combine state from |
| 668 // main_request_context_storage() objects and the argumet to this method, | 672 // main_request_context_storage() objects and the argumet to this method, |
| 669 // |main_context|. Remove |main_context| as an argument, and just use | 673 // |main_context|. Remove |main_context| as an argument, and just use |
| 670 // main_context() instead. | 674 // main_context() instead. |
| 671 net::HttpNetworkSession::Params network_params = | 675 net::HttpNetworkSession::Params network_params = |
| 672 main_request_context_storage()->http_network_session()->params(); | 676 main_request_context_storage()->http_network_session()->params(); |
| 673 network_params.channel_id_service = channel_id_service.get(); | 677 network_params.channel_id_service = channel_id_service.get(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 const base::Closure& completion) { | 810 const base::Closure& completion) { |
| 807 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 811 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 808 DCHECK(initialized()); | 812 DCHECK(initialized()); |
| 809 | 813 |
| 810 DCHECK(transport_security_state()); | 814 DCHECK(transport_security_state()); |
| 811 // Completes synchronously. | 815 // Completes synchronously. |
| 812 transport_security_state()->DeleteAllDynamicDataSince(time); | 816 transport_security_state()->DeleteAllDynamicDataSince(time); |
| 813 DCHECK(http_server_properties_manager_); | 817 DCHECK(http_server_properties_manager_); |
| 814 http_server_properties_manager_->Clear(completion); | 818 http_server_properties_manager_->Clear(completion); |
| 815 } | 819 } |
| OLD | NEW |