OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3662 WebKit::WebReferrerPolicy referrer_policy; | 3662 WebKit::WebReferrerPolicy referrer_policy; |
3663 if (document_state && document_state->is_referrer_policy_set()) { | 3663 if (document_state && document_state->is_referrer_policy_set()) { |
3664 referrer_policy = document_state->referrer_policy(); | 3664 referrer_policy = document_state->referrer_policy(); |
3665 document_state->clear_referrer_policy(); | 3665 document_state->clear_referrer_policy(); |
3666 } else { | 3666 } else { |
3667 referrer_policy = frame->document().referrerPolicy(); | 3667 referrer_policy = frame->document().referrerPolicy(); |
3668 } | 3668 } |
3669 | 3669 |
3670 // The request's extra data may indicate that we should set a custom user | 3670 // The request's extra data may indicate that we should set a custom user |
3671 // agent. This needs to be done here, after WebKit is through with setting the | 3671 // agent. This needs to be done here, after WebKit is through with setting the |
3672 // user agent on its own. | 3672 // user agent on its own. Similarly, it may indicate that we should set an |
| 3673 // X-Requested-With header. This must be done here to avoid breaking CORS |
| 3674 // checks. |
3673 WebString custom_user_agent; | 3675 WebString custom_user_agent; |
| 3676 WebString requested_with; |
3674 if (request.extraData()) { | 3677 if (request.extraData()) { |
3675 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = | 3678 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = |
3676 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( | 3679 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( |
3677 request.extraData()); | 3680 request.extraData()); |
| 3681 |
3678 custom_user_agent = old_extra_data->custom_user_agent(); | 3682 custom_user_agent = old_extra_data->custom_user_agent(); |
3679 | |
3680 if (!custom_user_agent.isNull()) { | 3683 if (!custom_user_agent.isNull()) { |
3681 if (custom_user_agent.isEmpty()) | 3684 if (custom_user_agent.isEmpty()) |
3682 request.clearHTTPHeaderField("User-Agent"); | 3685 request.clearHTTPHeaderField("User-Agent"); |
3683 else | 3686 else |
3684 request.setHTTPHeaderField("User-Agent", custom_user_agent); | 3687 request.setHTTPHeaderField("User-Agent", custom_user_agent); |
3685 } | 3688 } |
| 3689 |
| 3690 requested_with = old_extra_data->requested_with(); |
| 3691 if (!requested_with.isNull()) { |
| 3692 if (requested_with.isEmpty()) |
| 3693 request.clearHTTPHeaderField("X-Requested-With"); |
| 3694 else |
| 3695 request.setHTTPHeaderField("X-Requested-With", requested_with); |
| 3696 } |
3686 } | 3697 } |
3687 | 3698 |
3688 request.setExtraData( | 3699 request.setExtraData( |
3689 new RequestExtraData(referrer_policy, | 3700 new RequestExtraData(referrer_policy, |
3690 custom_user_agent, | 3701 custom_user_agent, |
| 3702 requested_with, |
3691 (frame == top_frame), | 3703 (frame == top_frame), |
3692 frame->identifier(), | 3704 frame->identifier(), |
3693 frame->parent() == top_frame, | 3705 frame->parent() == top_frame, |
3694 frame->parent() ? frame->parent()->identifier() : -1, | 3706 frame->parent() ? frame->parent()->identifier() : -1, |
3695 navigation_state->allow_download(), | 3707 navigation_state->allow_download(), |
3696 transition_type, | 3708 transition_type, |
3697 navigation_state->transferred_request_child_id(), | 3709 navigation_state->transferred_request_child_id(), |
3698 navigation_state->transferred_request_request_id())); | 3710 navigation_state->transferred_request_request_id())); |
3699 | 3711 |
3700 DocumentState* top_document_state = | 3712 DocumentState* top_document_state = |
(...skipping 2801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6502 } | 6514 } |
6503 #endif | 6515 #endif |
6504 | 6516 |
6505 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6517 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
6506 TransportDIB::Handle dib_handle) { | 6518 TransportDIB::Handle dib_handle) { |
6507 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6519 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
6508 RenderProcess::current()->ReleaseTransportDIB(dib); | 6520 RenderProcess::current()->ReleaseTransportDIB(dib); |
6509 } | 6521 } |
6510 | 6522 |
6511 } // namespace content | 6523 } // namespace content |
OLD | NEW |