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 |
316 context->set_net_log(io_thread_globals->net_log.get()); | 321 context->set_net_log(io_thread_globals->net_log.get()); |
317 return context; | 322 return context; |
318 } | 323 } |
319 | 324 |
320 // Factory that creates the ChromeURLRequestContext for extensions. | 325 // Factory that creates the ChromeURLRequestContext for extensions. |
321 class FactoryForExtensions : public ChromeURLRequestContextFactory { | 326 class FactoryForExtensions : public ChromeURLRequestContextFactory { |
322 public: | 327 public: |
323 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, | 328 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, |
324 bool incognito) | 329 bool incognito) |
325 : ChromeURLRequestContextFactory(profile), | 330 : ChromeURLRequestContextFactory(profile), |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 // |factory_| and |url_request_context_| now. | 550 // |factory_| and |url_request_context_| now. |
546 } | 551 } |
547 | 552 |
548 // Lazily create a ChromeURLRequestContext using our factory. | 553 // Lazily create a ChromeURLRequestContext using our factory. |
549 URLRequestContext* ChromeURLRequestContextGetter::GetURLRequestContext() { | 554 URLRequestContext* ChromeURLRequestContextGetter::GetURLRequestContext() { |
550 CheckCurrentlyOnIOThread(); | 555 CheckCurrentlyOnIOThread(); |
551 | 556 |
552 if (!url_request_context_) { | 557 if (!url_request_context_) { |
553 DCHECK(factory_.get()); | 558 DCHECK(factory_.get()); |
554 url_request_context_ = factory_->Create(); | 559 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 | |
563 factory_.reset(); | 560 factory_.reset(); |
564 } | 561 } |
565 | 562 |
566 return url_request_context_; | 563 return url_request_context_; |
567 } | 564 } |
568 | 565 |
569 void ChromeURLRequestContextGetter::RegisterUserPrefs( | 566 void ChromeURLRequestContextGetter::RegisterUserPrefs( |
570 PrefService* pref_service) { | 567 PrefService* pref_service) { |
571 pref_service->RegisterBooleanPref(prefs::kNoProxyServer, false); | 568 pref_service->RegisterBooleanPref(prefs::kNoProxyServer, false); |
572 pref_service->RegisterBooleanPref(prefs::kProxyAutoDetect, false); | 569 pref_service->RegisterBooleanPref(prefs::kProxyAutoDetect, false); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 appcache_service_->set_request_context(NULL); | 764 appcache_service_->set_request_context(NULL); |
768 | 765 |
769 if (proxy_service_ && | 766 if (proxy_service_ && |
770 proxy_service_->GetProxyScriptFetcher() && | 767 proxy_service_->GetProxyScriptFetcher() && |
771 proxy_service_->GetProxyScriptFetcher()->GetRequestContext() == this) { | 768 proxy_service_->GetProxyScriptFetcher()->GetRequestContext() == this) { |
772 // Remove the ProxyScriptFetcher's weak reference to this context. | 769 // Remove the ProxyScriptFetcher's weak reference to this context. |
773 proxy_service_->SetProxyScriptFetcher(NULL); | 770 proxy_service_->SetProxyScriptFetcher(NULL); |
774 } | 771 } |
775 | 772 |
776 #if defined(USE_NSS) | 773 #if defined(USE_NSS) |
777 if (is_main()) { | 774 if (this == net::GetURLRequestContextForOCSP()) { |
778 DCHECK_EQ(this, net::GetURLRequestContextForOCSP()); | |
779 // We are releasing the URLRequestContext used by OCSP handlers. | 775 // We are releasing the URLRequestContext used by OCSP handlers. |
780 net::SetURLRequestContextForOCSP(NULL); | 776 net::SetURLRequestContextForOCSP(NULL); |
781 } | 777 } |
782 #endif | 778 #endif |
783 | 779 |
784 NotificationService::current()->Notify( | 780 NotificationService::current()->Notify( |
785 NotificationType::URL_REQUEST_CONTEXT_RELEASED, | 781 NotificationType::URL_REQUEST_CONTEXT_RELEASED, |
786 Source<URLRequestContext>(this), | 782 Source<URLRequestContext>(this), |
787 NotificationService::NoDetails()); | 783 NotificationService::NoDetails()); |
788 | 784 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 prefs::kProxyAutoDetect)); | 1104 prefs::kProxyAutoDetect)); |
1109 | 1105 |
1110 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { | 1106 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { |
1111 std::string proxy_bypass = | 1107 std::string proxy_bypass = |
1112 pref_service->GetString(prefs::kProxyBypassList); | 1108 pref_service->GetString(prefs::kProxyBypassList); |
1113 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); | 1109 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); |
1114 } | 1110 } |
1115 | 1111 |
1116 return proxy_config; | 1112 return proxy_config; |
1117 } | 1113 } |
OLD | NEW |