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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 451923002: Add a X-Requested-With header to URL requests for PPAPI Flash (only). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add comment about -1. Created 6 years, 4 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 | « content/renderer/pepper/url_request_info_util.cc ('k') | content/test/ppapi_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 30d405fe6e5f4ff5944f0ff7a2dbf80b3ee3ba32..f11b1fc8032967d5369a797542c0be6d892a5613 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -2522,20 +2522,30 @@ void RenderFrameImpl::willSendRequest(
// The request's extra data may indicate that we should set a custom user
// agent. This needs to be done here, after WebKit is through with setting the
- // user agent on its own.
+ // user agent on its own. Similarly, it may indicate that we should set an
+ // X-Requested-With header. This must be done here to avoid breaking CORS
+ // checks.
WebString custom_user_agent;
+ WebString requested_with;
if (request.extraData()) {
RequestExtraData* old_extra_data =
- static_cast<RequestExtraData*>(
- request.extraData());
- custom_user_agent = old_extra_data->custom_user_agent();
+ static_cast<RequestExtraData*>(request.extraData());
+ custom_user_agent = old_extra_data->custom_user_agent();
if (!custom_user_agent.isNull()) {
if (custom_user_agent.isEmpty())
request.clearHTTPHeaderField("User-Agent");
else
request.setHTTPHeaderField("User-Agent", custom_user_agent);
}
+
+ requested_with = old_extra_data->requested_with();
+ if (!requested_with.isNull()) {
+ if (requested_with.isEmpty())
+ request.clearHTTPHeaderField("X-Requested-With");
+ else
+ request.setHTTPHeaderField("X-Requested-With", requested_with);
+ }
}
// Add the default accept header for frame request if it has not been set
@@ -2598,6 +2608,7 @@ void RenderFrameImpl::willSendRequest(
RequestExtraData* extra_data = new RequestExtraData();
extra_data->set_visibility_state(render_view_->visibilityState());
extra_data->set_custom_user_agent(custom_user_agent);
+ extra_data->set_requested_with(requested_with);
extra_data->set_render_frame_id(routing_id_);
extra_data->set_is_main_frame(frame == top_frame);
extra_data->set_frame_origin(
« no previous file with comments | « content/renderer/pepper/url_request_info_util.cc ('k') | content/test/ppapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698