Commit f71cc7bb authored by davidben's avatar davidben Committed by Commit bot

Remove prerender cookie store, part 3.

This removes the plumbing in //content to pass a custom cookie store to a
request. This reverts (a small portion of)
https://codereview.chromium.org/188693003

BUG=457344

Review URL: https://codereview.chromium.org/1002363002

Cr-Commit-Position: refs/heads/master@{#321624}
parent 502c994f
......@@ -1153,12 +1153,9 @@ void ResourceDispatcherHostImpl::BeginRequest(
}
// Construct the request.
net::CookieStore* cookie_store =
GetContentClient()->browser()->OverrideCookieStoreForRenderProcess(
child_id);
scoped_ptr<net::URLRequest> new_request;
new_request = request_context->CreateRequest(
request_data.url, request_data.priority, NULL, cookie_store);
request_data.url, request_data.priority, NULL, NULL);
new_request->set_method(request_data.method);
new_request->set_first_party_for_cookies(
......@@ -1594,13 +1591,8 @@ void ResourceDispatcherHostImpl::BeginSaveFile(
return;
}
net::CookieStore* cookie_store =
GetContentClient()->browser()->OverrideCookieStoreForRenderProcess(
child_id);
scoped_ptr<net::URLRequest> request(
request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL,
cookie_store));
request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL, NULL));
request->set_method("GET");
SetReferrerForRequest(request.get(), referrer);
......@@ -1903,9 +1895,6 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
// requests that have the ignore limits flag set.
DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS));
// TODO(davidben): OverrideCookieStoreForRenderProcess handling for
// prerender. There may not be a renderer process yet, so we need to use the
// ResourceContext or something.
scoped_ptr<net::URLRequest> new_request;
new_request = request_context->CreateRequest(
info.common_params.url, net::HIGHEST, nullptr, nullptr);
......
......@@ -571,9 +571,9 @@ void RenderMessageFilter::OnSetCookie(int render_frame_id,
if (GetContentClient()->browser()->AllowSetCookie(
url, first_party_for_cookies, cookie, resource_context_,
render_process_id_, render_frame_id, &options)) {
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
net::URLRequestContext* context = GetRequestContextForURL(url);
// Pass a null callback since we don't care about when the 'set' completes.
cookie_store->SetCookieWithOptionsAsync(
context->cookie_store()->SetCookieWithOptionsAsync(
url, cookie, options, net::CookieStore::SetCookiesCallback());
}
}
......@@ -595,8 +595,8 @@ void RenderMessageFilter::OnGetCookies(int render_frame_id,
base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf));
base::debug::Alias(url_buf);
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
cookie_store->GetAllCookiesForURLAsync(
net::URLRequestContext* context = GetRequestContextForURL(url);
context->cookie_store()->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::CheckPolicyForCookies, this,
render_frame_id, url, first_party_for_cookies,
reply_msg));
......@@ -621,8 +621,8 @@ void RenderMessageFilter::OnGetRawCookies(
// We check policy here to avoid sending back cookies that would not normally
// be applied to outbound requests for the given URL. Since this cookie info
// is visible in the developer tools, it is helpful to make it match reality.
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
cookie_store->GetAllCookiesForURLAsync(
net::URLRequestContext* context = GetRequestContextForURL(url);
context->cookie_store()->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::SendGetRawCookiesResponse,
this, reply_msg));
}
......@@ -634,8 +634,8 @@ void RenderMessageFilter::OnDeleteCookie(const GURL& url,
if (!policy->CanAccessCookiesForOrigin(render_process_id_, url))
return;
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
cookie_store->DeleteCookieAsync(url, cookie_name, base::Closure());
net::URLRequestContext* context = GetRequestContextForURL(url);
context->cookie_store()->DeleteCookieAsync(url, cookie_name, base::Closure());
}
void RenderMessageFilter::OnCookiesEnabled(
......@@ -862,15 +862,6 @@ void RenderMessageFilter::DownloadUrl(int render_view_id,
scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo());
save_info->suggested_name = suggested_name;
save_info->prompt_for_save_location = use_prompt;
// There may be a special cookie store that we could use for this download,
// rather than the default one. Since this feature is generally only used for
// proper render views, and not downloads, we do not need to retrieve the
// special cookie store here, but just initialize the request to use the
// default cookie store.
// TODO(tburkard): retrieve the appropriate special cookie store, if this
// is ever to be used for downloads as well.
scoped_ptr<net::URLRequest> request(
resource_context_->GetRequestContext()->CreateRequest(
url, net::DEFAULT_PRIORITY, NULL, NULL));
......@@ -1004,30 +995,17 @@ void RenderMessageFilter::OnDeletedDiscardableSharedMemory(
this, id));
}
net::CookieStore* RenderMessageFilter::GetCookieStoreForURL(
net::URLRequestContext* RenderMessageFilter::GetRequestContextForURL(
const GURL& url) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
net::URLRequestContext* context =
GetContentClient()->browser()->OverrideRequestContextForURL(
url, resource_context_);
if (!context)
context = request_context_->GetURLRequestContext();
// If we should use a special URLRequestContext rather than the default one,
// return the cookie store of that special URLRequestContext.
if (context)
return context->cookie_store();
// Otherwise, if there is a special cookie store to be used for this process,
// return that cookie store.
net::CookieStore* cookie_store =
GetContentClient()->browser()->OverrideCookieStoreForRenderProcess(
render_process_id_);
if (cookie_store)
return cookie_store;
// Otherwise, return the cookie store of the default request context used
// for this renderer.
return request_context_->GetURLRequestContext()->cookie_store();
return context;
}
void RenderMessageFilter::OnCacheableMetadataAvailable(
......@@ -1121,14 +1099,14 @@ void RenderMessageFilter::CheckPolicyForCookies(
const GURL& first_party_for_cookies,
IPC::Message* reply_msg,
const net::CookieList& cookie_list) {
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
net::URLRequestContext* context = GetRequestContextForURL(url);
// Check the policy for get cookies, and pass cookie_list to the
// TabSpecificContentSetting for logging purpose.
if (GetContentClient()->browser()->AllowGetCookie(
url, first_party_for_cookies, cookie_list, resource_context_,
render_process_id_, render_frame_id)) {
// Gets the cookies from cookie store if allowed.
cookie_store->GetCookiesWithOptionsAsync(
context->cookie_store()->GetCookiesWithOptionsAsync(
url, net::CookieOptions(),
base::Bind(&RenderMessageFilter::SendGetCookiesResponse,
this, reply_msg));
......
......@@ -72,7 +72,6 @@ struct MediaLogEvent;
}
namespace net {
class CookieStore;
class KeygenHandler;
class URLRequestContext;
class URLRequestContextGetter;
......@@ -116,10 +115,10 @@ class CONTENT_EXPORT RenderMessageFilter : public BrowserMessageFilter {
int render_process_id() const { return render_process_id_; }
// Returns the correct net::CookieStore depending on what type of url is
// Returns the correct net::URLRequestContext depending on what type of url is
// given.
// Only call on the IO thread.
net::CookieStore* GetCookieStoreForURL(const GURL& url);
net::URLRequestContext* GetRequestContextForURL(const GURL& url);
protected:
~RenderMessageFilter() override;
......
......@@ -327,11 +327,6 @@ bool ContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs(
return false;
}
net::CookieStore* ContentBrowserClient::OverrideCookieStoreForRenderProcess(
int render_process_id) {
return nullptr;
}
bool ContentBrowserClient::CheckMediaAccessPermission(
BrowserContext* browser_context,
const GURL& security_origin,
......
......@@ -57,7 +57,6 @@ class ImageSkia;
namespace net {
class CookieOptions;
class CookieStore;
class NetLog;
class SSLCertRequestInfo;
class SSLInfo;
......@@ -587,12 +586,6 @@ class CONTENT_EXPORT ContentBrowserClient {
BrowserContext* browser_context,
const GURL& url);
// Returns a special cookie store to use for a given render process, or
// nullptr if the default cookie store should be used.
// This is called on the IO thread.
virtual net::CookieStore* OverrideCookieStoreForRenderProcess(
int render_process_id);
// Checks if |security_origin| has permission to access the microphone or
// camera. Note that this does not query the user. |type| must be
// MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment