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

Unified Diff: content/browser/frame_host/render_frame_message_filter.cc

Issue 2167513003: Moves FrameHostMsg_SetCookie to a Mojo message (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser-associated-interface
Patch Set: . Created 4 years, 5 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
Index: content/browser/frame_host/render_frame_message_filter.cc
diff --git a/content/browser/frame_host/render_frame_message_filter.cc b/content/browser/frame_host/render_frame_message_filter.cc
index a1ccf839d0aead6e9b7e3f9efb59b597cec057f6..a4a91b09e4869065e1ba2ea995e6442ea2a7d189 100644
--- a/content/browser/frame_host/render_frame_message_filter.cc
+++ b/content/browser/frame_host/render_frame_message_filter.cc
@@ -212,6 +212,7 @@ RenderFrameMessageFilter::RenderFrameMessageFilter(
net::URLRequestContextGetter* request_context,
RenderWidgetHelper* render_widget_helper)
: BrowserMessageFilter(FrameMsgStart),
+ BrowserAssociatedInterface<mojom::RenderFrameMessageFilter>(this, this),
#if defined(ENABLE_PLUGINS)
plugin_service_(plugin_service),
profile_data_directory_(browser_context->GetPath()),
@@ -232,7 +233,6 @@ bool RenderFrameMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderFrameMessageFilter, message)
IPC_MESSAGE_HANDLER(FrameHostMsg_CreateChildFrame, OnCreateChildFrame)
- IPC_MESSAGE_HANDLER(FrameHostMsg_SetCookie, OnSetCookie)
IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_GetCookies, OnGetCookies)
IPC_MESSAGE_HANDLER(FrameHostMsg_CookiesEnabled, OnCookiesEnabled)
IPC_MESSAGE_HANDLER(FrameHostMsg_DownloadUrl, OnDownloadUrl)
@@ -261,6 +261,10 @@ bool RenderFrameMessageFilter::OnMessageReceived(const IPC::Message& message) {
return handled;
}
+void RenderFrameMessageFilter::OnDestruct() const {
+ BrowserThread::DeleteOnIOThread::Destruct(this);
+}
+
void RenderFrameMessageFilter::DownloadUrl(int render_view_id,
int render_frame_id,
const GURL& url,
@@ -304,39 +308,6 @@ void RenderFrameMessageFilter::OnCreateChildFrame(
params.frame_owner_properties, *new_routing_id));
}
-void RenderFrameMessageFilter::OnSetCookie(int render_frame_id,
- const GURL& url,
- const GURL& first_party_for_cookies,
- const std::string& cookie) {
- ChildProcessSecurityPolicyImpl* policy =
- ChildProcessSecurityPolicyImpl::GetInstance();
- if (!policy->CanAccessDataForOrigin(render_process_id_, url)) {
- bad_message::ReceivedBadMessage(this,
- bad_message::RFMF_SET_COOKIE_BAD_ORIGIN);
- return;
- }
-
- net::CookieOptions options;
- bool experimental_web_platform_features_enabled =
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableExperimentalWebPlatformFeatures);
- const std::string enforce_strict_secure_group =
- base::FieldTrialList::FindFullName(kEnforceStrictSecureExperiment);
- if (experimental_web_platform_features_enabled ||
- base::StartsWith(enforce_strict_secure_group, "Enabled",
- base::CompareCase::INSENSITIVE_ASCII)) {
- options.set_enforce_strict_secure();
- }
- if (GetContentClient()->browser()->AllowSetCookie(
- url, first_party_for_cookies, cookie, resource_context_,
- render_process_id_, render_frame_id, options)) {
- net::URLRequestContext* context = GetRequestContextForURL(url);
- // Pass a null callback since we don't care about when the 'set' completes.
- context->cookie_store()->SetCookieWithOptionsAsync(
- url, cookie, options, net::CookieStore::SetCookiesCallback());
- }
-}
-
void RenderFrameMessageFilter::OnGetCookies(int render_frame_id,
const GURL& url,
const GURL& first_party_for_cookies,
@@ -460,6 +431,39 @@ void RenderFrameMessageFilter::OnRenderProcessGone() {
this, bad_message::RFMF_RENDERER_FAKED_ITS_OWN_DEATH);
}
+void RenderFrameMessageFilter::SetCookie(int32_t render_frame_id,
+ const GURL& url,
+ const GURL& first_party_for_cookies,
+ const mojo::String& cookie) {
+ ChildProcessSecurityPolicyImpl* policy =
+ ChildProcessSecurityPolicyImpl::GetInstance();
+ if (!policy->CanAccessDataForOrigin(render_process_id_, url)) {
+ bad_message::ReceivedBadMessage(this,
+ bad_message::RFMF_SET_COOKIE_BAD_ORIGIN);
+ return;
+ }
+
+ net::CookieOptions options;
+ bool experimental_web_platform_features_enabled =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableExperimentalWebPlatformFeatures);
+ const std::string enforce_strict_secure_group =
+ base::FieldTrialList::FindFullName(kEnforceStrictSecureExperiment);
+ if (experimental_web_platform_features_enabled ||
+ base::StartsWith(enforce_strict_secure_group, "Enabled",
+ base::CompareCase::INSENSITIVE_ASCII)) {
+ options.set_enforce_strict_secure();
+ }
+ if (GetContentClient()->browser()->AllowSetCookie(
+ url, first_party_for_cookies, cookie, resource_context_,
+ render_process_id_, render_frame_id, options)) {
+ net::URLRequestContext* context = GetRequestContextForURL(url);
+ // Pass a null callback since we don't care about when the 'set' completes.
+ context->cookie_store()->SetCookieWithOptionsAsync(
+ url, cookie, options, net::CookieStore::SetCookiesCallback());
+ }
+}
+
#if defined(ENABLE_PLUGINS)
void RenderFrameMessageFilter::OnGetPlugins(

Powered by Google App Engine
This is Rietveld 408576698