OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/net/chrome_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/io_thread.h" | 10 #include "chrome/browser/io_thread.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 : profile_io_data_(profile_io_data) {} | 70 : profile_io_data_(profile_io_data) {} |
71 | 71 |
72 virtual scoped_refptr<ChromeURLRequestContext> Create() { | 72 virtual scoped_refptr<ChromeURLRequestContext> Create() { |
73 return profile_io_data_->GetExtensionsRequestContext(); | 73 return profile_io_data_->GetExtensionsRequestContext(); |
74 } | 74 } |
75 | 75 |
76 private: | 76 private: |
77 const scoped_refptr<const ProfileIOData> profile_io_data_; | 77 const scoped_refptr<const ProfileIOData> profile_io_data_; |
78 }; | 78 }; |
79 | 79 |
80 // Factory that creates the ChromeURLRequestContext for a given isolated app. | |
81 class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { | |
82 public: | |
83 FactoryForIsolatedApp(const ProfileIOData* profile_io_data, | |
84 const Extension* installed_app, | |
85 ChromeURLRequestContextGetter* main_context) | |
86 : profile_io_data_(profile_io_data), | |
87 installed_app_(installed_app), | |
88 main_request_context_getter_(main_context) {} | |
89 | |
90 virtual scoped_refptr<ChromeURLRequestContext> Create() { | |
91 // We will copy most of the state from the main request context. | |
92 return profile_io_data_->GetIsolatedAppRequestContext( | |
93 main_request_context_getter_->GetIOContext(), installed_app_); | |
94 } | |
95 | |
96 private: | |
97 const scoped_refptr<const ProfileIOData> profile_io_data_; | |
98 const scoped_refptr<const Extension> installed_app_; | |
99 scoped_refptr<ChromeURLRequestContextGetter> | |
100 main_request_context_getter_; | |
101 }; | |
102 | |
80 // Factory that creates the ChromeURLRequestContext for media. | 103 // Factory that creates the ChromeURLRequestContext for media. |
81 class FactoryForMedia : public ChromeURLRequestContextFactory { | 104 class FactoryForMedia : public ChromeURLRequestContextFactory { |
82 public: | 105 public: |
83 explicit FactoryForMedia(const ProfileIOData* profile_io_data) | 106 explicit FactoryForMedia(const ProfileIOData* profile_io_data) |
84 : profile_io_data_(profile_io_data) { | 107 : profile_io_data_(profile_io_data) { |
85 } | 108 } |
86 | 109 |
87 virtual scoped_refptr<ChromeURLRequestContext> Create() { | 110 virtual scoped_refptr<ChromeURLRequestContext> Create() { |
88 return profile_io_data_->GetMediaRequestContext(); | 111 return profile_io_data_->GetMediaRequestContext(); |
89 } | 112 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 ChromeURLRequestContextGetter::CreateOriginalForExtensions( | 231 ChromeURLRequestContextGetter::CreateOriginalForExtensions( |
209 Profile* profile, const ProfileIOData* profile_io_data) { | 232 Profile* profile, const ProfileIOData* profile_io_data) { |
210 DCHECK(!profile->IsOffTheRecord()); | 233 DCHECK(!profile->IsOffTheRecord()); |
211 return new ChromeURLRequestContextGetter( | 234 return new ChromeURLRequestContextGetter( |
212 profile, | 235 profile, |
213 new FactoryForExtensions(profile_io_data)); | 236 new FactoryForExtensions(profile_io_data)); |
214 } | 237 } |
215 | 238 |
216 // static | 239 // static |
217 ChromeURLRequestContextGetter* | 240 ChromeURLRequestContextGetter* |
241 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | |
242 Profile* profile, | |
243 const ProfileIOData* profile_io_data, | |
244 const Extension* installed_app) { | |
245 DCHECK(!profile->IsOffTheRecord()); | |
246 ChromeURLRequestContextGetter* main_context = | |
247 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); | |
248 return new ChromeURLRequestContextGetter( | |
249 profile, | |
250 new FactoryForIsolatedApp(profile_io_data, installed_app, main_context)); | |
251 } | |
252 | |
253 // static | |
254 ChromeURLRequestContextGetter* | |
218 ChromeURLRequestContextGetter::CreateOffTheRecord( | 255 ChromeURLRequestContextGetter::CreateOffTheRecord( |
219 Profile* profile, const ProfileIOData* profile_io_data) { | 256 Profile* profile, const ProfileIOData* profile_io_data) { |
220 DCHECK(profile->IsOffTheRecord()); | 257 DCHECK(profile->IsOffTheRecord()); |
221 return new ChromeURLRequestContextGetter( | 258 return new ChromeURLRequestContextGetter( |
222 profile, new FactoryForMain(profile_io_data)); | 259 profile, new FactoryForMain(profile_io_data)); |
223 } | 260 } |
224 | 261 |
225 // static | 262 // static |
226 ChromeURLRequestContextGetter* | 263 ChromeURLRequestContextGetter* |
227 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions( | 264 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions( |
228 Profile* profile, const ProfileIOData* profile_io_data) { | 265 Profile* profile, const ProfileIOData* profile_io_data) { |
229 DCHECK(profile->IsOffTheRecord()); | 266 DCHECK(profile->IsOffTheRecord()); |
230 return new ChromeURLRequestContextGetter( | 267 return new ChromeURLRequestContextGetter( |
231 profile, new FactoryForExtensions(profile_io_data)); | 268 profile, new FactoryForExtensions(profile_io_data)); |
232 } | 269 } |
233 | 270 |
271 // static | |
272 ChromeURLRequestContextGetter* | |
273 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp( | |
274 Profile* profile, | |
275 const ProfileIOData* profile_io_data, | |
276 const Extension* installed_app) { | |
277 DCHECK(profile->IsOffTheRecord()); | |
278 ChromeURLRequestContextGetter* main_context = | |
279 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); | |
280 return new ChromeURLRequestContextGetter( | |
281 profile, | |
282 new FactoryForIsolatedApp(profile_io_data, installed_app, main_context)); | |
283 } | |
284 | |
234 void ChromeURLRequestContextGetter::CleanupOnUIThread() { | 285 void ChromeURLRequestContextGetter::CleanupOnUIThread() { |
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
236 // Unregister for pref notifications. | 287 // Unregister for pref notifications. |
237 DCHECK(!registrar_.IsEmpty()) << "Called more than once!"; | 288 DCHECK(!registrar_.IsEmpty()) << "Called more than once!"; |
238 registrar_.RemoveAll(); | 289 registrar_.RemoveAll(); |
239 } | 290 } |
240 | 291 |
241 // NotificationObserver implementation. | 292 // NotificationObserver implementation. |
242 void ChromeURLRequestContextGetter::Observe( | 293 void ChromeURLRequestContextGetter::Observe( |
243 NotificationType type, | 294 NotificationType type, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 | 368 |
318 // ---------------------------------------------------------------------------- | 369 // ---------------------------------------------------------------------------- |
319 // ChromeURLRequestContext | 370 // ChromeURLRequestContext |
320 // ---------------------------------------------------------------------------- | 371 // ---------------------------------------------------------------------------- |
321 | 372 |
322 ChromeURLRequestContext::ChromeURLRequestContext() | 373 ChromeURLRequestContext::ChromeURLRequestContext() |
323 : is_off_the_record_(false) { | 374 : is_off_the_record_(false) { |
324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
325 } | 376 } |
326 | 377 |
378 void ChromeURLRequestContext::Copy(ChromeURLRequestContext* out) { | |
379 // Copy profile-related parameters. | |
willchan no longer on Chromium
2011/03/03 18:16:59
Where are you getting the ordering for these membe
Charlie Reis
2011/03/04 22:34:53
I got the ordering from ProfileIOData::ApplyProfil
| |
380 out->set_is_off_the_record(is_off_the_record()); | |
381 out->set_accept_language(accept_language()); | |
382 out->set_accept_charset(accept_charset()); | |
383 out->set_referrer_charset(referrer_charset()); | |
384 out->set_user_script_dir_path(user_script_dir_path()); | |
385 out->set_host_content_settings_map(host_content_settings_map()); | |
386 out->set_host_zoom_map(host_zoom_map_); | |
387 out->set_transport_security_state(transport_security_state()); | |
388 out->set_ssl_config_service(ssl_config_service()); | |
389 out->set_database_tracker(database_tracker()); | |
390 out->set_appcache_service(appcache_service()); | |
391 out->set_blob_storage_context(blob_storage_context()); | |
392 out->set_file_system_context(file_system_context()); | |
393 out->set_extension_info_map(extension_info_map_); | |
394 out->set_prerender_manager(prerender_manager()); | |
395 out->set_protocol_handler_registry(protocol_handler_registry_); | |
396 | |
397 out->set_chrome_cookie_policy(chrome_cookie_policy_); | |
398 out->set_net_log(net_log()); | |
399 out->set_network_delegate(network_delegate()); | |
400 out->set_host_resolver(host_resolver()); | |
401 out->set_cert_verifier(cert_verifier()); | |
402 out->set_dnsrr_resolver(dnsrr_resolver()); | |
403 out->set_http_auth_handler_factory(http_auth_handler_factory()); | |
404 out->set_dns_cert_checker(dns_cert_checker()); | |
405 out->set_proxy_service(proxy_service()); | |
406 | |
407 out->set_cookie_store(cookie_store()); | |
408 out->set_cookie_delegate(cookie_delegate()); | |
409 | |
410 out->set_http_transaction_factory(http_transaction_factory()); | |
411 out->set_ftp_transaction_factory(ftp_transaction_factory()); | |
412 } | |
413 | |
327 void ChromeURLRequestContext::set_chrome_cookie_policy( | 414 void ChromeURLRequestContext::set_chrome_cookie_policy( |
328 ChromeCookiePolicy* cookie_policy) { | 415 ChromeCookiePolicy* cookie_policy) { |
329 chrome_cookie_policy_ = cookie_policy; // Take a strong reference. | 416 chrome_cookie_policy_ = cookie_policy; // Take a strong reference. |
330 set_cookie_policy(cookie_policy); | 417 set_cookie_policy(cookie_policy); |
331 } | 418 } |
332 | 419 |
333 ChromeURLDataManagerBackend* | 420 ChromeURLDataManagerBackend* |
334 ChromeURLRequestContext::GetChromeURLDataManagerBackend() { | 421 ChromeURLRequestContext::GetChromeURLDataManagerBackend() { |
335 if (!chrome_url_data_manager_backend_.get()) | 422 if (!chrome_url_data_manager_backend_.get()) |
336 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend()); | 423 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); | 464 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); |
378 } | 465 } |
379 | 466 |
380 void ChromeURLRequestContext::OnDefaultCharsetChange( | 467 void ChromeURLRequestContext::OnDefaultCharsetChange( |
381 const std::string& default_charset) { | 468 const std::string& default_charset) { |
382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 469 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
383 set_referrer_charset(default_charset); | 470 set_referrer_charset(default_charset); |
384 set_accept_charset( | 471 set_accept_charset( |
385 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); | 472 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); |
386 } | 473 } |
OLD | NEW |