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

Unified Diff: content/renderer/render_view_impl.cc

Issue 10886047: Pepper: Add a X-Requested-With header to URL requests done for Pepper plugins. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: foo Created 8 years 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/pepper_url_request_unittest.cc ('k') | ppapi/tests/test_url_loader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index fd18ad12f38bd5c74efabbc9da61f111f82687f0..04b69b648e0c79f4c3e27488ee01b18b34951c1a 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -3669,25 +3669,37 @@ void RenderViewImpl::willSendRequest(WebFrame* frame,
// 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()) {
webkit_glue::WebURLRequestExtraDataImpl* old_extra_data =
static_cast<webkit_glue::WebURLRequestExtraDataImpl*>(
request.extraData());
- custom_user_agent = old_extra_data->custom_user_agent();
+ 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);
+ }
}
request.setExtraData(
new RequestExtraData(referrer_policy,
custom_user_agent,
+ requested_with,
(frame == top_frame),
frame->identifier(),
frame->parent() == top_frame,
« no previous file with comments | « content/renderer/pepper/pepper_url_request_unittest.cc ('k') | ppapi/tests/test_url_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698