diff options
Diffstat (limited to 'webkit/tools/test_shell/simple_resource_loader_bridge.cc')
-rw-r--r-- | webkit/tools/test_shell/simple_resource_loader_bridge.cc | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index c8755d5..1a1cc71 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -89,13 +89,11 @@ struct TestShellRequestContextParams { bool in_no_proxy) : cache_path(in_cache_path), cache_mode(in_cache_mode), - no_proxy(in_no_proxy), - accept_all_cookies(false) {} + no_proxy(in_no_proxy) {} FilePath cache_path; net::HttpCache::Mode cache_mode; bool no_proxy; - bool accept_all_cookies; }; net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request, @@ -139,6 +137,7 @@ net::URLRequestJob* FileSystemURLRequestJobFactory(net::URLRequest* request, TestShellRequestContextParams* g_request_context_params = NULL; TestShellRequestContext* g_request_context = NULL; base::Thread* g_cache_thread = NULL; +bool g_accept_all_cookies = false; //----------------------------------------------------------------------------- @@ -159,12 +158,10 @@ class IOThread : public base::Thread { g_request_context_params->cache_path, g_request_context_params->cache_mode, g_request_context_params->no_proxy); - SetAcceptAllCookies(g_request_context_params->accept_all_cookies); delete g_request_context_params; g_request_context_params = NULL; } else { g_request_context = new TestShellRequestContext(); - SetAcceptAllCookies(false); } g_request_context->AddRef(); @@ -192,14 +189,6 @@ class IOThread : public base::Thread { g_request_context = NULL; } } - - void SetAcceptAllCookies(bool accept_all_cookies) { - StaticCookiePolicy::Type policy_type = accept_all_cookies ? - StaticCookiePolicy::ALLOW_ALL_COOKIES : - StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; - static_cast<StaticCookiePolicy*>(g_request_context->cookie_policy())-> - set_type(policy_type); - } }; IOThread* g_io_thread = NULL; @@ -494,6 +483,30 @@ class RequestProxy : public net::URLRequest::Delegate, request->ContinueDespiteLastError(); } + virtual bool CanGetCookies(net::URLRequest* request) { + StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? + StaticCookiePolicy::ALLOW_ALL_COOKIES : + StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; + + net::StaticCookiePolicy policy(policy_type); + int rv = policy.CanGetCookies( + request->url(), request->first_party_for_cookies()); + return rv == net::OK; + } + + virtual bool CanSetCookie(net::URLRequest* request, + const std::string& cookie_line, + net::CookieOptions* options) { + StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? + StaticCookiePolicy::ALLOW_ALL_COOKIES : + StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; + + net::StaticCookiePolicy policy(policy_type); + int rv = policy.CanSetCookie( + request->url(), request->first_party_for_cookies(), cookie_line); + return rv == net::OK; + } + virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) { if (request->status().is_success() && bytes_read > 0) { OnReceivedData(bytes_read); @@ -931,13 +944,7 @@ bool SimpleResourceLoaderBridge::EnsureIOThread() { // static void SimpleResourceLoaderBridge::SetAcceptAllCookies(bool accept_all_cookies) { - if (g_request_context_params) { - g_request_context_params->accept_all_cookies = accept_all_cookies; - DCHECK(!g_request_context); - DCHECK(!g_io_thread); - } else { - g_io_thread->SetAcceptAllCookies(accept_all_cookies); - } + g_accept_all_cookies = accept_all_cookies; } // static |