Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 10546083: Convert ProtocolHandlerRegistry to be a ProfileKeyedService. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix merge issue (correctly) in PHR test. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/content_settings/cookie_settings.h" 20 #include "chrome/browser/content_settings/cookie_settings.h"
21 #include "chrome/browser/content_settings/host_content_settings_map.h" 21 #include "chrome/browser/content_settings/host_content_settings_map.h"
22 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 22 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
23 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
23 #include "chrome/browser/download/download_service.h" 24 #include "chrome/browser/download/download_service.h"
24 #include "chrome/browser/download/download_service_factory.h" 25 #include "chrome/browser/download/download_service_factory.h"
25 #include "chrome/browser/extensions/extension_info_map.h" 26 #include "chrome/browser/extensions/extension_info_map.h"
26 #include "chrome/browser/extensions/extension_protocols.h" 27 #include "chrome/browser/extensions/extension_protocols.h"
27 #include "chrome/browser/extensions/extension_resource_protocols.h" 28 #include "chrome/browser/extensions/extension_resource_protocols.h"
28 #include "chrome/browser/extensions/extension_system.h" 29 #include "chrome/browser/extensions/extension_system.h"
29 #include "chrome/browser/io_thread.h" 30 #include "chrome/browser/io_thread.h"
30 #include "chrome/browser/net/chrome_cookie_notification_details.h" 31 #include "chrome/browser/net/chrome_cookie_notification_details.h"
31 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" 32 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
32 #include "chrome/browser/net/chrome_net_log.h" 33 #include "chrome/browser/net/chrome_net_log.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 content::NotificationService::current()->Notify( 106 content::NotificationService::current()->Notify(
106 chrome::NOTIFICATION_COOKIE_CHANGED, 107 chrome::NOTIFICATION_COOKIE_CHANGED,
107 content::Source<Profile>(profile), 108 content::Source<Profile>(profile),
108 content::Details<ChromeCookieDetails>(&cookie_details)); 109 content::Details<ChromeCookieDetails>(&cookie_details));
109 } 110 }
110 } 111 }
111 112
112 const base::Callback<Profile*(void)> profile_getter_; 113 const base::Callback<Profile*(void)> profile_getter_;
113 }; 114 };
114 115
115 class ProtocolHandlerRegistryInterceptor
116 : public net::URLRequestJobFactory::Interceptor {
117 public:
118 explicit ProtocolHandlerRegistryInterceptor(
119 ProtocolHandlerRegistry* protocol_handler_registry)
120 : protocol_handler_registry_(protocol_handler_registry) {
121 DCHECK(protocol_handler_registry_);
122 }
123
124 virtual ~ProtocolHandlerRegistryInterceptor() {}
125
126 virtual net::URLRequestJob* MaybeIntercept(
127 net::URLRequest* request) const OVERRIDE {
128 return protocol_handler_registry_->MaybeCreateJob(request);
129 }
130
131 virtual bool WillHandleProtocol(const std::string& protocol) const {
132 return protocol_handler_registry_->IsHandledProtocolIO(protocol);
133 }
134
135 virtual net::URLRequestJob* MaybeInterceptRedirect(
136 const GURL& url, net::URLRequest* request) const OVERRIDE {
137 return NULL;
138 }
139
140 virtual net::URLRequestJob* MaybeInterceptResponse(
141 net::URLRequest* request) const OVERRIDE {
142 return NULL;
143 }
144
145 private:
146 const scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_;
147
148 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistryInterceptor);
149 };
150
151 Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) { 116 Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) {
152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
153 DCHECK(profile); 118 DCHECK(profile);
154 if (profile_manager->IsValidProfile(profile)) 119 if (profile_manager->IsValidProfile(profile))
155 return profile; 120 return profile;
156 return NULL; 121 return NULL;
157 } 122 }
158 123
159 } // namespace 124 } // namespace
160 125
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 params->cookie_monster_delegate = 161 params->cookie_monster_delegate =
197 new ChromeCookieMonsterDelegate(profile_getter); 162 new ChromeCookieMonsterDelegate(profile_getter);
198 params->extension_info_map = 163 params->extension_info_map =
199 ExtensionSystem::Get(profile)->info_map(); 164 ExtensionSystem::Get(profile)->info_map();
200 165
201 #if defined(ENABLE_NOTIFICATIONS) 166 #if defined(ENABLE_NOTIFICATIONS)
202 params->notification_service = 167 params->notification_service =
203 DesktopNotificationServiceFactory::GetForProfile(profile); 168 DesktopNotificationServiceFactory::GetForProfile(profile);
204 #endif 169 #endif
205 170
206 params->protocol_handler_registry = profile->GetProtocolHandlerRegistry(); 171 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.
172 ProtocolHandlerRegistryFactory::GetForProfile(profile);
173 DCHECK(proto_handlers);
174
175 // the profile instance is only available here in the InitializeOnUIThread
176 // method, so we create the url interceptor here, then save it for
177 // later delivery to the job factory in LazyInitialize
178 params->protocol_handler_url_interceptor =
179 proto_handlers->CreateIOURLInterceptor();
207 180
208 ChromeProxyConfigService* proxy_config_service = 181 ChromeProxyConfigService* proxy_config_service =
209 ProxyServiceFactory::CreateProxyConfigService(true); 182 ProxyServiceFactory::CreateProxyConfigService(true);
210 params->proxy_config_service.reset(proxy_config_service); 183 params->proxy_config_service.reset(proxy_config_service);
211 profile->GetProxyConfigTracker()->SetChromeProxyConfigService( 184 profile->GetProxyConfigTracker()->SetChromeProxyConfigService(
212 proxy_config_service); 185 proxy_config_service);
213 params->profile = profile; 186 params->profile = profile;
214 profile_params_.reset(params.release()); 187 profile_params_.reset(params.release());
215 188
216 // The URLBlacklistManager has to be created on the UI thread to register 189 // The URLBlacklistManager has to be created on the UI thread to register
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 new TransportSecurityPersister(transport_security_state_.get(), 468 new TransportSecurityPersister(transport_security_state_.get(),
496 profile_params_->path, 469 profile_params_->path,
497 is_incognito())); 470 is_incognito()));
498 const std::string& serialized = 471 const std::string& serialized =
499 command_line.GetSwitchValueASCII(switches::kHstsHosts); 472 command_line.GetSwitchValueASCII(switches::kHstsHosts);
500 transport_security_persister_.get()->DeserializeFromCommandLine(serialized); 473 transport_security_persister_.get()->DeserializeFromCommandLine(serialized);
501 474
502 // NOTE(willchan): Keep these protocol handlers in sync with 475 // NOTE(willchan): Keep these protocol handlers in sync with
503 // ProfileIOData::IsHandledProtocol(). 476 // ProfileIOData::IsHandledProtocol().
504 job_factory_.reset(new net::URLRequestJobFactory); 477 job_factory_.reset(new net::URLRequestJobFactory);
505 if (profile_params_->protocol_handler_registry) { 478 if (profile_params_->protocol_handler_url_interceptor) {
506 job_factory_->AddInterceptor( 479 job_factory_->AddInterceptor(
507 new ProtocolHandlerRegistryInterceptor( 480 profile_params_->protocol_handler_url_interceptor);
508 profile_params_->protocol_handler_registry));
509 } 481 }
510 bool set_protocol = job_factory_->SetProtocolHandler( 482 bool set_protocol = job_factory_->SetProtocolHandler(
511 chrome::kExtensionScheme, 483 chrome::kExtensionScheme,
512 CreateExtensionProtocolHandler(is_incognito(), 484 CreateExtensionProtocolHandler(is_incognito(),
513 profile_params_->extension_info_map)); 485 profile_params_->extension_info_map));
514 DCHECK(set_protocol); 486 DCHECK(set_protocol);
515 set_protocol = job_factory_->SetProtocolHandler( 487 set_protocol = job_factory_->SetProtocolHandler(
516 chrome::kExtensionResourceScheme, 488 chrome::kExtensionResourceScheme,
517 CreateExtensionResourceProtocolHandler()); 489 CreateExtensionResourceProtocolHandler());
518 DCHECK(set_protocol); 490 DCHECK(set_protocol);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } 555 }
584 556
585 void ProfileIOData::set_server_bound_cert_service( 557 void ProfileIOData::set_server_bound_cert_service(
586 net::ServerBoundCertService* server_bound_cert_service) const { 558 net::ServerBoundCertService* server_bound_cert_service) const {
587 server_bound_cert_service_.reset(server_bound_cert_service); 559 server_bound_cert_service_.reset(server_bound_cert_service);
588 } 560 }
589 561
590 void ProfileIOData::DestroyResourceContext() { 562 void ProfileIOData::DestroyResourceContext() {
591 resource_context_.reset(); 563 resource_context_.reset();
592 } 564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698