Chromium Code Reviews| Index: chrome/browser/profiles/profile_io_data.cc |
| diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc |
| index 6881c225d4b07596013457c40d031c35e88d97bf..e1ef0109a64a1a1a7b3e347d2e00ebc5182cbb9b 100644 |
| --- a/chrome/browser/profiles/profile_io_data.cc |
| +++ b/chrome/browser/profiles/profile_io_data.cc |
| @@ -20,6 +20,7 @@ |
| #include "chrome/browser/content_settings/cookie_settings.h" |
| #include "chrome/browser/content_settings/host_content_settings_map.h" |
| #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| +#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| #include "chrome/browser/download/download_service.h" |
| #include "chrome/browser/download/download_service_factory.h" |
| #include "chrome/browser/extensions/extension_info_map.h" |
| @@ -112,42 +113,6 @@ class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { |
| const base::Callback<Profile*(void)> profile_getter_; |
| }; |
| -class ProtocolHandlerRegistryInterceptor |
| - : public net::URLRequestJobFactory::Interceptor { |
| - public: |
| - explicit ProtocolHandlerRegistryInterceptor( |
| - ProtocolHandlerRegistry* protocol_handler_registry) |
| - : protocol_handler_registry_(protocol_handler_registry) { |
| - DCHECK(protocol_handler_registry_); |
| - } |
| - |
| - virtual ~ProtocolHandlerRegistryInterceptor() {} |
| - |
| - virtual net::URLRequestJob* MaybeIntercept( |
| - net::URLRequest* request) const OVERRIDE { |
| - return protocol_handler_registry_->MaybeCreateJob(request); |
| - } |
| - |
| - virtual bool WillHandleProtocol(const std::string& protocol) const { |
| - return protocol_handler_registry_->IsHandledProtocolIO(protocol); |
| - } |
| - |
| - virtual net::URLRequestJob* MaybeInterceptRedirect( |
| - const GURL& url, net::URLRequest* request) const OVERRIDE { |
| - return NULL; |
| - } |
| - |
| - virtual net::URLRequestJob* MaybeInterceptResponse( |
| - net::URLRequest* request) const OVERRIDE { |
| - return NULL; |
| - } |
| - |
| - private: |
| - const scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistryInterceptor); |
| -}; |
| - |
| Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| DCHECK(profile); |
| @@ -203,7 +168,15 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
| DesktopNotificationServiceFactory::GetForProfile(profile); |
| #endif |
| - params->protocol_handler_registry = profile->GetProtocolHandlerRegistry(); |
| + ProtocolHandlerRegistry* proto_handlers = |
|
willchan no longer on Chromium
2012/06/22 23:15:44
The style guide discourages abbreviations. Please
smckay
2012/06/22 23:44:31
Done.
|
| + ProtocolHandlerRegistryFactory::GetForProfile(profile); |
| + DCHECK(proto_handlers); |
| + |
| + // the profile instance is only available here in the InitializeOnUIThread |
| + // method, so we create the url interceptor here, then save it for |
| + // later delivery to the job factory in LazyInitialize |
| + params->protocol_handler_url_interceptor = |
| + proto_handlers->CreateIOURLInterceptor(); |
| ChromeProxyConfigService* proxy_config_service = |
| ProxyServiceFactory::CreateProxyConfigService(true); |
| @@ -502,10 +475,9 @@ void ProfileIOData::LazyInitialize() const { |
| // NOTE(willchan): Keep these protocol handlers in sync with |
| // ProfileIOData::IsHandledProtocol(). |
| job_factory_.reset(new net::URLRequestJobFactory); |
| - if (profile_params_->protocol_handler_registry) { |
| + if (profile_params_->protocol_handler_url_interceptor) { |
| job_factory_->AddInterceptor( |
| - new ProtocolHandlerRegistryInterceptor( |
| - profile_params_->protocol_handler_registry)); |
| + profile_params_->protocol_handler_url_interceptor); |
| } |
| bool set_protocol = job_factory_->SetProtocolHandler( |
| chrome::kExtensionScheme, |