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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 main_cache->set_mode( | 430 main_cache->set_mode( |
431 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 431 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
432 } | 432 } |
433 | 433 |
434 main_http_factory_.reset(main_cache); | 434 main_http_factory_.reset(main_cache); |
435 main_context->set_http_transaction_factory(main_cache); | 435 main_context->set_http_transaction_factory(main_cache); |
436 | 436 |
437 #if !defined(DISABLE_FTP_SUPPORT) | 437 #if !defined(DISABLE_FTP_SUPPORT) |
438 ftp_factory_.reset( | 438 ftp_factory_.reset( |
439 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 439 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
440 main_context->set_ftp_transaction_factory(ftp_factory_.get()); | |
441 #endif // !defined(DISABLE_FTP_SUPPORT) | 440 #endif // !defined(DISABLE_FTP_SUPPORT) |
442 | 441 |
443 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 442 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
444 new net::URLRequestJobFactoryImpl()); | 443 new net::URLRequestJobFactoryImpl()); |
445 bool set_protocol = main_job_factory->SetProtocolHandler( | 444 bool set_protocol = main_job_factory->SetProtocolHandler( |
446 chrome::kBlobScheme, blob_protocol_handler.release()); | 445 chrome::kBlobScheme, blob_protocol_handler.release()); |
447 DCHECK(set_protocol); | 446 DCHECK(set_protocol); |
448 set_protocol = main_job_factory->SetProtocolHandler( | 447 set_protocol = main_job_factory->SetProtocolHandler( |
449 chrome::kFileSystemScheme, file_system_protocol_handler.release()); | 448 chrome::kFileSystemScheme, file_system_protocol_handler.release()); |
450 DCHECK(set_protocol); | 449 DCHECK(set_protocol); |
451 set_protocol = main_job_factory->SetProtocolHandler( | 450 set_protocol = main_job_factory->SetProtocolHandler( |
452 chrome::kChromeUIScheme, chrome_protocol_handler.release()); | 451 chrome::kChromeUIScheme, chrome_protocol_handler.release()); |
453 DCHECK(set_protocol); | 452 DCHECK(set_protocol); |
454 set_protocol = main_job_factory->SetProtocolHandler( | 453 set_protocol = main_job_factory->SetProtocolHandler( |
455 chrome::kChromeDevToolsScheme, | 454 chrome::kChromeDevToolsScheme, |
456 chrome_devtools_protocol_handler.release()); | 455 chrome_devtools_protocol_handler.release()); |
457 DCHECK(set_protocol); | 456 DCHECK(set_protocol); |
458 main_job_factory_ = SetUpJobFactoryDefaults( | 457 main_job_factory_ = SetUpJobFactoryDefaults( |
459 main_job_factory.Pass(), | 458 main_job_factory.Pass(), |
460 profile_params->protocol_handler_interceptor.Pass(), | 459 profile_params->protocol_handler_interceptor.Pass(), |
461 network_delegate(), | 460 network_delegate(), |
462 main_context->ftp_transaction_factory(), | 461 ftp_factory_.get()); |
463 main_context->ftp_auth_cache()); | |
464 main_job_factory_.reset(new net::ProtocolInterceptJobFactory( | 462 main_job_factory_.reset(new net::ProtocolInterceptJobFactory( |
465 main_job_factory_.Pass(), developer_protocol_handler.Pass())); | 463 main_job_factory_.Pass(), developer_protocol_handler.Pass())); |
466 main_context->set_job_factory(main_job_factory_.get()); | 464 main_context->set_job_factory(main_job_factory_.get()); |
467 | 465 |
468 #if defined(ENABLE_EXTENSIONS) | 466 #if defined(ENABLE_EXTENSIONS) |
469 InitializeExtensionsRequestContext(profile_params); | 467 InitializeExtensionsRequestContext(profile_params); |
470 #endif | 468 #endif |
471 | 469 |
472 // Create a media request context based on the main context, but using a | 470 // Create a media request context based on the main context, but using a |
473 // media cache. It shares the same job factory as the main context. | 471 // media cache. It shares the same job factory as the main context. |
(...skipping 22 matching lines...) Expand all Loading... |
496 new net::CookieMonster( | 494 new net::CookieMonster( |
497 new SQLitePersistentCookieStore( | 495 new SQLitePersistentCookieStore( |
498 lazy_params_->extensions_cookie_path, | 496 lazy_params_->extensions_cookie_path, |
499 lazy_params_->restore_old_session_cookies, NULL), NULL); | 497 lazy_params_->restore_old_session_cookies, NULL), NULL); |
500 // Enable cookies for devtools and extension URLs. | 498 // Enable cookies for devtools and extension URLs. |
501 const char* schemes[] = {chrome::kChromeDevToolsScheme, | 499 const char* schemes[] = {chrome::kChromeDevToolsScheme, |
502 extensions::kExtensionScheme}; | 500 extensions::kExtensionScheme}; |
503 extensions_cookie_store->SetCookieableSchemes(schemes, 2); | 501 extensions_cookie_store->SetCookieableSchemes(schemes, 2); |
504 extensions_context->set_cookie_store(extensions_cookie_store); | 502 extensions_context->set_cookie_store(extensions_cookie_store); |
505 | 503 |
506 #if !defined(DISABLE_FTP_SUPPORT) | |
507 DCHECK(ftp_factory_.get()); | |
508 extensions_context->set_ftp_transaction_factory(ftp_factory_.get()); | |
509 #endif // !defined(DISABLE_FTP_SUPPORT) | |
510 | |
511 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( | 504 scoped_ptr<net::URLRequestJobFactoryImpl> extensions_job_factory( |
512 new net::URLRequestJobFactoryImpl()); | 505 new net::URLRequestJobFactoryImpl()); |
513 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. | 506 // TODO(shalev): The extensions_job_factory has a NULL NetworkDelegate. |
514 // Without a network_delegate, this protocol handler will never | 507 // Without a network_delegate, this protocol handler will never |
515 // handle file: requests, but as a side effect it makes | 508 // handle file: requests, but as a side effect it makes |
516 // job_factory::IsHandledProtocol return true, which prevents attempts to | 509 // job_factory::IsHandledProtocol return true, which prevents attempts to |
517 // handle the protocol externally. We pass NULL in to | 510 // handle the protocol externally. We pass NULL in to |
518 // SetUpJobFactory() to get this effect. | 511 // SetUpJobFactory() to get this effect. |
519 extensions_job_factory_ = SetUpJobFactoryDefaults( | 512 extensions_job_factory_ = SetUpJobFactoryDefaults( |
520 extensions_job_factory.Pass(), | 513 extensions_job_factory.Pass(), |
521 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), | 514 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>(NULL), |
522 NULL, | 515 NULL, |
523 extensions_context->ftp_transaction_factory(), | 516 ftp_factory_.get()); |
524 extensions_context->ftp_auth_cache()); | |
525 extensions_context->set_job_factory(extensions_job_factory_.get()); | 517 extensions_context->set_job_factory(extensions_job_factory_.get()); |
526 } | 518 } |
527 | 519 |
528 ChromeURLRequestContext* | 520 ChromeURLRequestContext* |
529 ProfileImplIOData::InitializeAppRequestContext( | 521 ProfileImplIOData::InitializeAppRequestContext( |
530 ChromeURLRequestContext* main_context, | 522 ChromeURLRequestContext* main_context, |
531 const StoragePartitionDescriptor& partition_descriptor, | 523 const StoragePartitionDescriptor& partition_descriptor, |
532 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 524 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
533 protocol_handler_interceptor, | 525 protocol_handler_interceptor, |
534 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 526 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 DCHECK(set_protocol); | 613 DCHECK(set_protocol); |
622 scoped_ptr<net::URLRequestJobFactory> top_job_factory; | 614 scoped_ptr<net::URLRequestJobFactory> top_job_factory; |
623 // Overwrite the job factory that we inherit from the main context so | 615 // Overwrite the job factory that we inherit from the main context so |
624 // that we can later provide our own handlers for storage related protocols. | 616 // that we can later provide our own handlers for storage related protocols. |
625 // Install all the usual protocol handlers unless we are in a browser plugin | 617 // Install all the usual protocol handlers unless we are in a browser plugin |
626 // guest process, in which case only web-safe schemes are allowed. | 618 // guest process, in which case only web-safe schemes are allowed. |
627 if (!partition_descriptor.in_memory) { | 619 if (!partition_descriptor.in_memory) { |
628 top_job_factory = SetUpJobFactoryDefaults( | 620 top_job_factory = SetUpJobFactoryDefaults( |
629 job_factory.Pass(), protocol_handler_interceptor.Pass(), | 621 job_factory.Pass(), protocol_handler_interceptor.Pass(), |
630 network_delegate(), | 622 network_delegate(), |
631 context->ftp_transaction_factory(), | 623 ftp_factory_.get()); |
632 context->ftp_auth_cache()); | |
633 } else { | 624 } else { |
634 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); | 625 top_job_factory = job_factory.PassAs<net::URLRequestJobFactory>(); |
635 } | 626 } |
636 top_job_factory.reset(new net::ProtocolInterceptJobFactory( | 627 top_job_factory.reset(new net::ProtocolInterceptJobFactory( |
637 top_job_factory.Pass(), developer_protocol_handler.Pass())); | 628 top_job_factory.Pass(), developer_protocol_handler.Pass())); |
638 context->SetJobFactory(top_job_factory.Pass()); | 629 context->SetJobFactory(top_job_factory.Pass()); |
639 | 630 |
640 return context; | 631 return context; |
641 } | 632 } |
642 | 633 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 base::Time time, | 734 base::Time time, |
744 const base::Closure& completion) { | 735 const base::Closure& completion) { |
745 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
746 DCHECK(initialized()); | 737 DCHECK(initialized()); |
747 | 738 |
748 DCHECK(transport_security_state()); | 739 DCHECK(transport_security_state()); |
749 transport_security_state()->DeleteSince(time); // Completes synchronously. | 740 transport_security_state()->DeleteSince(time); // Completes synchronously. |
750 DCHECK(http_server_properties_manager_); | 741 DCHECK(http_server_properties_manager_); |
751 http_server_properties_manager_->Clear(completion); | 742 http_server_properties_manager_->Clear(completion); |
752 } | 743 } |
OLD | NEW |