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/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
11 #include "chrome/browser/extensions/extensions_service.h" | 11 #include "chrome/browser/extensions/extensions_service.h" |
12 #include "chrome/browser/extensions/user_script_master.h" | 12 #include "chrome/browser/extensions/user_script_master.h" |
13 #include "chrome/browser/io_thread.h" | 13 #include "chrome/browser/io_thread.h" |
| 14 #include "chrome/browser/net/chrome_net_log.h" |
14 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 15 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
15 #include "chrome/browser/net/dns_global.h" | 16 #include "chrome/browser/net/dns_global.h" |
16 #include "chrome/browser/privacy_blacklist/blacklist.h" | 17 #include "chrome/browser/privacy_blacklist/blacklist.h" |
17 #include "chrome/browser/privacy_blacklist/blacklist_request_info.h" | 18 #include "chrome/browser/privacy_blacklist/blacklist_request_info.h" |
18 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
19 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/notification_service.h" | 23 #include "chrome/common/notification_service.h" |
23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 195 |
195 // Create a new AppCacheService. | 196 // Create a new AppCacheService. |
196 context->set_appcache_service( | 197 context->set_appcache_service( |
197 new ChromeAppCacheService(profile_dir_path_, context)); | 198 new ChromeAppCacheService(profile_dir_path_, context)); |
198 | 199 |
199 #if defined(USE_NSS) | 200 #if defined(USE_NSS) |
200 // TODO(ukai): find a better way to set the URLRequestContext for OCSP. | 201 // TODO(ukai): find a better way to set the URLRequestContext for OCSP. |
201 net::SetURLRequestContextForOCSP(context); | 202 net::SetURLRequestContextForOCSP(context); |
202 #endif | 203 #endif |
203 | 204 |
| 205 context->set_net_log(io_thread()->globals()->net_log.get()); |
204 return context; | 206 return context; |
205 } | 207 } |
206 | 208 |
207 // Factory that creates the ChromeURLRequestContext for extensions. | 209 // Factory that creates the ChromeURLRequestContext for extensions. |
208 class FactoryForExtensions : public ChromeURLRequestContextFactory { | 210 class FactoryForExtensions : public ChromeURLRequestContextFactory { |
209 public: | 211 public: |
210 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path) | 212 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path) |
211 : ChromeURLRequestContextFactory(profile), | 213 : ChromeURLRequestContextFactory(profile), |
212 cookie_store_path_(cookie_store_path) { | 214 cookie_store_path_(cookie_store_path) { |
213 } | 215 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 switches::kDisableByteRangeSupport)) | 288 switches::kDisableByteRangeSupport)) |
287 cache->set_enable_range_support(false); | 289 cache->set_enable_range_support(false); |
288 | 290 |
289 context->set_ftp_transaction_factory( | 291 context->set_ftp_transaction_factory( |
290 new net::FtpNetworkLayer(context->host_resolver())); | 292 new net::FtpNetworkLayer(context->host_resolver())); |
291 | 293 |
292 // Create a separate AppCacheService for OTR mode. | 294 // Create a separate AppCacheService for OTR mode. |
293 context->set_appcache_service( | 295 context->set_appcache_service( |
294 new ChromeAppCacheService(profile_dir_path_, context)); | 296 new ChromeAppCacheService(profile_dir_path_, context)); |
295 | 297 |
| 298 context->set_net_log(io_thread()->globals()->net_log.get()); |
296 return context; | 299 return context; |
297 } | 300 } |
298 | 301 |
299 // Factory that creates the ChromeURLRequestContext for media. | 302 // Factory that creates the ChromeURLRequestContext for media. |
300 class FactoryForMedia : public ChromeURLRequestContextFactory { | 303 class FactoryForMedia : public ChromeURLRequestContextFactory { |
301 public: | 304 public: |
302 FactoryForMedia(Profile* profile, | 305 FactoryForMedia(Profile* profile, |
303 const FilePath& disk_cache_path, | 306 const FilePath& disk_cache_path, |
304 int cache_size, | 307 int cache_size, |
305 bool off_the_record) | 308 bool off_the_record) |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 *result = GetURLRequestContext()->cookie_store(); | 591 *result = GetURLRequestContext()->cookie_store(); |
589 completion->Signal(); | 592 completion->Signal(); |
590 } | 593 } |
591 | 594 |
592 // ---------------------------------------------------------------------------- | 595 // ---------------------------------------------------------------------------- |
593 // ChromeURLRequestContext | 596 // ChromeURLRequestContext |
594 // ---------------------------------------------------------------------------- | 597 // ---------------------------------------------------------------------------- |
595 | 598 |
596 ChromeURLRequestContext::ChromeURLRequestContext() { | 599 ChromeURLRequestContext::ChromeURLRequestContext() { |
597 CheckCurrentlyOnIOThread(); | 600 CheckCurrentlyOnIOThread(); |
598 | |
599 url_request_tracker()->SetGraveyardFilter( | |
600 &ChromeURLRequestContext::ShouldTrackRequest); | |
601 } | 601 } |
602 | 602 |
603 ChromeURLRequestContext::~ChromeURLRequestContext() { | 603 ChromeURLRequestContext::~ChromeURLRequestContext() { |
604 CheckCurrentlyOnIOThread(); | 604 CheckCurrentlyOnIOThread(); |
605 | 605 |
606 if (appcache_service_.get() && appcache_service_->request_context() == this) | 606 if (appcache_service_.get() && appcache_service_->request_context() == this) |
607 appcache_service_->set_request_context(NULL); | 607 appcache_service_->set_request_context(NULL); |
608 | 608 |
609 if (proxy_service_ && | 609 if (proxy_service_ && |
610 proxy_service_->GetProxyScriptFetcher() && | 610 proxy_service_->GetProxyScriptFetcher() && |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 host_content_settings_map_->GetDefaultContentSetting( | 745 host_content_settings_map_->GetDefaultContentSetting( |
746 CONTENT_SETTINGS_TYPE_COOKIES); | 746 CONTENT_SETTINGS_TYPE_COOKIES); |
747 return setting != CONTENT_SETTING_BLOCK; | 747 return setting != CONTENT_SETTING_BLOCK; |
748 } | 748 } |
749 | 749 |
750 ChromeURLRequestContext::ChromeURLRequestContext( | 750 ChromeURLRequestContext::ChromeURLRequestContext( |
751 ChromeURLRequestContext* other) { | 751 ChromeURLRequestContext* other) { |
752 CheckCurrentlyOnIOThread(); | 752 CheckCurrentlyOnIOThread(); |
753 | 753 |
754 // Set URLRequestContext members | 754 // Set URLRequestContext members |
| 755 net_log_ = other->net_log_; |
755 host_resolver_ = other->host_resolver_; | 756 host_resolver_ = other->host_resolver_; |
756 proxy_service_ = other->proxy_service_; | 757 proxy_service_ = other->proxy_service_; |
757 ssl_config_service_ = other->ssl_config_service_; | 758 ssl_config_service_ = other->ssl_config_service_; |
758 http_transaction_factory_ = other->http_transaction_factory_; | 759 http_transaction_factory_ = other->http_transaction_factory_; |
759 ftp_transaction_factory_ = other->ftp_transaction_factory_; | 760 ftp_transaction_factory_ = other->ftp_transaction_factory_; |
760 cookie_store_ = other->cookie_store_; | 761 cookie_store_ = other->cookie_store_; |
761 cookie_policy_ = other->cookie_policy_; | 762 cookie_policy_ = other->cookie_policy_; |
762 transport_security_state_ = other->transport_security_state_; | 763 transport_security_state_ = other->transport_security_state_; |
763 accept_language_ = other->accept_language_; | 764 accept_language_ = other->accept_language_; |
764 accept_charset_ = other->accept_charset_; | 765 accept_charset_ = other->accept_charset_; |
(...skipping 26 matching lines...) Expand all Loading... |
791 } | 792 } |
792 | 793 |
793 void ChromeURLRequestContext::OnDefaultCharsetChange( | 794 void ChromeURLRequestContext::OnDefaultCharsetChange( |
794 const std::string& default_charset) { | 795 const std::string& default_charset) { |
795 CheckCurrentlyOnIOThread(); | 796 CheckCurrentlyOnIOThread(); |
796 referrer_charset_ = default_charset; | 797 referrer_charset_ = default_charset; |
797 accept_charset_ = | 798 accept_charset_ = |
798 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset); | 799 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset); |
799 } | 800 } |
800 | 801 |
801 // static | |
802 bool ChromeURLRequestContext::ShouldTrackRequest(const GURL& url) { | |
803 // Exclude "chrome://" URLs from our recent requests circular buffer. | |
804 return !url.SchemeIs("chrome"); | |
805 } | |
806 | |
807 // ---------------------------------------------------------------------------- | 802 // ---------------------------------------------------------------------------- |
808 // ChromeURLRequestContextFactory | 803 // ChromeURLRequestContextFactory |
809 // ---------------------------------------------------------------------------- | 804 // ---------------------------------------------------------------------------- |
810 | 805 |
811 // Extract values from |profile| and copy them into | 806 // Extract values from |profile| and copy them into |
812 // ChromeURLRequestContextFactory. We will use them later when constructing the | 807 // ChromeURLRequestContextFactory. We will use them later when constructing the |
813 // ChromeURLRequestContext on the IO thread (see | 808 // ChromeURLRequestContext on the IO thread (see |
814 // ApplyProfileParametersToContext() which reverses this). | 809 // ApplyProfileParametersToContext() which reverses this). |
815 ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile) | 810 ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile) |
816 : is_media_(false), | 811 : is_media_(false), |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 } | 939 } |
945 | 940 |
946 if (command_line.HasSwitch(switches::kProxyBypassList)) { | 941 if (command_line.HasSwitch(switches::kProxyBypassList)) { |
947 proxy_config->proxy_rules().bypass_rules.ParseFromString( | 942 proxy_config->proxy_rules().bypass_rules.ParseFromString( |
948 WideToASCII(command_line.GetSwitchValue( | 943 WideToASCII(command_line.GetSwitchValue( |
949 switches::kProxyBypassList))); | 944 switches::kProxyBypassList))); |
950 } | 945 } |
951 | 946 |
952 return proxy_config; | 947 return proxy_config; |
953 } | 948 } |
OLD | NEW |