Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: net/url_request/url_request_test_util.cc

Issue 6995013: More progress towards removing content settings code from the content layer. We can't use Cookie... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments and sync Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_test_util.h ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_test_util.cc
===================================================================
--- net/url_request/url_request_test_util.cc (revision 84789)
+++ net/url_request/url_request_test_util.cc (working copy)
@@ -11,32 +11,6 @@
#include "net/base/host_port_pair.h"
#include "net/http/http_network_session.h"
-TestCookiePolicy::TestCookiePolicy(int options_bit_mask)
- : options_(options_bit_mask) {
-}
-
-TestCookiePolicy::~TestCookiePolicy() {}
-
-int TestCookiePolicy::CanGetCookies(const GURL& url,
- const GURL& first_party) const {
- if (options_ & NO_GET_COOKIES)
- return net::ERR_ACCESS_DENIED;
-
- return net::OK;
-}
-
-int TestCookiePolicy::CanSetCookie(const GURL& url,
- const GURL& first_party,
- const std::string& cookie_line) const {
- if (options_ & NO_SET_COOKIE)
- return net::ERR_ACCESS_DENIED;
-
- if (options_ & FORCE_SESSION)
- return net::OK_FOR_SESSION_ONLY;
-
- return net::OK;
-}
-
TestURLRequestContext::TestURLRequestContext()
: ALLOW_THIS_IN_INITIALIZER_LIST(context_storage_(this)) {
context_storage_.set_host_resolver(
@@ -113,6 +87,7 @@
quit_on_complete_(true),
quit_on_redirect_(false),
allow_certificate_errors_(false),
+ cookie_options_bit_mask_(0),
response_started_count_(0),
received_bytes_count_(0),
received_redirect_count_(0),
@@ -161,26 +136,40 @@
request->Cancel();
}
-void TestDelegate::OnGetCookies(net::URLRequest* request,
- bool blocked_by_policy) {
- if (blocked_by_policy) {
+bool TestDelegate::CanGetCookies(net::URLRequest* request) {
+ bool allow = true;
+ if (cookie_options_bit_mask_ & NO_GET_COOKIES)
+ allow = false;
+
+ if (!allow) {
blocked_get_cookies_count_++;
if (cancel_in_getcookiesblocked_)
request->Cancel();
}
+
+ return allow;
}
-void TestDelegate::OnSetCookie(net::URLRequest* request,
- const std::string& cookie_line,
- const net::CookieOptions& options,
- bool blocked_by_policy) {
- if (blocked_by_policy) {
+bool TestDelegate::CanSetCookie(net::URLRequest* request,
+ const std::string& cookie_line,
+ net::CookieOptions* options) {
+ bool allow = true;
+ if (cookie_options_bit_mask_ & NO_SET_COOKIE)
+ allow = false;
+
+ if (cookie_options_bit_mask_ & FORCE_SESSION)
+ options->set_force_session();
+
+
+ if (!allow) {
blocked_set_cookie_count_++;
if (cancel_in_setcookieblocked_)
request->Cancel();
} else {
set_cookie_count_++;
}
+
+ return allow;
}
void TestDelegate::OnResponseStarted(net::URLRequest* request) {
« no previous file with comments | « net/url_request/url_request_test_util.h ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698