summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/url_request/url_request_context.h22
-rw-r--r--net/url_request/url_request_http_job.cc6
2 files changed, 25 insertions, 3 deletions
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index 2c9f6fa..374af90 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -23,6 +23,8 @@ class HostResolver;
class HttpTransactionFactory;
class ProxyService;
}
+class Blacklist;
+class URLRequest;
// Subclass to provide application-specific context for URLRequest instances.
class URLRequestContext :
@@ -34,7 +36,8 @@ class URLRequestContext :
http_transaction_factory_(NULL),
ftp_transaction_factory_(NULL),
cookie_store_(NULL),
- force_tls_state_(NULL) {
+ force_tls_state_(NULL),
+ blacklist_(NULL) {
}
net::HostResolver* host_resolver() const {
@@ -67,6 +70,9 @@ class URLRequestContext :
// Gets the FTP authentication cache for this context.
net::FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; }
+ // Gets the Privacy Blacklist, if any for this context.
+ const Blacklist* blacklist() { return blacklist_; }
+
// Gets the value of 'Accept-Charset' header field.
const std::string& accept_charset() const { return accept_charset_; }
@@ -87,6 +93,19 @@ class URLRequestContext :
referrer_charset_ = charset;
}
+ // Called for each cookie returning for the given request. A pointer to
+ // the cookie is passed so that it can be modified. Returns true if the
+ // cookie was not dropped (it could still be modified though).
+ virtual bool interceptCookie(const URLRequest* request, std::string* cookie) {
+ return true;
+ }
+
+ // Called before adding cookies to sent requests. Allows overriding
+ // requests to block sending of cookies.
+ virtual bool allowSendingCookies(const URLRequest* request) const {
+ return true;
+ }
+
protected:
friend class base::RefCountedThreadSafe<URLRequestContext>;
@@ -102,6 +121,7 @@ class URLRequestContext :
net::CookiePolicy cookie_policy_;
net::ForceTLSState* force_tls_state_;;
net::FtpAuthCache ftp_auth_cache_;
+ const Blacklist* blacklist_;
std::string accept_language_;
std::string accept_charset_;
// The charset of the referrer where this request comes from. It's not
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 1c8053d..d3b16a6 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -663,7 +663,8 @@ void URLRequestHttpJob::AddExtraHeaders() {
URLRequestContext* context = request_->context();
if (context) {
- request_info_.extra_headers += AssembleRequestCookies();
+ if (context->allowSendingCookies(request_))
+ request_info_.extra_headers += AssembleRequestCookies();
if (!context->accept_language().empty())
request_info_.extra_headers += "Accept-Language: " +
context->accept_language() + "\r\n";
@@ -700,7 +701,8 @@ void URLRequestHttpJob::FetchResponseCookies() {
void* iter = NULL;
while (response_info_->headers->EnumerateHeader(&iter, name, &value))
- response_cookies_.push_back(value);
+ if (request_->context()->interceptCookie(request_, &value))
+ response_cookies_.push_back(value);
}