diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-20 14:59:44 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-20 14:59:44 +0000 |
commit | 5f9a7f97780db19175a8549d39b97f62fa6c9afb (patch) | |
tree | 3fd95826f8b36779fe1394b36a0f0814ecc6eeb5 /chrome/browser/net | |
parent | 00f1cab12265fc810d882ae20e58bdef9437ca7f (diff) | |
download | chromium_src-5f9a7f97780db19175a8549d39b97f62fa6c9afb.zip chromium_src-5f9a7f97780db19175a8549d39b97f62fa6c9afb.tar.gz chromium_src-5f9a7f97780db19175a8549d39b97f62fa6c9afb.tar.bz2 |
Remove support for filtering by MIME-type.
Also merge kDontSendCookies and kDontStoreCookies to kNoCookies.
BUG=16932
TEST=unit_tests
Review URL: http://codereview.chromium.org/542056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 44 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 14 |
2 files changed, 23 insertions, 35 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 3e0bc31..fda3916 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -676,38 +676,18 @@ const std::string& ChromeURLRequestContext::GetUserAgent( return webkit_glue::GetUserAgent(url); } -bool ChromeURLRequestContext::InterceptCookie(const URLRequest* request, - std::string* cookie) { - BlacklistRequestInfo* request_info = - BlacklistRequestInfo::FromURLRequest(request); - // Requests which don't go through ResourceDispatcherHost don't have privacy - // blacklist request data. - if (!request_info) - return true; - const Blacklist* blacklist = request_info->GetBlacklist(); - // TODO(phajdan.jr): remove the NULL check when blacklists are stable. - if (!blacklist) - return true; - scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url())); - if (!match.get()) - return true; - if (match->attributes() & Blacklist::kDontStoreCookies) { - NotificationService::current()->Notify( - NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED, - Source<const ChromeURLRequestContext>(this), - Details<const URLRequest>(request)); +bool ChromeURLRequestContext::InterceptRequestCookies( + const URLRequest* request, const std::string& cookies) const { + return InterceptCookie(request, cookies); +} - cookie->clear(); - return false; - } - if (match->attributes() & Blacklist::kDontPersistCookies) { - *cookie = Blacklist::StripCookieExpiry(*cookie); - } - return true; +bool ChromeURLRequestContext::InterceptResponseCookie( + const URLRequest* request, const std::string& cookie) const { + return InterceptCookie(request, cookie); } -bool ChromeURLRequestContext::AllowSendingCookies(const URLRequest* request) - const { +bool ChromeURLRequestContext::InterceptCookie( + const URLRequest* request, const std::string& cookie) const { BlacklistRequestInfo* request_info = BlacklistRequestInfo::FromURLRequest(request); // Requests which don't go through ResourceDispatcherHost don't have privacy @@ -719,16 +699,14 @@ bool ChromeURLRequestContext::AllowSendingCookies(const URLRequest* request) if (!blacklist) return true; scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url())); - if (!match.get()) - return true; - if (match->attributes() & Blacklist::kDontSendCookies) { + if (match.get() && (match->attributes() & Blacklist::kBlockCookies)) { NotificationService::current()->Notify( NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED, Source<const ChromeURLRequestContext>(this), Details<const URLRequest>(request)); - return false; } + return true; } diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index a1bc78c..b1384f6 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -185,9 +185,13 @@ class ChromeURLRequestContext : public URLRequestContext { virtual const std::string& GetUserAgent(const GURL& url) const; - virtual bool InterceptCookie(const URLRequest* request, std::string* cookie); + // Returns true if cookies can be added to request. + virtual bool InterceptRequestCookies(const URLRequest* request, + const std::string& cookie) const; - virtual bool AllowSendingCookies(const URLRequest* request) const; + // Returns true if response cookies should be stored. + virtual bool InterceptResponseCookie(const URLRequest* request, + const std::string& cookie) const; const HostZoomMap* host_zoom_map() const { return host_zoom_map_; } @@ -300,6 +304,12 @@ class ChromeURLRequestContext : public URLRequestContext { bool is_off_the_record_; private: + // Blacklist implementation of InterceptRequestCookie and + // InterceptResponseCookie. Returns true if cookies are allowed and false + // if the request matches a Blacklist rule and cookies should be blocked. + bool InterceptCookie(const URLRequest* request, + const std::string& cookie) const; + // Filter for url_request_tracker(), that prevents "chrome://" requests from // being tracked by "about:net-internals". static bool ShouldTrackRequest(const GURL& url); |