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_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 #if defined(ENABLE_NOTIFICATIONS) | 165 #if defined(ENABLE_NOTIFICATIONS) |
166 params->notification_service = | 166 params->notification_service = |
167 DesktopNotificationServiceFactory::GetForProfile(profile); | 167 DesktopNotificationServiceFactory::GetForProfile(profile); |
168 #endif | 168 #endif |
169 | 169 |
170 ProtocolHandlerRegistry* protocol_handler_registry = | 170 ProtocolHandlerRegistry* protocol_handler_registry = |
171 ProtocolHandlerRegistryFactory::GetForProfile(profile); | 171 ProtocolHandlerRegistryFactory::GetForProfile(profile); |
172 DCHECK(protocol_handler_registry); | 172 DCHECK(protocol_handler_registry); |
173 | 173 |
174 // The profile instance is only available here in the InitializeOnUIThread | 174 // The profile instance is only available here in the InitializeOnUIThread |
175 // method, so we create the url interceptor here, then save it for | 175 // method, so we create the url job factory here, then save it for |
176 // later delivery to the job factory in LazyInitialize. | 176 // later delivery to the job factory in LazyInitialize. |
177 params->protocol_handler_interceptor.reset( | 177 params->protocol_handler_interceptor = |
178 protocol_handler_registry->CreateURLInterceptor()); | 178 protocol_handler_registry->CreateURLRequestJobFactory(); |
179 | 179 |
180 ChromeProxyConfigService* proxy_config_service = | 180 ChromeProxyConfigService* proxy_config_service = |
181 ProxyServiceFactory::CreateProxyConfigService(true); | 181 ProxyServiceFactory::CreateProxyConfigService(true); |
182 params->proxy_config_service.reset(proxy_config_service); | 182 params->proxy_config_service.reset(proxy_config_service); |
183 profile->GetProxyConfigTracker()->SetChromeProxyConfigService( | 183 profile->GetProxyConfigTracker()->SetChromeProxyConfigService( |
184 proxy_config_service); | 184 proxy_config_service); |
185 params->profile = profile; | 185 params->profile = profile; |
186 profile_params_.reset(params.release()); | 186 profile_params_.reset(params.release()); |
187 | 187 |
188 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 188 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 ChromeURLRequestContext* | 387 ChromeURLRequestContext* |
388 ProfileIOData::GetExtensionsRequestContext() const { | 388 ProfileIOData::GetExtensionsRequestContext() const { |
389 LazyInitialize(); | 389 LazyInitialize(); |
390 return extensions_request_context_.get(); | 390 return extensions_request_context_.get(); |
391 } | 391 } |
392 | 392 |
393 ChromeURLRequestContext* | 393 ChromeURLRequestContext* |
394 ProfileIOData::GetIsolatedAppRequestContext( | 394 ProfileIOData::GetIsolatedAppRequestContext( |
395 ChromeURLRequestContext* main_context, | 395 ChromeURLRequestContext* main_context, |
396 const StoragePartitionDescriptor& partition_descriptor, | 396 const StoragePartitionDescriptor& partition_descriptor, |
397 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 397 scoped_ptr<ProtocolHandlerRegistry::JobFactory> |
398 protocol_handler_interceptor) const { | 398 protocol_handler_interceptor) const { |
399 LazyInitialize(); | 399 LazyInitialize(); |
400 ChromeURLRequestContext* context = NULL; | 400 ChromeURLRequestContext* context = NULL; |
401 if (ContainsKey(app_request_context_map_, partition_descriptor)) { | 401 if (ContainsKey(app_request_context_map_, partition_descriptor)) { |
402 context = app_request_context_map_[partition_descriptor]; | 402 context = app_request_context_map_[partition_descriptor]; |
403 } else { | 403 } else { |
404 context = AcquireIsolatedAppRequestContext( | 404 context = AcquireIsolatedAppRequestContext( |
405 main_context, partition_descriptor, | 405 main_context, partition_descriptor, |
406 protocol_handler_interceptor.Pass()); | 406 protocol_handler_interceptor.Pass()); |
407 app_request_context_map_[partition_descriptor] = context; | 407 app_request_context_map_[partition_descriptor] = context; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 } | 597 } |
598 | 598 |
599 void ProfileIOData::ApplyProfileParamsToContext( | 599 void ProfileIOData::ApplyProfileParamsToContext( |
600 ChromeURLRequestContext* context) const { | 600 ChromeURLRequestContext* context) const { |
601 context->set_is_incognito(is_incognito()); | 601 context->set_is_incognito(is_incognito()); |
602 context->set_http_user_agent_settings( | 602 context->set_http_user_agent_settings( |
603 chrome_http_user_agent_settings_.get()); | 603 chrome_http_user_agent_settings_.get()); |
604 context->set_ssl_config_service(profile_params_->ssl_config_service); | 604 context->set_ssl_config_service(profile_params_->ssl_config_service); |
605 } | 605 } |
606 | 606 |
607 void ProfileIOData::SetUpJobFactoryDefaults( | 607 scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults( |
608 net::URLRequestJobFactoryImpl* job_factory, | 608 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, |
609 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 609 scoped_ptr<ProtocolHandlerRegistry::JobFactory> |
610 protocol_handler_interceptor, | 610 protocol_handler_interceptor, |
611 net::NetworkDelegate* network_delegate, | 611 net::NetworkDelegate* network_delegate, |
612 net::FtpTransactionFactory* ftp_transaction_factory, | 612 net::FtpTransactionFactory* ftp_transaction_factory, |
613 net::FtpAuthCache* ftp_auth_cache) const { | 613 net::FtpAuthCache* ftp_auth_cache) const { |
614 // NOTE(willchan): Keep these protocol handlers in sync with | 614 // NOTE(willchan): Keep these protocol handlers in sync with |
615 // ProfileIOData::IsHandledProtocol(). | 615 // ProfileIOData::IsHandledProtocol(). |
616 bool set_protocol = job_factory->SetProtocolHandler( | 616 bool set_protocol = job_factory->SetProtocolHandler( |
617 chrome::kFileScheme, new net::FileProtocolHandler()); | 617 chrome::kFileScheme, new net::FileProtocolHandler()); |
618 DCHECK(set_protocol); | 618 DCHECK(set_protocol); |
619 | 619 |
620 set_protocol = job_factory->SetProtocolHandler( | 620 set_protocol = job_factory->SetProtocolHandler( |
621 chrome::kChromeDevToolsScheme, | 621 chrome::kChromeDevToolsScheme, |
622 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend(), | 622 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend(), |
623 network_delegate)); | 623 network_delegate)); |
624 DCHECK(set_protocol); | 624 DCHECK(set_protocol); |
625 | |
626 if (protocol_handler_interceptor.get()) { | |
627 job_factory->AddInterceptor(protocol_handler_interceptor.release()); | |
628 } | |
629 | |
630 set_protocol = job_factory->SetProtocolHandler( | 625 set_protocol = job_factory->SetProtocolHandler( |
631 extensions::kExtensionScheme, | 626 extensions::kExtensionScheme, |
632 CreateExtensionProtocolHandler(is_incognito(), GetExtensionInfoMap())); | 627 CreateExtensionProtocolHandler(is_incognito(), GetExtensionInfoMap())); |
633 DCHECK(set_protocol); | 628 DCHECK(set_protocol); |
634 set_protocol = job_factory->SetProtocolHandler( | 629 set_protocol = job_factory->SetProtocolHandler( |
635 chrome::kExtensionResourceScheme, | 630 chrome::kExtensionResourceScheme, |
636 CreateExtensionResourceProtocolHandler()); | 631 CreateExtensionResourceProtocolHandler()); |
637 DCHECK(set_protocol); | 632 DCHECK(set_protocol); |
638 set_protocol = job_factory->SetProtocolHandler( | 633 set_protocol = job_factory->SetProtocolHandler( |
639 chrome::kChromeUIScheme, | 634 chrome::kChromeUIScheme, |
(...skipping 14 matching lines...) Expand all Loading... | |
654 job_factory->SetProtocolHandler( | 649 job_factory->SetProtocolHandler( |
655 chrome::kAboutScheme, | 650 chrome::kAboutScheme, |
656 new chrome_browser_net::AboutProtocolHandler()); | 651 new chrome_browser_net::AboutProtocolHandler()); |
657 #if !defined(DISABLE_FTP_SUPPORT) | 652 #if !defined(DISABLE_FTP_SUPPORT) |
658 DCHECK(ftp_transaction_factory); | 653 DCHECK(ftp_transaction_factory); |
659 job_factory->SetProtocolHandler( | 654 job_factory->SetProtocolHandler( |
660 chrome::kFtpScheme, | 655 chrome::kFtpScheme, |
661 new net::FtpProtocolHandler(ftp_transaction_factory, | 656 new net::FtpProtocolHandler(ftp_transaction_factory, |
662 ftp_auth_cache)); | 657 ftp_auth_cache)); |
663 #endif // !defined(DISABLE_FTP_SUPPORT) | 658 #endif // !defined(DISABLE_FTP_SUPPORT) |
659 | |
660 if (protocol_handler_interceptor.get()) { | |
661 protocol_handler_interceptor->Chain( | |
erikwright (departed)
2013/01/02 16:29:36
Passing a custom type around, and configuring the
pauljensen
2013/01/02 22:13:35
I agree, I think if this code occurs again we shou
| |
662 job_factory.PassAs<net::URLRequestJobFactory>()); | |
663 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); | |
664 } else { | |
665 return job_factory.PassAs<net::URLRequestJobFactory>(); | |
666 } | |
664 } | 667 } |
665 | 668 |
666 void ProfileIOData::ShutdownOnUIThread() { | 669 void ProfileIOData::ShutdownOnUIThread() { |
667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 670 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
668 | 671 |
669 if (signin_names_) | 672 if (signin_names_) |
670 signin_names_->ReleaseResourcesOnUIThread(); | 673 signin_names_->ReleaseResourcesOnUIThread(); |
671 | 674 |
672 google_services_username_.Destroy(); | 675 google_services_username_.Destroy(); |
673 google_services_username_pattern_.Destroy(); | 676 google_services_username_pattern_.Destroy(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 void ProfileIOData::SetCookieSettingsForTesting( | 731 void ProfileIOData::SetCookieSettingsForTesting( |
729 CookieSettings* cookie_settings) { | 732 CookieSettings* cookie_settings) { |
730 DCHECK(!cookie_settings_.get()); | 733 DCHECK(!cookie_settings_.get()); |
731 cookie_settings_ = cookie_settings; | 734 cookie_settings_ = cookie_settings; |
732 } | 735 } |
733 | 736 |
734 void ProfileIOData::set_signin_names_for_testing( | 737 void ProfileIOData::set_signin_names_for_testing( |
735 SigninNamesOnIOThread* signin_names) { | 738 SigninNamesOnIOThread* signin_names) { |
736 signin_names_.reset(signin_names); | 739 signin_names_.reset(signin_names); |
737 } | 740 } |
OLD | NEW |