| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 new SQLitePersistentCookieStore(cookie_store_path_); | 306 new SQLitePersistentCookieStore(cookie_store_path_); |
| 307 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), | 307 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), |
| 308 cookie_monster_delegate_)); | 308 cookie_monster_delegate_)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 context->set_cookie_policy( | 311 context->set_cookie_policy( |
| 312 new ChromeCookiePolicy(host_content_settings_map_)); | 312 new ChromeCookiePolicy(host_content_settings_map_)); |
| 313 | 313 |
| 314 appcache_service_->set_request_context(context); | 314 appcache_service_->set_request_context(context); |
| 315 | 315 |
| 316 #if defined(USE_NSS) | |
| 317 // TODO(ukai): find a better way to set the URLRequestContext for OCSP. | |
| 318 net::SetURLRequestContextForOCSP(context); | |
| 319 #endif | |
| 320 | |
| 321 context->set_net_log(io_thread_globals->net_log.get()); | 316 context->set_net_log(io_thread_globals->net_log.get()); |
| 322 return context; | 317 return context; |
| 323 } | 318 } |
| 324 | 319 |
| 325 // Factory that creates the ChromeURLRequestContext for extensions. | 320 // Factory that creates the ChromeURLRequestContext for extensions. |
| 326 class FactoryForExtensions : public ChromeURLRequestContextFactory { | 321 class FactoryForExtensions : public ChromeURLRequestContextFactory { |
| 327 public: | 322 public: |
| 328 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, | 323 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, |
| 329 bool incognito) | 324 bool incognito) |
| 330 : ChromeURLRequestContextFactory(profile), | 325 : ChromeURLRequestContextFactory(profile), |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 // |factory_| and |url_request_context_| now. | 545 // |factory_| and |url_request_context_| now. |
| 551 } | 546 } |
| 552 | 547 |
| 553 // Lazily create a ChromeURLRequestContext using our factory. | 548 // Lazily create a ChromeURLRequestContext using our factory. |
| 554 URLRequestContext* ChromeURLRequestContextGetter::GetURLRequestContext() { | 549 URLRequestContext* ChromeURLRequestContextGetter::GetURLRequestContext() { |
| 555 CheckCurrentlyOnIOThread(); | 550 CheckCurrentlyOnIOThread(); |
| 556 | 551 |
| 557 if (!url_request_context_) { | 552 if (!url_request_context_) { |
| 558 DCHECK(factory_.get()); | 553 DCHECK(factory_.get()); |
| 559 url_request_context_ = factory_->Create(); | 554 url_request_context_ = factory_->Create(); |
| 555 if (is_main()) { |
| 556 url_request_context_->set_is_main(true); |
| 557 #if defined(USE_NSS) |
| 558 // TODO(ukai): find a better way to set the URLRequestContext for OCSP. |
| 559 net::SetURLRequestContextForOCSP(url_request_context_); |
| 560 #endif |
| 561 } |
| 562 |
| 560 factory_.reset(); | 563 factory_.reset(); |
| 561 } | 564 } |
| 562 | 565 |
| 563 return url_request_context_; | 566 return url_request_context_; |
| 564 } | 567 } |
| 565 | 568 |
| 566 void ChromeURLRequestContextGetter::RegisterUserPrefs( | 569 void ChromeURLRequestContextGetter::RegisterUserPrefs( |
| 567 PrefService* pref_service) { | 570 PrefService* pref_service) { |
| 568 pref_service->RegisterBooleanPref(prefs::kNoProxyServer, false); | 571 pref_service->RegisterBooleanPref(prefs::kNoProxyServer, false); |
| 569 pref_service->RegisterBooleanPref(prefs::kProxyAutoDetect, false); | 572 pref_service->RegisterBooleanPref(prefs::kProxyAutoDetect, false); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 appcache_service_->set_request_context(NULL); | 767 appcache_service_->set_request_context(NULL); |
| 765 | 768 |
| 766 if (proxy_service_ && | 769 if (proxy_service_ && |
| 767 proxy_service_->GetProxyScriptFetcher() && | 770 proxy_service_->GetProxyScriptFetcher() && |
| 768 proxy_service_->GetProxyScriptFetcher()->GetRequestContext() == this) { | 771 proxy_service_->GetProxyScriptFetcher()->GetRequestContext() == this) { |
| 769 // Remove the ProxyScriptFetcher's weak reference to this context. | 772 // Remove the ProxyScriptFetcher's weak reference to this context. |
| 770 proxy_service_->SetProxyScriptFetcher(NULL); | 773 proxy_service_->SetProxyScriptFetcher(NULL); |
| 771 } | 774 } |
| 772 | 775 |
| 773 #if defined(USE_NSS) | 776 #if defined(USE_NSS) |
| 774 if (this == net::GetURLRequestContextForOCSP()) { | 777 if (is_main()) { |
| 778 DCHECK_EQ(this, net::GetURLRequestContextForOCSP()); |
| 775 // We are releasing the URLRequestContext used by OCSP handlers. | 779 // We are releasing the URLRequestContext used by OCSP handlers. |
| 776 net::SetURLRequestContextForOCSP(NULL); | 780 net::SetURLRequestContextForOCSP(NULL); |
| 777 } | 781 } |
| 778 #endif | 782 #endif |
| 779 | 783 |
| 780 NotificationService::current()->Notify( | 784 NotificationService::current()->Notify( |
| 781 NotificationType::URL_REQUEST_CONTEXT_RELEASED, | 785 NotificationType::URL_REQUEST_CONTEXT_RELEASED, |
| 782 Source<URLRequestContext>(this), | 786 Source<URLRequestContext>(this), |
| 783 NotificationService::NoDetails()); | 787 NotificationService::NoDetails()); |
| 784 | 788 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 prefs::kProxyAutoDetect)); | 1087 prefs::kProxyAutoDetect)); |
| 1084 | 1088 |
| 1085 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { | 1089 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { |
| 1086 std::string proxy_bypass = | 1090 std::string proxy_bypass = |
| 1087 pref_service->GetString(prefs::kProxyBypassList); | 1091 pref_service->GetString(prefs::kProxyBypassList); |
| 1088 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); | 1092 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); |
| 1089 } | 1093 } |
| 1090 | 1094 |
| 1091 return proxy_config; | 1095 return proxy_config; |
| 1092 } | 1096 } |
| OLD | NEW |