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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 2504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 request.firstPartyForCookies(), 2515 request.firstPartyForCookies(),
2516 &new_url)) { 2516 &new_url)) {
2517 request.setURL(WebURL(new_url)); 2517 request.setURL(WebURL(new_url));
2518 } 2518 }
2519 2519
2520 if (internal_data->is_cache_policy_override_set()) 2520 if (internal_data->is_cache_policy_override_set())
2521 request.setCachePolicy(internal_data->cache_policy_override()); 2521 request.setCachePolicy(internal_data->cache_policy_override());
2522 2522
2523 // The request's extra data may indicate that we should set a custom user 2523 // The request's extra data may indicate that we should set a custom user
2524 // agent. This needs to be done here, after WebKit is through with setting the 2524 // agent. This needs to be done here, after WebKit is through with setting the
2525 // user agent on its own. 2525 // user agent on its own. Similarly, it may indicate that we should set an
2526 // X-Requested-With header. This must be done here to avoid breaking CORS
2527 // checks.
2526 WebString custom_user_agent; 2528 WebString custom_user_agent;
2529 WebString requested_with;
2527 if (request.extraData()) { 2530 if (request.extraData()) {
2528 RequestExtraData* old_extra_data = 2531 RequestExtraData* old_extra_data =
2529 static_cast<RequestExtraData*>( 2532 static_cast<RequestExtraData*>(request.extraData());
2530 request.extraData()); 2533
2531 custom_user_agent = old_extra_data->custom_user_agent(); 2534 custom_user_agent = old_extra_data->custom_user_agent();
2532
2533 if (!custom_user_agent.isNull()) { 2535 if (!custom_user_agent.isNull()) {
2534 if (custom_user_agent.isEmpty()) 2536 if (custom_user_agent.isEmpty())
2535 request.clearHTTPHeaderField("User-Agent"); 2537 request.clearHTTPHeaderField("User-Agent");
2536 else 2538 else
2537 request.setHTTPHeaderField("User-Agent", custom_user_agent); 2539 request.setHTTPHeaderField("User-Agent", custom_user_agent);
2538 } 2540 }
2541
2542 requested_with = old_extra_data->requested_with();
2543 if (!requested_with.isNull()) {
2544 if (requested_with.isEmpty())
2545 request.clearHTTPHeaderField("X-Requested-With");
2546 else
2547 request.setHTTPHeaderField("X-Requested-With", requested_with);
2548 }
2539 } 2549 }
2540 2550
2541 // Add the default accept header for frame request if it has not been set 2551 // Add the default accept header for frame request if it has not been set
2542 // already. 2552 // already.
2543 if ((request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || 2553 if ((request.frameType() == blink::WebURLRequest::FrameTypeTopLevel ||
2544 request.frameType() == blink::WebURLRequest::FrameTypeNested) && 2554 request.frameType() == blink::WebURLRequest::FrameTypeNested) &&
2545 request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) { 2555 request.httpHeaderField(WebString::fromUTF8(kAcceptHeader)).isEmpty()) {
2546 request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader), 2556 request.setHTTPHeaderField(WebString::fromUTF8(kAcceptHeader),
2547 WebString::fromUTF8(kDefaultAcceptHeader)); 2557 WebString::fromUTF8(kDefaultAcceptHeader));
2548 } 2558 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2591 parent_routing_id = -1; 2601 parent_routing_id = -1;
2592 } else if (parent->isWebLocalFrame()) { 2602 } else if (parent->isWebLocalFrame()) {
2593 parent_routing_id = FromWebFrame(parent)->GetRoutingID(); 2603 parent_routing_id = FromWebFrame(parent)->GetRoutingID();
2594 } else { 2604 } else {
2595 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id(); 2605 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id();
2596 } 2606 }
2597 2607
2598 RequestExtraData* extra_data = new RequestExtraData(); 2608 RequestExtraData* extra_data = new RequestExtraData();
2599 extra_data->set_visibility_state(render_view_->visibilityState()); 2609 extra_data->set_visibility_state(render_view_->visibilityState());
2600 extra_data->set_custom_user_agent(custom_user_agent); 2610 extra_data->set_custom_user_agent(custom_user_agent);
2611 extra_data->set_requested_with(requested_with);
2601 extra_data->set_render_frame_id(routing_id_); 2612 extra_data->set_render_frame_id(routing_id_);
2602 extra_data->set_is_main_frame(frame == top_frame); 2613 extra_data->set_is_main_frame(frame == top_frame);
2603 extra_data->set_frame_origin( 2614 extra_data->set_frame_origin(
2604 GURL(frame->document().securityOrigin().toString())); 2615 GURL(frame->document().securityOrigin().toString()));
2605 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); 2616 extra_data->set_parent_is_main_frame(frame->parent() == top_frame);
2606 extra_data->set_parent_render_frame_id(parent_routing_id); 2617 extra_data->set_parent_render_frame_id(parent_routing_id);
2607 extra_data->set_allow_download(navigation_state->allow_download()); 2618 extra_data->set_allow_download(navigation_state->allow_download());
2608 extra_data->set_transition_type(transition_type); 2619 extra_data->set_transition_type(transition_type);
2609 extra_data->set_should_replace_current_entry(should_replace_current_entry); 2620 extra_data->set_should_replace_current_entry(should_replace_current_entry);
2610 extra_data->set_transferred_request_child_id( 2621 extra_data->set_transferred_request_child_id(
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3719 3730
3720 #if defined(ENABLE_BROWSER_CDMS) 3731 #if defined(ENABLE_BROWSER_CDMS)
3721 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3732 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3722 if (!cdm_manager_) 3733 if (!cdm_manager_)
3723 cdm_manager_ = new RendererCdmManager(this); 3734 cdm_manager_ = new RendererCdmManager(this);
3724 return cdm_manager_; 3735 return cdm_manager_;
3725 } 3736 }
3726 #endif // defined(ENABLE_BROWSER_CDMS) 3737 #endif // defined(ENABLE_BROWSER_CDMS)
3727 3738
3728 } // namespace content 3739 } // namespace content
OLDNEW
« 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