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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 new SQLitePersistentCookieStore(cookie_store_path_); | 307 new SQLitePersistentCookieStore(cookie_store_path_); |
308 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), | 308 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), |
309 cookie_monster_delegate_)); | 309 cookie_monster_delegate_)); |
310 } | 310 } |
311 | 311 |
312 context->set_cookie_policy( | 312 context->set_cookie_policy( |
313 new ChromeCookiePolicy(host_content_settings_map_)); | 313 new ChromeCookiePolicy(host_content_settings_map_)); |
314 | 314 |
315 appcache_service_->set_request_context(context); | 315 appcache_service_->set_request_context(context); |
316 | 316 |
317 #if defined(USE_NSS) | |
318 // TODO(ukai): find a better way to set the URLRequestContext for OCSP. | |
319 net::SetURLRequestContextForOCSP(context); | |
320 #endif | |
321 | |
322 context->set_net_log(io_thread_globals->net_log.get()); | 317 context->set_net_log(io_thread_globals->net_log.get()); |
323 return context; | 318 return context; |
324 } | 319 } |
325 | 320 |
326 // Factory that creates the ChromeURLRequestContext for extensions. | 321 // Factory that creates the ChromeURLRequestContext for extensions. |
327 class FactoryForExtensions : public ChromeURLRequestContextFactory { | 322 class FactoryForExtensions : public ChromeURLRequestContextFactory { |
328 public: | 323 public: |
329 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, | 324 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, |
330 bool incognito) | 325 bool incognito) |
331 : ChromeURLRequestContextFactory(profile), | 326 : ChromeURLRequestContextFactory(profile), |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // |factory_| and |url_request_context_| now. | 547 // |factory_| and |url_request_context_| now. |
553 } | 548 } |
554 | 549 |
555 // Lazily create a ChromeURLRequestContext using our factory. | 550 // Lazily create a ChromeURLRequestContext using our factory. |
556 URLRequestContext* ChromeURLRequestContextGetter::GetURLRequestContext() { | 551 URLRequestContext* ChromeURLRequestContextGetter::GetURLRequestContext() { |
557 CheckCurrentlyOnIOThread(); | 552 CheckCurrentlyOnIOThread(); |
558 | 553 |
559 if (!url_request_context_) { | 554 if (!url_request_context_) { |
560 DCHECK(factory_.get()); | 555 DCHECK(factory_.get()); |
561 url_request_context_ = factory_->Create(); | 556 url_request_context_ = factory_->Create(); |
| 557 if (is_main()) { |
| 558 url_request_context_->set_is_main(true); |
| 559 #if defined(USE_NSS) |
| 560 // TODO(ukai): find a better way to set the URLRequestContext for OCSP. |
| 561 net::SetURLRequestContextForOCSP(url_request_context_); |
| 562 #endif |
| 563 } |
| 564 |
562 factory_.reset(); | 565 factory_.reset(); |
563 } | 566 } |
564 | 567 |
565 return url_request_context_; | 568 return url_request_context_; |
566 } | 569 } |
567 | 570 |
568 void ChromeURLRequestContextGetter::RegisterUserPrefs( | 571 void ChromeURLRequestContextGetter::RegisterUserPrefs( |
569 PrefService* pref_service) { | 572 PrefService* pref_service) { |
570 pref_service->RegisterBooleanPref(prefs::kNoProxyServer, false); | 573 pref_service->RegisterBooleanPref(prefs::kNoProxyServer, false); |
571 pref_service->RegisterBooleanPref(prefs::kProxyAutoDetect, false); | 574 pref_service->RegisterBooleanPref(prefs::kProxyAutoDetect, false); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 appcache_service_->set_request_context(NULL); | 752 appcache_service_->set_request_context(NULL); |
750 | 753 |
751 if (proxy_service_ && | 754 if (proxy_service_ && |
752 proxy_service_->GetProxyScriptFetcher() && | 755 proxy_service_->GetProxyScriptFetcher() && |
753 proxy_service_->GetProxyScriptFetcher()->GetRequestContext() == this) { | 756 proxy_service_->GetProxyScriptFetcher()->GetRequestContext() == this) { |
754 // Remove the ProxyScriptFetcher's weak reference to this context. | 757 // Remove the ProxyScriptFetcher's weak reference to this context. |
755 proxy_service_->SetProxyScriptFetcher(NULL); | 758 proxy_service_->SetProxyScriptFetcher(NULL); |
756 } | 759 } |
757 | 760 |
758 #if defined(USE_NSS) | 761 #if defined(USE_NSS) |
759 if (this == net::GetURLRequestContextForOCSP()) { | 762 if (is_main()) { |
| 763 DCHECK_EQ(this, net::GetURLRequestContextForOCSP()); |
760 // We are releasing the URLRequestContext used by OCSP handlers. | 764 // We are releasing the URLRequestContext used by OCSP handlers. |
761 net::SetURLRequestContextForOCSP(NULL); | 765 net::SetURLRequestContextForOCSP(NULL); |
762 } | 766 } |
763 #endif | 767 #endif |
764 | 768 |
765 NotificationService::current()->Notify( | 769 NotificationService::current()->Notify( |
766 NotificationType::URL_REQUEST_CONTEXT_RELEASED, | 770 NotificationType::URL_REQUEST_CONTEXT_RELEASED, |
767 Source<URLRequestContext>(this), | 771 Source<URLRequestContext>(this), |
768 NotificationService::NoDetails()); | 772 NotificationService::NoDetails()); |
769 | 773 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 prefs::kProxyAutoDetect)); | 967 prefs::kProxyAutoDetect)); |
964 | 968 |
965 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { | 969 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { |
966 std::string proxy_bypass = | 970 std::string proxy_bypass = |
967 pref_service->GetString(prefs::kProxyBypassList); | 971 pref_service->GetString(prefs::kProxyBypassList); |
968 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); | 972 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); |
969 } | 973 } |
970 | 974 |
971 return proxy_config; | 975 return proxy_config; |
972 } | 976 } |
OLD | NEW |