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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 main_cache->set_mode( | 395 main_cache->set_mode( |
396 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 396 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
397 } | 397 } |
398 | 398 |
399 main_http_factory_.reset(main_cache); | 399 main_http_factory_.reset(main_cache); |
400 main_context->set_http_transaction_factory(main_cache); | 400 main_context->set_http_transaction_factory(main_cache); |
401 | 401 |
402 #if !defined(DISABLE_FTP_SUPPORT) | 402 #if !defined(DISABLE_FTP_SUPPORT) |
403 ftp_factory_.reset( | 403 ftp_factory_.reset( |
404 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 404 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
405 main_context->set_ftp_transaction_factory(ftp_factory_.get()); | |
406 #endif // !defined(DISABLE_FTP_SUPPORT) | 405 #endif // !defined(DISABLE_FTP_SUPPORT) |
407 | 406 |
408 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 407 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
409 new net::URLRequestJobFactoryImpl()); | 408 new net::URLRequestJobFactoryImpl()); |
410 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); | 409 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); |
411 main_job_factory_ = SetUpJobFactoryDefaults( | 410 main_job_factory_ = SetUpJobFactoryDefaults( |
412 main_job_factory.Pass(), | 411 main_job_factory.Pass(), |
413 profile_params->protocol_handler_interceptor.Pass(), | 412 profile_params->protocol_handler_interceptor.Pass(), |
414 network_delegate(), | 413 network_delegate(), |
415 main_context->ftp_transaction_factory(), | 414 ftp_factory_.get()); |
416 main_context->ftp_auth_cache()); | |
417 main_context->set_job_factory(main_job_factory_.get()); | 415 main_context->set_job_factory(main_job_factory_.get()); |
418 | 416 |
419 #if defined(ENABLE_EXTENSIONS) | 417 #if defined(ENABLE_EXTENSIONS) |
420 InitializeExtensionsRequestContext(profile_params); | 418 InitializeExtensionsRequestContext(profile_params); |
421 #endif | 419 #endif |
422 | 420 |
423 // Create a media request context based on the main context, but using a | 421 // Create a media request context based on the main context, but using a |
424 // media cache. It shares the same job factory as the main context. | 422 // media cache. It shares the same job factory as the main context. |
425 StoragePartitionDescriptor details(profile_path_, false); | 423 StoragePartitionDescriptor details(profile_path_, false); |
426 media_request_context_.reset(InitializeMediaRequestContext(main_context, | 424 media_request_context_.reset(InitializeMediaRequestContext(main_context, |
(...skipping 21 matching lines...) Expand all Loading... |
448 lazy_params_->extensions_cookie_path, | 446 lazy_params_->extensions_cookie_path, |
449 lazy_params_->restore_old_session_cookies, | 447 lazy_params_->restore_old_session_cookies, |
450 NULL, | 448 NULL, |
451 NULL); | 449 NULL); |
452 // Enable cookies for devtools and extension URLs. | 450 // Enable cookies for devtools and extension URLs. |
453 const char* schemes[] = {chrome::kChromeDevToolsScheme, | 451 const char* schemes[] = {chrome::kChromeDevToolsScheme, |
454 extensions::kExtensionScheme}; | 452 extensions::kExtensionScheme}; |
455 extensions_cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 2); | 453 extensions_cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 2); |
456 extensions_context->set_cookie_store(extensions_cookie_store); | 454 extensions_context->set_cookie_store(extensions_cookie_store); |
457 | 455 |
458 #if !defined(DISABLE_FTP_SUPPORT) | |
459 DCHECK(ftp_factory_); | |
460 extensions_context->set_ftp_transaction_factory(ftp_factory_.get()); | |
461 #endif // !defined(DISABLE_FTP_SUPPORT) | |
462 | |
463 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 456 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |
464 new net::URLRequestJobFactoryImpl()); | 457 new net::URLRequestJobFactoryImpl()); |
465 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 458 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |
466 // Without a network_delegate, this protocol handler will never | 459 // Without a network_delegate, this protocol handler will never |
467 // handle file: requests, but as a side effect it makes | 460 // handle file: requests, but as a side effect it makes |
468 // job_factory::IsHandledProtocol return true, which prevents attempts to | 461 // job_factory::IsHandledProtocol return true, which prevents attempts to |
469 // handle the protocol externally. We pass NULL in to | 462 // handle the protocol externally. We pass NULL in to |
470 // SetUpJobFactory() to get this effect. | 463 // SetUpJobFactory() to get this effect. |
471 extensions_job_factory_ = SetUpJobFactoryDefaults( | 464 extensions_job_factory_ = SetUpJobFactoryDefaults( |
472 extensions_job_factory.Pass(), | 465 extensions_job_factory.Pass(), |
473 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), | 466 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), |
474 NULL, | 467 NULL, |
475 extensions_context->ftp_transaction_factory(), | 468 ftp_factory_.get()); |
476 extensions_context->ftp_auth_cache()); | |
477 extensions_context->set_job_factory(extensions_job_factory_.get()); | 469 extensions_context->set_job_factory(extensions_job_factory_.get()); |
478 } | 470 } |
479 | 471 |
480 ChromeURLRequestContext* | 472 ChromeURLRequestContext* |
481 ProfileImplIOData::InitializeAppRequestContext( | 473 ProfileImplIOData::InitializeAppRequestContext( |
482 ChromeURLRequestContext* main_context, | 474 ChromeURLRequestContext* main_context, |
483 const StoragePartitionDescriptor& partition_descriptor, | 475 const StoragePartitionDescriptor& partition_descriptor, |
484 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 476 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
485 protocol_handler_interceptor, | 477 protocol_handler_interceptor, |
486 content::ProtocolHandlerMap* protocol_handlers) const { | 478 content::ProtocolHandlerMap* protocol_handlers) const { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 InstallProtocolHandlers(job_factory.get(), protocol_handlers); | 546 InstallProtocolHandlers(job_factory.get(), protocol_handlers); |
555 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 547 scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
556 // Overwrite the job factory that we inherit from the main context so | 548 // Overwrite the job factory that we inherit from the main context so |
557 // that we can later provide our own handlers for storage related protocols. | 549 // that we can later provide our own handlers for storage related protocols. |
558 // Install all the usual protocol handlers unless we are in a browser plugin | 550 // Install all the usual protocol handlers unless we are in a browser plugin |
559 // guest process, in which case only web-safe schemes are allowed. | 551 // guest process, in which case only web-safe schemes are allowed. |
560 if (!partition_descriptor.in_memory) { | 552 if (!partition_descriptor.in_memory) { |
561 top_job_factory = SetUpJobFactoryDefaults( | 553 top_job_factory = SetUpJobFactoryDefaults( |
562 job_factory.Pass(), protocol_handler_interceptor.Pass(), | 554 job_factory.Pass(), protocol_handler_interceptor.Pass(), |
563 network_delegate(), | 555 network_delegate(), |
564 context->ftp_transaction_factory(), | 556 ftp_factory_.get()); |
565 context->ftp_auth_cache()); | |
566 } else { | 557 } else { |
567 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); | 558 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); |
568 } | 559 } |
569 context->SetJobFactory(top_job_factory.Pass()); | 560 context->SetJobFactory(top_job_factory.Pass()); |
570 | 561 |
571 return context; | 562 return context; |
572 } | 563 } |
573 | 564 |
574 ChromeURLRequestContext* | 565 ChromeURLRequestContext* |
575 ProfileImplIOData::InitializeMediaRequestContext( | 566 ProfileImplIOData::InitializeMediaRequestContext( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 const base::Closure& completion) { | 653 const base::Closure& completion) { |
663 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 654 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
664 DCHECK(initialized()); | 655 DCHECK(initialized()); |
665 | 656 |
666 DCHECK(transport_security_state()); | 657 DCHECK(transport_security_state()); |
667 // Completes synchronously. | 658 // Completes synchronously. |
668 transport_security_state()->DeleteAllDynamicDataSince(time); | 659 transport_security_state()->DeleteAllDynamicDataSince(time); |
669 DCHECK(http_server_properties_manager_); | 660 DCHECK(http_server_properties_manager_); |
670 http_server_properties_manager_->Clear(completion); | 661 http_server_properties_manager_->Clear(completion); |
671 } | 662 } |
OLD | NEW |