| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/privacy_blacklist/blacklist.h" | |
| 11 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
| 12 #include "chrome/browser/extensions/extensions_service.h" | 11 #include "chrome/browser/extensions/extensions_service.h" |
| 13 #include "chrome/browser/extensions/user_script_master.h" | 12 #include "chrome/browser/extensions/user_script_master.h" |
| 14 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 13 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
| 15 #include "chrome/browser/net/dns_global.h" | 14 #include "chrome/browser/net/dns_global.h" |
| 16 #include "chrome/browser/privacy_blacklist/blacklist_manager.h" | 15 #include "chrome/browser/privacy_blacklist/blacklist_manager.h" |
| 16 #include "chrome/browser/privacy_blacklist/blacklist_request_info.h" |
| 17 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/notification_service.h" | 21 #include "chrome/common/notification_service.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "net/ftp/ftp_network_layer.h" | 24 #include "net/ftp/ftp_network_layer.h" |
| 25 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" |
| 26 #include "net/http/http_network_layer.h" | 26 #include "net/http/http_network_layer.h" |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 return result; | 669 return result; |
| 670 } | 670 } |
| 671 | 671 |
| 672 const std::string& ChromeURLRequestContext::GetUserAgent( | 672 const std::string& ChromeURLRequestContext::GetUserAgent( |
| 673 const GURL& url) const { | 673 const GURL& url) const { |
| 674 return webkit_glue::GetUserAgent(url); | 674 return webkit_glue::GetUserAgent(url); |
| 675 } | 675 } |
| 676 | 676 |
| 677 bool ChromeURLRequestContext::InterceptCookie(const URLRequest* request, | 677 bool ChromeURLRequestContext::InterceptCookie(const URLRequest* request, |
| 678 std::string* cookie) { | 678 std::string* cookie) { |
| 679 const URLRequest::UserData* d = | 679 BlacklistRequestInfo* request_info = |
| 680 request->GetUserData(&Blacklist::kRequestDataKey); | 680 BlacklistRequestInfo::FromURLRequest(request); |
| 681 if (d) { | 681 // Requests which don't go through ResourceDispatcherHost don't have privacy |
| 682 const Blacklist::Match* match = static_cast<const Blacklist::Match*>(d); | 682 // blacklist request data. |
| 683 if (match->attributes() & Blacklist::kDontStoreCookies) { | 683 if (!request_info) |
| 684 NotificationService::current()->Notify( | 684 return true; |
| 685 NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED, | 685 const BlacklistManager* blacklist_manager = |
| 686 Source<const ChromeURLRequestContext>(this), | 686 request_info->GetBlacklistManager(); |
| 687 Details<const URLRequest>(request)); | 687 // TODO(phajdan.jr): remove the NULL check when blacklists are stable. |
| 688 if (!blacklist_manager) |
| 689 return NULL; |
| 690 const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist(); |
| 691 scoped_ptr<Blacklist::Match> match(blacklist->findMatch(request->url())); |
| 692 if (!match.get()) |
| 693 return true; |
| 694 if (match->attributes() & Blacklist::kDontStoreCookies) { |
| 695 NotificationService::current()->Notify( |
| 696 NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED, |
| 697 Source<const ChromeURLRequestContext>(this), |
| 698 Details<const URLRequest>(request)); |
| 688 | 699 |
| 689 cookie->clear(); | 700 cookie->clear(); |
| 690 return false; | 701 return false; |
| 691 } | 702 } |
| 692 if (match->attributes() & Blacklist::kDontPersistCookies) { | 703 if (match->attributes() & Blacklist::kDontPersistCookies) { |
| 693 *cookie = Blacklist::StripCookieExpiry(*cookie); | 704 *cookie = Blacklist::StripCookieExpiry(*cookie); |
| 694 } | |
| 695 } | 705 } |
| 696 return true; | 706 return true; |
| 697 } | 707 } |
| 698 | 708 |
| 699 bool ChromeURLRequestContext::AllowSendingCookies(const URLRequest* request) | 709 bool ChromeURLRequestContext::AllowSendingCookies(const URLRequest* request) |
| 700 const { | 710 const { |
| 701 const URLRequest::UserData* d = | 711 BlacklistRequestInfo* request_info = |
| 702 request->GetUserData(&Blacklist::kRequestDataKey); | 712 BlacklistRequestInfo::FromURLRequest(request); |
| 703 if (d) { | 713 // Requests which don't go through ResourceDispatcherHost don't have privacy |
| 704 const Blacklist::Match* match = static_cast<const Blacklist::Match*>(d); | 714 // blacklist request data. |
| 705 if (match->attributes() & Blacklist::kDontSendCookies) { | 715 if (!request_info) |
| 706 NotificationService::current()->Notify( | 716 return true; |
| 707 NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED, | 717 const BlacklistManager* blacklist_manager = |
| 708 Source<const ChromeURLRequestContext>(this), | 718 request_info->GetBlacklistManager(); |
| 709 Details<const URLRequest>(request)); | 719 // TODO(phajdan.jr): remove the NULL check when blacklists are stable. |
| 720 if (!blacklist_manager) |
| 721 return NULL; |
| 722 const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist(); |
| 723 scoped_ptr<Blacklist::Match> match(blacklist->findMatch(request->url())); |
| 724 if (!match.get()) |
| 725 return true; |
| 726 if (match->attributes() & Blacklist::kDontSendCookies) { |
| 727 NotificationService::current()->Notify( |
| 728 NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED, |
| 729 Source<const ChromeURLRequestContext>(this), |
| 730 Details<const URLRequest>(request)); |
| 710 | 731 |
| 711 return false; | 732 return false; |
| 712 } | |
| 713 } | 733 } |
| 714 return true; | 734 return true; |
| 715 } | 735 } |
| 716 | 736 |
| 717 const Blacklist* ChromeURLRequestContext::GetBlacklist() const { | 737 BlacklistManager* ChromeURLRequestContext::GetBlacklistManager() const { |
| 718 // TODO(phajdan.jr): Remove the check when Privacy Blacklists become stable. | 738 return blacklist_manager_.get(); |
| 719 if (!blacklist_manager_) | |
| 720 return NULL; | |
| 721 return blacklist_manager_->GetCompiledBlacklist(); | |
| 722 } | 739 } |
| 723 | 740 |
| 724 void ChromeURLRequestContext::OnNewExtensions( | 741 void ChromeURLRequestContext::OnNewExtensions( |
| 725 const std::string& id, | 742 const std::string& id, |
| 726 const FilePath& path, | 743 const FilePath& path, |
| 727 const std::string& default_locale) { | 744 const std::string& default_locale) { |
| 728 if (!is_off_the_record_) { | 745 if (!is_off_the_record_) { |
| 729 extension_paths_[id] = path; | 746 extension_paths_[id] = path; |
| 730 if (!default_locale.empty()) | 747 if (!default_locale.empty()) |
| 731 extension_default_locales_[id] = default_locale; | 748 extension_default_locales_[id] = default_locale; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 } | 960 } |
| 944 | 961 |
| 945 if (command_line.HasSwitch(switches::kProxyBypassList)) { | 962 if (command_line.HasSwitch(switches::kProxyBypassList)) { |
| 946 proxy_config->ParseNoProxyList( | 963 proxy_config->ParseNoProxyList( |
| 947 WideToASCII(command_line.GetSwitchValue( | 964 WideToASCII(command_line.GetSwitchValue( |
| 948 switches::kProxyBypassList))); | 965 switches::kProxyBypassList))); |
| 949 } | 966 } |
| 950 | 967 |
| 951 return proxy_config; | 968 return proxy_config; |
| 952 } | 969 } |
| OLD | NEW |