OLD | NEW |
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 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 } | 545 } |
546 | 546 |
547 // Returns false unless this is a top-level navigation. | 547 // Returns false unless this is a top-level navigation. |
548 bool IsTopLevelNavigation(WebFrame* frame) { | 548 bool IsTopLevelNavigation(WebFrame* frame) { |
549 return frame->parent() == NULL; | 549 return frame->parent() == NULL; |
550 } | 550 } |
551 | 551 |
552 WebURLRequest CreateURLRequestForNavigation( | 552 WebURLRequest CreateURLRequestForNavigation( |
553 const CommonNavigationParams& common_params, | 553 const CommonNavigationParams& common_params, |
554 std::unique_ptr<StreamOverrideParameters> stream_override, | 554 std::unique_ptr<StreamOverrideParameters> stream_override, |
555 bool is_view_source_mode_enabled) { | 555 bool is_view_source_mode_enabled, |
| 556 bool is_same_document_navigation) { |
556 WebURLRequest request(common_params.url); | 557 WebURLRequest request(common_params.url); |
557 if (is_view_source_mode_enabled) | 558 if (is_view_source_mode_enabled) |
558 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); | 559 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); |
559 | 560 |
560 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); | 561 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); |
561 if (common_params.referrer.url.is_valid()) { | 562 if (common_params.referrer.url.is_valid()) { |
562 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( | 563 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( |
563 common_params.referrer.policy, | 564 common_params.referrer.policy, |
564 common_params.url, | 565 common_params.url, |
565 WebString::fromUTF8(common_params.referrer.url.spec())); | 566 WebString::fromUTF8(common_params.referrer.url.spec())); |
566 if (!web_referrer.isEmpty()) { | 567 if (!web_referrer.isEmpty()) { |
567 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 568 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
568 request.addHTTPOriginIfNeeded( | 569 request.addHTTPOriginIfNeeded( |
569 WebSecurityOrigin(url::Origin(common_params.referrer.url))); | 570 WebSecurityOrigin(url::Origin(common_params.referrer.url))); |
570 } | 571 } |
571 } | 572 } |
572 | 573 |
| 574 request.setIsSameDocumentNavigation(is_same_document_navigation); |
| 575 |
573 request.setLoFiState( | 576 request.setLoFiState( |
574 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); | 577 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); |
575 | 578 |
576 RequestExtraData* extra_data = new RequestExtraData(); | 579 RequestExtraData* extra_data = new RequestExtraData(); |
577 extra_data->set_stream_override(std::move(stream_override)); | 580 extra_data->set_stream_override(std::move(stream_override)); |
578 request.setExtraData(extra_data); | 581 request.setExtraData(extra_data); |
579 | 582 |
580 // Set the ui timestamp for this navigation. Currently the timestamp here is | 583 // Set the ui timestamp for this navigation. Currently the timestamp here is |
581 // only non empty when the navigation was triggered by an Android intent. The | 584 // only non empty when the navigation was triggered by an Android intent. The |
582 // timestamp is converted to a double version supported by blink. It will be | 585 // timestamp is converted to a double version supported by blink. It will be |
(...skipping 4543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5126 frame_->setCommittedFirstRealLoad(); | 5129 frame_->setCommittedFirstRealLoad(); |
5127 | 5130 |
5128 pending_navigation_params_.reset(new NavigationParams( | 5131 pending_navigation_params_.reset(new NavigationParams( |
5129 common_params, StartNavigationParams(), request_params)); | 5132 common_params, StartNavigationParams(), request_params)); |
5130 | 5133 |
5131 // Send the provisional load failure. | 5134 // Send the provisional load failure. |
5132 blink::WebURLError error = | 5135 blink::WebURLError error = |
5133 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 5136 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
5134 WebURLRequest failed_request = CreateURLRequestForNavigation( | 5137 WebURLRequest failed_request = CreateURLRequestForNavigation( |
5135 common_params, std::unique_ptr<StreamOverrideParameters>(), | 5138 common_params, std::unique_ptr<StreamOverrideParameters>(), |
5136 frame_->isViewSourceModeEnabled()); | 5139 frame_->isViewSourceModeEnabled(), |
| 5140 false); // is_same_document_navigation |
5137 | 5141 |
5138 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 5142 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
5139 // The browser expects this frame to be loading an error page. Inform it | 5143 // The browser expects this frame to be loading an error page. Inform it |
5140 // that the load stopped. | 5144 // that the load stopped. |
5141 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 5145 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
5142 browser_side_navigation_pending_ = false; | 5146 browser_side_navigation_pending_ = false; |
5143 return; | 5147 return; |
5144 } | 5148 } |
5145 | 5149 |
5146 // On load failure, a frame can ask its owner to render fallback content. | 5150 // On load failure, a frame can ask its owner to render fallback content. |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5812 // Create parameters for a standard navigation, indicating whether it should | 5816 // Create parameters for a standard navigation, indicating whether it should |
5813 // replace the current NavigationEntry. | 5817 // replace the current NavigationEntry. |
5814 blink::WebFrameLoadType load_type = | 5818 blink::WebFrameLoadType load_type = |
5815 common_params.should_replace_current_entry | 5819 common_params.should_replace_current_entry |
5816 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5820 ? blink::WebFrameLoadType::ReplaceCurrentItem |
5817 : blink::WebFrameLoadType::Standard; | 5821 : blink::WebFrameLoadType::Standard; |
5818 blink::WebHistoryLoadType history_load_type = | 5822 blink::WebHistoryLoadType history_load_type = |
5819 blink::WebHistoryDifferentDocumentLoad; | 5823 blink::WebHistoryDifferentDocumentLoad; |
5820 bool should_load_request = false; | 5824 bool should_load_request = false; |
5821 WebHistoryItem item_for_history_navigation; | 5825 WebHistoryItem item_for_history_navigation; |
5822 WebURLRequest request = | 5826 |
5823 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5827 bool is_same_page = request_params.is_same_document_fragment_change || |
5824 frame_->isViewSourceModeEnabled()); | 5828 request_params.is_same_document_history_load; |
| 5829 |
| 5830 WebURLRequest request = CreateURLRequestForNavigation( |
| 5831 common_params, std::move(stream_params), |
| 5832 frame_->isViewSourceModeEnabled(), |
| 5833 is_same_page); |
5825 request.setFrameType(IsTopLevelNavigation(frame_) | 5834 request.setFrameType(IsTopLevelNavigation(frame_) |
5826 ? blink::WebURLRequest::FrameTypeTopLevel | 5835 ? blink::WebURLRequest::FrameTypeTopLevel |
5827 : blink::WebURLRequest::FrameTypeNested); | 5836 : blink::WebURLRequest::FrameTypeNested); |
5828 | 5837 |
5829 if (IsBrowserSideNavigationEnabled() && common_params.post_data) | 5838 if (IsBrowserSideNavigationEnabled() && common_params.post_data) |
5830 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); | 5839 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); |
5831 | 5840 |
5832 // Used to determine whether this frame is actually loading a request as part | 5841 // Used to determine whether this frame is actually loading a request as part |
5833 // of a history navigation. | 5842 // of a history navigation. |
5834 bool has_history_navigation_in_frame = false; | 5843 bool has_history_navigation_in_frame = false; |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6776 // event target. Potentially a Pepper plugin will receive the event. | 6785 // event target. Potentially a Pepper plugin will receive the event. |
6777 // In order to tell whether a plugin gets the last mouse event and which it | 6786 // In order to tell whether a plugin gets the last mouse event and which it |
6778 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6787 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6779 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6788 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6780 // |pepper_last_mouse_event_target_|. | 6789 // |pepper_last_mouse_event_target_|. |
6781 pepper_last_mouse_event_target_ = nullptr; | 6790 pepper_last_mouse_event_target_ = nullptr; |
6782 #endif | 6791 #endif |
6783 } | 6792 } |
6784 | 6793 |
6785 } // namespace content | 6794 } // namespace content |
OLD | NEW |