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_util.h" | 10 #include "base/string_util.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chrome_thread.h" | 12 #include "chrome/browser/chrome_thread.h" |
13 #include "chrome/browser/extensions/extensions_service.h" | 13 #include "chrome/browser/extensions/extensions_service.h" |
14 #include "chrome/browser/extensions/user_script_master.h" | 14 #include "chrome/browser/extensions/user_script_master.h" |
15 #include "chrome/browser/io_thread.h" | 15 #include "chrome/browser/io_thread.h" |
16 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 16 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
17 #include "chrome/browser/net/chrome_net_log.h" | 17 #include "chrome/browser/net/chrome_net_log.h" |
18 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 18 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
19 #include "chrome/browser/net/predictor_api.h" | 19 #include "chrome/browser/net/predictor_api.h" |
20 #include "chrome/browser/privacy_blacklist/blacklist.h" | |
21 #include "chrome/browser/privacy_blacklist/blacklist_request_info.h" | |
22 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
23 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
24 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
26 #include "chrome/common/notification_service.h" | 24 #include "chrome/common/notification_service.h" |
27 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
28 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
29 #include "net/base/static_cookie_policy.h" | 27 #include "net/base/static_cookie_policy.h" |
30 #include "net/ftp/ftp_network_layer.h" | 28 #include "net/ftp/ftp_network_layer.h" |
31 #include "net/http/http_cache.h" | 29 #include "net/http/http_cache.h" |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 return std::find(api_permissions.begin(), | 805 return std::find(api_permissions.begin(), |
808 api_permissions.end(), | 806 api_permissions.end(), |
809 permission_name) != api_permissions.end(); | 807 permission_name) != api_permissions.end(); |
810 } | 808 } |
811 | 809 |
812 const std::string& ChromeURLRequestContext::GetUserAgent( | 810 const std::string& ChromeURLRequestContext::GetUserAgent( |
813 const GURL& url) const { | 811 const GURL& url) const { |
814 return webkit_glue::GetUserAgent(url); | 812 return webkit_glue::GetUserAgent(url); |
815 } | 813 } |
816 | 814 |
817 bool ChromeURLRequestContext::InterceptRequestCookies( | |
818 const URLRequest* request, const std::string& cookies) const { | |
819 return InterceptCookie(request, cookies); | |
820 } | |
821 | |
822 bool ChromeURLRequestContext::InterceptResponseCookie( | |
823 const URLRequest* request, const std::string& cookie) const { | |
824 return InterceptCookie(request, cookie); | |
825 } | |
826 | |
827 bool ChromeURLRequestContext::InterceptCookie( | |
828 const URLRequest* request, const std::string& cookie) const { | |
829 BlacklistRequestInfo* request_info = | |
830 BlacklistRequestInfo::FromURLRequest(request); | |
831 // Requests which don't go through ResourceDispatcherHost don't have privacy | |
832 // blacklist request data. | |
833 if (!request_info) | |
834 return true; | |
835 const Blacklist* blacklist = request_info->GetBlacklist(); | |
836 // TODO(phajdan.jr): remove the NULL check when blacklists are stable. | |
837 if (!blacklist) | |
838 return true; | |
839 scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url())); | |
840 if (match.get() && (match->attributes() & Blacklist::kBlockCookies)) { | |
841 NotificationService::current()->Notify( | |
842 NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED, | |
843 Source<const ChromeURLRequestContext>(this), | |
844 Details<const URLRequest>(request)); | |
845 return false; | |
846 } | |
847 | |
848 return true; | |
849 } | |
850 | |
851 const Blacklist* ChromeURLRequestContext::GetPrivacyBlacklist() const { | |
852 return privacy_blacklist_.get(); | |
853 } | |
854 | |
855 void ChromeURLRequestContext::OnNewExtensions(const std::string& id, | 815 void ChromeURLRequestContext::OnNewExtensions(const std::string& id, |
856 ExtensionInfo* info) { | 816 ExtensionInfo* info) { |
857 if (!is_off_the_record_) | 817 if (!is_off_the_record_) |
858 extension_info_[id] = linked_ptr<ExtensionInfo>(info); | 818 extension_info_[id] = linked_ptr<ExtensionInfo>(info); |
859 } | 819 } |
860 | 820 |
861 void ChromeURLRequestContext::OnUnloadedExtension(const std::string& id) { | 821 void ChromeURLRequestContext::OnUnloadedExtension(const std::string& id) { |
862 CheckCurrentlyOnIOThread(); | 822 CheckCurrentlyOnIOThread(); |
863 if (is_off_the_record_) | 823 if (is_off_the_record_) |
864 return; | 824 return; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 http_auth_handler_factory_ = other->http_auth_handler_factory_; | 860 http_auth_handler_factory_ = other->http_auth_handler_factory_; |
901 | 861 |
902 // Set ChromeURLRequestContext members | 862 // Set ChromeURLRequestContext members |
903 extension_info_ = other->extension_info_; | 863 extension_info_ = other->extension_info_; |
904 user_script_dir_path_ = other->user_script_dir_path_; | 864 user_script_dir_path_ = other->user_script_dir_path_; |
905 appcache_service_ = other->appcache_service_; | 865 appcache_service_ = other->appcache_service_; |
906 database_tracker_ = other->database_tracker_; | 866 database_tracker_ = other->database_tracker_; |
907 chrome_cookie_policy_ = other->chrome_cookie_policy_; | 867 chrome_cookie_policy_ = other->chrome_cookie_policy_; |
908 host_content_settings_map_ = other->host_content_settings_map_; | 868 host_content_settings_map_ = other->host_content_settings_map_; |
909 host_zoom_map_ = other->host_zoom_map_; | 869 host_zoom_map_ = other->host_zoom_map_; |
910 privacy_blacklist_ = other->privacy_blacklist_; | |
911 is_media_ = other->is_media_; | 870 is_media_ = other->is_media_; |
912 is_off_the_record_ = other->is_off_the_record_; | 871 is_off_the_record_ = other->is_off_the_record_; |
913 } | 872 } |
914 | 873 |
915 void ChromeURLRequestContext::OnAcceptLanguageChange( | 874 void ChromeURLRequestContext::OnAcceptLanguageChange( |
916 const std::string& accept_language) { | 875 const std::string& accept_language) { |
917 CheckCurrentlyOnIOThread(); | 876 CheckCurrentlyOnIOThread(); |
918 accept_language_ = | 877 accept_language_ = |
919 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language); | 878 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language); |
920 } | 879 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 // types a URL in the omnibar or click on a download link in a page. | 917 // types a URL in the omnibar or click on a download link in a page. |
959 // For the latter, we need a change on the webkit-side. | 918 // For the latter, we need a change on the webkit-side. |
960 // We initialize it to the default charset here and a user will | 919 // We initialize it to the default charset here and a user will |
961 // have an *arguably* better default charset for interpreting a raw 8bit | 920 // have an *arguably* better default charset for interpreting a raw 8bit |
962 // C-D header field. It means the native OS codepage fallback in | 921 // C-D header field. It means the native OS codepage fallback in |
963 // net_util::GetSuggestedFilename is unlikely to be taken. | 922 // net_util::GetSuggestedFilename is unlikely to be taken. |
964 referrer_charset_ = default_charset; | 923 referrer_charset_ = default_charset; |
965 | 924 |
966 host_content_settings_map_ = profile->GetHostContentSettingsMap(); | 925 host_content_settings_map_ = profile->GetHostContentSettingsMap(); |
967 host_zoom_map_ = profile->GetHostZoomMap(); | 926 host_zoom_map_ = profile->GetHostZoomMap(); |
968 privacy_blacklist_ = profile->GetPrivacyBlacklist(); | |
969 transport_security_state_ = profile->GetTransportSecurityState(); | 927 transport_security_state_ = profile->GetTransportSecurityState(); |
970 | 928 |
971 if (profile->GetExtensionsService()) { | 929 if (profile->GetExtensionsService()) { |
972 const ExtensionList* extensions = | 930 const ExtensionList* extensions = |
973 profile->GetExtensionsService()->extensions(); | 931 profile->GetExtensionsService()->extensions(); |
974 for (ExtensionList::const_iterator iter = extensions->begin(); | 932 for (ExtensionList::const_iterator iter = extensions->begin(); |
975 iter != extensions->end(); ++iter) { | 933 iter != extensions->end(); ++iter) { |
976 extension_info_[(*iter)->id()] = | 934 extension_info_[(*iter)->id()] = |
977 linked_ptr<ChromeURLRequestContext::ExtensionInfo>( | 935 linked_ptr<ChromeURLRequestContext::ExtensionInfo>( |
978 new ChromeURLRequestContext::ExtensionInfo( | 936 new ChromeURLRequestContext::ExtensionInfo( |
(...skipping 27 matching lines...) Expand all Loading... |
1006 // ChromeURLRequestContextFactory(Profile*). | 964 // ChromeURLRequestContextFactory(Profile*). |
1007 context->set_is_media(is_media_); | 965 context->set_is_media(is_media_); |
1008 context->set_is_off_the_record(is_off_the_record_); | 966 context->set_is_off_the_record(is_off_the_record_); |
1009 context->set_accept_language(accept_language_); | 967 context->set_accept_language(accept_language_); |
1010 context->set_accept_charset(accept_charset_); | 968 context->set_accept_charset(accept_charset_); |
1011 context->set_referrer_charset(referrer_charset_); | 969 context->set_referrer_charset(referrer_charset_); |
1012 context->set_extension_info(extension_info_); | 970 context->set_extension_info(extension_info_); |
1013 context->set_user_script_dir_path(user_script_dir_path_); | 971 context->set_user_script_dir_path(user_script_dir_path_); |
1014 context->set_host_content_settings_map(host_content_settings_map_); | 972 context->set_host_content_settings_map(host_content_settings_map_); |
1015 context->set_host_zoom_map(host_zoom_map_); | 973 context->set_host_zoom_map(host_zoom_map_); |
1016 context->set_privacy_blacklist(privacy_blacklist_); | |
1017 context->set_transport_security_state( | 974 context->set_transport_security_state( |
1018 transport_security_state_); | 975 transport_security_state_); |
1019 context->set_ssl_config_service(ssl_config_service_); | 976 context->set_ssl_config_service(ssl_config_service_); |
1020 context->set_database_tracker(database_tracker_); | 977 context->set_database_tracker(database_tracker_); |
1021 } | 978 } |
1022 | 979 |
1023 // ---------------------------------------------------------------------------- | 980 // ---------------------------------------------------------------------------- |
1024 | 981 |
1025 net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service) { | 982 net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service) { |
1026 // Scan for all "enable" type proxy switches. | 983 // Scan for all "enable" type proxy switches. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 prefs::kProxyAutoDetect)); | 1022 prefs::kProxyAutoDetect)); |
1066 | 1023 |
1067 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { | 1024 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { |
1068 std::string proxy_bypass = | 1025 std::string proxy_bypass = |
1069 pref_service->GetString(prefs::kProxyBypassList); | 1026 pref_service->GetString(prefs::kProxyBypassList); |
1070 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); | 1027 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); |
1071 } | 1028 } |
1072 | 1029 |
1073 return proxy_config; | 1030 return proxy_config; |
1074 } | 1031 } |
OLD | NEW |