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 23 matching lines...) Expand all Loading... |
34 #include "chrome/browser/policy/url_blacklist_manager.h" | 34 #include "chrome/browser/policy/url_blacklist_manager.h" |
35 #include "chrome/browser/prefs/pref_service.h" | 35 #include "chrome/browser/prefs/pref_service.h" |
36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
38 #include "chrome/browser/transport_security_persister.h" | 38 #include "chrome/browser/transport_security_persister.h" |
39 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 39 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" |
40 #include "chrome/common/chrome_notification_types.h" | 40 #include "chrome/common/chrome_notification_types.h" |
41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
42 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
43 #include "chrome/common/url_constants.h" | 43 #include "chrome/common/url_constants.h" |
44 #include "content/browser/renderer_host/resource_request_info_impl.h" | |
45 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
46 #include "content/public/browser/host_zoom_map.h" | 45 #include "content/public/browser/host_zoom_map.h" |
47 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
48 #include "content/public/browser/resource_context.h" | 47 #include "content/public/browser/resource_context.h" |
49 #include "content/public/browser/resource_dispatcher_host.h" | 48 #include "content/public/browser/resource_dispatcher_host.h" |
50 #include "net/base/server_bound_cert_service.h" | 49 #include "net/base/server_bound_cert_service.h" |
51 #include "net/http/http_transaction_factory.h" | 50 #include "net/http/http_transaction_factory.h" |
52 #include "net/http/http_util.h" | 51 #include "net/http/http_util.h" |
53 #include "net/proxy/proxy_config_service_fixed.h" | 52 #include "net/proxy/proxy_config_service_fixed.h" |
54 #include "net/proxy/proxy_script_fetcher_impl.h" | 53 #include "net/proxy/proxy_script_fetcher_impl.h" |
55 #include "net/proxy/proxy_service.h" | 54 #include "net/proxy/proxy_service.h" |
56 #include "net/url_request/url_request.h" | 55 #include "net/url_request/url_request.h" |
57 #include "webkit/blob/blob_data.h" | |
58 #include "webkit/blob/blob_url_request_job_factory.h" | |
59 #include "webkit/fileapi/file_system_url_request_job_factory.h" | |
60 | 56 |
61 #if defined(OS_CHROMEOS) | 57 #if defined(OS_CHROMEOS) |
62 #include "chrome/browser/chromeos/gview_request_interceptor.h" | 58 #include "chrome/browser/chromeos/gview_request_interceptor.h" |
63 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 59 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
64 #endif // defined(OS_CHROMEOS) | 60 #endif // defined(OS_CHROMEOS) |
65 | 61 |
66 using content::BrowserContext; | 62 using content::BrowserContext; |
67 using content::BrowserThread; | 63 using content::BrowserThread; |
68 using content::ResourceContext; | 64 using content::ResourceContext; |
69 using content::ResourceDispatcherHost; | 65 using content::ResourceDispatcherHost; |
70 using content::ResourceRequestInfoImpl; | |
71 | 66 |
72 namespace { | 67 namespace { |
73 | 68 |
74 // ---------------------------------------------------------------------------- | 69 // ---------------------------------------------------------------------------- |
75 // CookieMonster::Delegate implementation | 70 // CookieMonster::Delegate implementation |
76 // ---------------------------------------------------------------------------- | 71 // ---------------------------------------------------------------------------- |
77 class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { | 72 class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { |
78 public: | 73 public: |
79 explicit ChromeCookieMonsterDelegate( | 74 explicit ChromeCookieMonsterDelegate( |
80 const base::Callback<Profile*(void)>& profile_getter) | 75 const base::Callback<Profile*(void)>& profile_getter) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 net::URLRequest* request) const OVERRIDE { | 137 net::URLRequest* request) const OVERRIDE { |
143 return NULL; | 138 return NULL; |
144 } | 139 } |
145 | 140 |
146 private: | 141 private: |
147 const scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; | 142 const scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_; |
148 | 143 |
149 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistryInterceptor); | 144 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistryInterceptor); |
150 }; | 145 }; |
151 | 146 |
152 // TODO(darin): Move this class to src/content | |
153 class ChromeBlobProtocolHandler : public webkit_blob::BlobProtocolHandler { | |
154 public: | |
155 ChromeBlobProtocolHandler( | |
156 webkit_blob::BlobStorageController* blob_storage_controller, | |
157 base::MessageLoopProxy* loop_proxy) | |
158 : webkit_blob::BlobProtocolHandler(blob_storage_controller, | |
159 loop_proxy) {} | |
160 | |
161 virtual ~ChromeBlobProtocolHandler() {} | |
162 | |
163 private: | |
164 virtual scoped_refptr<webkit_blob::BlobData> | |
165 LookupBlobData(net::URLRequest* request) const { | |
166 const ResourceRequestInfoImpl* info = | |
167 ResourceRequestInfoImpl::ForRequest(request); | |
168 if (!info) | |
169 return NULL; | |
170 return info->requested_blob_data(); | |
171 } | |
172 | |
173 DISALLOW_COPY_AND_ASSIGN(ChromeBlobProtocolHandler); | |
174 }; | |
175 | |
176 Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) { | 147 Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) { |
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
178 DCHECK(profile); | 149 DCHECK(profile); |
179 if (profile_manager->IsValidProfile(profile)) | 150 if (profile_manager->IsValidProfile(profile)) |
180 return profile; | 151 return profile; |
181 return NULL; | 152 return NULL; |
182 } | 153 } |
183 | 154 |
184 } // namespace | 155 } // namespace |
185 | 156 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 profile_params_->protocol_handler_registry)); | 452 profile_params_->protocol_handler_registry)); |
482 } | 453 } |
483 bool set_protocol = job_factory_->SetProtocolHandler( | 454 bool set_protocol = job_factory_->SetProtocolHandler( |
484 chrome::kExtensionScheme, | 455 chrome::kExtensionScheme, |
485 CreateExtensionProtocolHandler(profile_params_->is_incognito, | 456 CreateExtensionProtocolHandler(profile_params_->is_incognito, |
486 profile_params_->extension_info_map)); | 457 profile_params_->extension_info_map)); |
487 DCHECK(set_protocol); | 458 DCHECK(set_protocol); |
488 set_protocol = job_factory_->SetProtocolHandler( | 459 set_protocol = job_factory_->SetProtocolHandler( |
489 chrome::kChromeUIScheme, | 460 chrome::kChromeUIScheme, |
490 ChromeURLDataManagerBackend::CreateProtocolHandler( | 461 ChromeURLDataManagerBackend::CreateProtocolHandler( |
491 chrome_url_data_manager_backend_.get(), | 462 chrome_url_data_manager_backend_.get())); |
492 ResourceContext::GetAppCacheService(&resource_context_), | |
493 ResourceContext::GetBlobStorageController(&resource_context_))); | |
494 DCHECK(set_protocol); | 463 DCHECK(set_protocol); |
495 set_protocol = job_factory_->SetProtocolHandler( | 464 set_protocol = job_factory_->SetProtocolHandler( |
496 chrome::kChromeDevToolsScheme, | 465 chrome::kChromeDevToolsScheme, |
497 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); | 466 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); |
498 DCHECK(set_protocol); | 467 DCHECK(set_protocol); |
499 set_protocol = job_factory_->SetProtocolHandler( | |
500 chrome::kBlobScheme, | |
501 new ChromeBlobProtocolHandler( | |
502 ResourceContext::GetBlobStorageController(&resource_context_), | |
503 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | |
504 DCHECK(set_protocol); | |
505 set_protocol = job_factory_->SetProtocolHandler( | |
506 chrome::kFileSystemScheme, | |
507 CreateFileSystemProtocolHandler( | |
508 ResourceContext::GetFileSystemContext(&resource_context_), | |
509 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | |
510 DCHECK(set_protocol); | |
511 #if defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) | 468 #if defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) |
512 // Install the GView request interceptor that will redirect requests | 469 // Install the GView request interceptor that will redirect requests |
513 // of compatible documents (PDF, etc) to the GView document viewer. | 470 // of compatible documents (PDF, etc) to the GView document viewer. |
514 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 471 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
515 if (parsed_command_line.HasSwitch(switches::kEnableGView)) | 472 if (parsed_command_line.HasSwitch(switches::kEnableGView)) |
516 job_factory_->AddInterceptor(new chromeos::GViewRequestInterceptor); | 473 job_factory_->AddInterceptor(new chromeos::GViewRequestInterceptor); |
517 #endif // defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) | 474 #endif // defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) |
518 | 475 |
519 // Take ownership over these parameters. | 476 // Take ownership over these parameters. |
520 host_content_settings_map_ = profile_params_->host_content_settings_map; | 477 host_content_settings_map_ = profile_params_->host_content_settings_map; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 &resource_context_)); | 519 &resource_context_)); |
563 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 520 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
564 if (!posted) | 521 if (!posted) |
565 delete this; | 522 delete this; |
566 } | 523 } |
567 | 524 |
568 void ProfileIOData::set_server_bound_cert_service( | 525 void ProfileIOData::set_server_bound_cert_service( |
569 net::ServerBoundCertService* server_bound_cert_service) const { | 526 net::ServerBoundCertService* server_bound_cert_service) const { |
570 server_bound_cert_service_.reset(server_bound_cert_service); | 527 server_bound_cert_service_.reset(server_bound_cert_service); |
571 } | 528 } |
OLD | NEW |