Chromium Code Reviews| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 } | 547 } |
| 548 | 548 |
| 549 // Returns false unless this is a top-level navigation. | 549 // Returns false unless this is a top-level navigation. |
| 550 bool IsTopLevelNavigation(WebFrame* frame) { | 550 bool IsTopLevelNavigation(WebFrame* frame) { |
| 551 return frame->parent() == NULL; | 551 return frame->parent() == NULL; |
| 552 } | 552 } |
| 553 | 553 |
| 554 WebURLRequest CreateURLRequestForNavigation( | 554 WebURLRequest CreateURLRequestForNavigation( |
| 555 const CommonNavigationParams& common_params, | 555 const CommonNavigationParams& common_params, |
| 556 std::unique_ptr<StreamOverrideParameters> stream_override, | 556 std::unique_ptr<StreamOverrideParameters> stream_override, |
| 557 bool is_view_source_mode_enabled) { | 557 bool is_view_source_mode_enabled, |
| 558 bool is_same_document_navigation) { | |
| 558 WebURLRequest request(common_params.url); | 559 WebURLRequest request(common_params.url); |
| 559 if (is_view_source_mode_enabled) | 560 if (is_view_source_mode_enabled) |
| 560 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); | 561 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); |
| 561 | 562 |
| 562 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); | 563 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); |
| 563 if (common_params.referrer.url.is_valid()) { | 564 if (common_params.referrer.url.is_valid()) { |
| 564 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( | 565 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( |
| 565 common_params.referrer.policy, | 566 common_params.referrer.policy, |
| 566 common_params.url, | 567 common_params.url, |
| 567 WebString::fromUTF8(common_params.referrer.url.spec())); | 568 WebString::fromUTF8(common_params.referrer.url.spec())); |
| 568 if (!web_referrer.isEmpty()) { | 569 if (!web_referrer.isEmpty()) { |
| 569 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 570 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
| 570 request.addHTTPOriginIfNeeded( | 571 request.addHTTPOriginIfNeeded( |
| 571 WebSecurityOrigin(url::Origin(common_params.referrer.url))); | 572 WebSecurityOrigin(url::Origin(common_params.referrer.url))); |
| 572 } | 573 } |
| 573 } | 574 } |
| 574 | 575 |
| 575 request.setPreviewsState( | 576 request.setIsSameDocumentNavigation(is_same_document_navigation); |
| 576 static_cast<WebURLRequest::PreviewsState>(common_params.previews_state)); | |
|
nasko
2017/01/13 19:36:57
Hmm, removing this line seems incorrect. It is unr
arthursonzogni
2017/01/17 15:24:48
Oops sorry!
| |
| 577 | 577 |
| 578 RequestExtraData* extra_data = new RequestExtraData(); | 578 RequestExtraData* extra_data = new RequestExtraData(); |
| 579 extra_data->set_stream_override(std::move(stream_override)); | 579 extra_data->set_stream_override(std::move(stream_override)); |
| 580 request.setExtraData(extra_data); | 580 request.setExtraData(extra_data); |
| 581 | 581 |
| 582 // Set the ui timestamp for this navigation. Currently the timestamp here is | 582 // Set the ui timestamp for this navigation. Currently the timestamp here is |
| 583 // only non empty when the navigation was triggered by an Android intent. The | 583 // only non empty when the navigation was triggered by an Android intent. The |
| 584 // timestamp is converted to a double version supported by blink. It will be | 584 // timestamp is converted to a double version supported by blink. It will be |
| 585 // passed back to the browser in the DidCommitProvisionalLoad and the | 585 // passed back to the browser in the DidCommitProvisionalLoad and the |
| 586 // DocumentLoadComplete IPCs. | 586 // DocumentLoadComplete IPCs. |
| (...skipping 4620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5207 frame_->setCommittedFirstRealLoad(); | 5207 frame_->setCommittedFirstRealLoad(); |
| 5208 | 5208 |
| 5209 pending_navigation_params_.reset(new NavigationParams( | 5209 pending_navigation_params_.reset(new NavigationParams( |
| 5210 common_params, StartNavigationParams(), request_params)); | 5210 common_params, StartNavigationParams(), request_params)); |
| 5211 | 5211 |
| 5212 // Send the provisional load failure. | 5212 // Send the provisional load failure. |
| 5213 blink::WebURLError error = | 5213 blink::WebURLError error = |
| 5214 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 5214 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
| 5215 WebURLRequest failed_request = CreateURLRequestForNavigation( | 5215 WebURLRequest failed_request = CreateURLRequestForNavigation( |
| 5216 common_params, std::unique_ptr<StreamOverrideParameters>(), | 5216 common_params, std::unique_ptr<StreamOverrideParameters>(), |
| 5217 frame_->isViewSourceModeEnabled()); | 5217 frame_->isViewSourceModeEnabled(), |
| 5218 false); // is_same_document_navigation | |
| 5218 | 5219 |
| 5219 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 5220 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
| 5220 // The browser expects this frame to be loading an error page. Inform it | 5221 // The browser expects this frame to be loading an error page. Inform it |
| 5221 // that the load stopped. | 5222 // that the load stopped. |
| 5222 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 5223 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 5223 browser_side_navigation_pending_ = false; | 5224 browser_side_navigation_pending_ = false; |
| 5224 return; | 5225 return; |
| 5225 } | 5226 } |
| 5226 | 5227 |
| 5227 // On load failure, a frame can ask its owner to render fallback content. | 5228 // On load failure, a frame can ask its owner to render fallback content. |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5901 // Create parameters for a standard navigation, indicating whether it should | 5902 // Create parameters for a standard navigation, indicating whether it should |
| 5902 // replace the current NavigationEntry. | 5903 // replace the current NavigationEntry. |
| 5903 blink::WebFrameLoadType load_type = | 5904 blink::WebFrameLoadType load_type = |
| 5904 common_params.should_replace_current_entry | 5905 common_params.should_replace_current_entry |
| 5905 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5906 ? blink::WebFrameLoadType::ReplaceCurrentItem |
| 5906 : blink::WebFrameLoadType::Standard; | 5907 : blink::WebFrameLoadType::Standard; |
| 5907 blink::WebHistoryLoadType history_load_type = | 5908 blink::WebHistoryLoadType history_load_type = |
| 5908 blink::WebHistoryDifferentDocumentLoad; | 5909 blink::WebHistoryDifferentDocumentLoad; |
| 5909 bool should_load_request = false; | 5910 bool should_load_request = false; |
| 5910 WebHistoryItem item_for_history_navigation; | 5911 WebHistoryItem item_for_history_navigation; |
| 5911 WebURLRequest request = | 5912 |
| 5912 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5913 bool is_same_page = request_params.is_same_document_fragment_change || |
| 5913 frame_->isViewSourceModeEnabled()); | 5914 request_params.is_same_document_history_load; |
| 5915 | |
| 5916 WebURLRequest request = CreateURLRequestForNavigation( | |
| 5917 common_params, std::move(stream_params), | |
| 5918 frame_->isViewSourceModeEnabled(), | |
| 5919 is_same_page); | |
| 5914 request.setFrameType(IsTopLevelNavigation(frame_) | 5920 request.setFrameType(IsTopLevelNavigation(frame_) |
| 5915 ? blink::WebURLRequest::FrameTypeTopLevel | 5921 ? blink::WebURLRequest::FrameTypeTopLevel |
| 5916 : blink::WebURLRequest::FrameTypeNested); | 5922 : blink::WebURLRequest::FrameTypeNested); |
| 5917 | 5923 |
| 5918 if (IsBrowserSideNavigationEnabled() && common_params.post_data) | 5924 if (IsBrowserSideNavigationEnabled() && common_params.post_data) |
| 5919 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); | 5925 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); |
| 5920 | 5926 |
| 5921 // Used to determine whether this frame is actually loading a request as part | 5927 // Used to determine whether this frame is actually loading a request as part |
| 5922 // of a history navigation. | 5928 // of a history navigation. |
| 5923 bool has_history_navigation_in_frame = false; | 5929 bool has_history_navigation_in_frame = false; |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6877 // event target. Potentially a Pepper plugin will receive the event. | 6883 // event target. Potentially a Pepper plugin will receive the event. |
| 6878 // In order to tell whether a plugin gets the last mouse event and which it | 6884 // In order to tell whether a plugin gets the last mouse event and which it |
| 6879 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6885 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6880 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6886 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6881 // |pepper_last_mouse_event_target_|. | 6887 // |pepper_last_mouse_event_target_|. |
| 6882 pepper_last_mouse_event_target_ = nullptr; | 6888 pepper_last_mouse_event_target_ = nullptr; |
| 6883 #endif | 6889 #endif |
| 6884 } | 6890 } |
| 6885 | 6891 |
| 6886 } // namespace content | 6892 } // namespace content |
| OLD | NEW |