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 |
576 request.setIsSameDocumentNavigation(is_same_document_navigation); | |
577 | |
575 request.setLoFiState( | 578 request.setLoFiState( |
576 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); | 579 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); |
577 | 580 |
578 RequestExtraData* extra_data = new RequestExtraData(); | 581 RequestExtraData* extra_data = new RequestExtraData(); |
579 extra_data->set_stream_override(std::move(stream_override)); | 582 extra_data->set_stream_override(std::move(stream_override)); |
580 request.setExtraData(extra_data); | 583 request.setExtraData(extra_data); |
581 | 584 |
582 // Set the ui timestamp for this navigation. Currently the timestamp here is | 585 // 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 | 586 // 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 | 587 // timestamp is converted to a double version supported by blink. It will be |
(...skipping 4609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5194 frame_->setCommittedFirstRealLoad(); | 5197 frame_->setCommittedFirstRealLoad(); |
5195 | 5198 |
5196 pending_navigation_params_.reset(new NavigationParams( | 5199 pending_navigation_params_.reset(new NavigationParams( |
5197 common_params, StartNavigationParams(), request_params)); | 5200 common_params, StartNavigationParams(), request_params)); |
5198 | 5201 |
5199 // Send the provisional load failure. | 5202 // Send the provisional load failure. |
5200 blink::WebURLError error = | 5203 blink::WebURLError error = |
5201 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 5204 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
5202 WebURLRequest failed_request = CreateURLRequestForNavigation( | 5205 WebURLRequest failed_request = CreateURLRequestForNavigation( |
5203 common_params, std::unique_ptr<StreamOverrideParameters>(), | 5206 common_params, std::unique_ptr<StreamOverrideParameters>(), |
5204 frame_->isViewSourceModeEnabled()); | 5207 frame_->isViewSourceModeEnabled(), |
5208 false); // is_same_document_navigation | |
5205 | 5209 |
5206 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 5210 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
5207 // The browser expects this frame to be loading an error page. Inform it | 5211 // The browser expects this frame to be loading an error page. Inform it |
5208 // that the load stopped. | 5212 // that the load stopped. |
5209 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 5213 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
5210 browser_side_navigation_pending_ = false; | 5214 browser_side_navigation_pending_ = false; |
5211 return; | 5215 return; |
5212 } | 5216 } |
5213 | 5217 |
5214 // On load failure, a frame can ask its owner to render fallback content. | 5218 // 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... | |
5888 // Create parameters for a standard navigation, indicating whether it should | 5892 // Create parameters for a standard navigation, indicating whether it should |
5889 // replace the current NavigationEntry. | 5893 // replace the current NavigationEntry. |
5890 blink::WebFrameLoadType load_type = | 5894 blink::WebFrameLoadType load_type = |
5891 common_params.should_replace_current_entry | 5895 common_params.should_replace_current_entry |
5892 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5896 ? blink::WebFrameLoadType::ReplaceCurrentItem |
5893 : blink::WebFrameLoadType::Standard; | 5897 : blink::WebFrameLoadType::Standard; |
5894 blink::WebHistoryLoadType history_load_type = | 5898 blink::WebHistoryLoadType history_load_type = |
5895 blink::WebHistoryDifferentDocumentLoad; | 5899 blink::WebHistoryDifferentDocumentLoad; |
5896 bool should_load_request = false; | 5900 bool should_load_request = false; |
5897 WebHistoryItem item_for_history_navigation; | 5901 WebHistoryItem item_for_history_navigation; |
5898 WebURLRequest request = | 5902 |
5899 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5903 bool is_same_page = request_params.is_same_document_fragment_change || |
5900 frame_->isViewSourceModeEnabled()); | 5904 request_params.is_same_document_history_load; |
5905 | |
5906 WebURLRequest request = CreateURLRequestForNavigation( | |
5907 common_params, std::move(stream_params), | |
5908 frame_->isViewSourceModeEnabled(), | |
5909 is_same_page); | |
5901 request.setFrameType(IsTopLevelNavigation(frame_) | 5910 request.setFrameType(IsTopLevelNavigation(frame_) |
5902 ? blink::WebURLRequest::FrameTypeTopLevel | 5911 ? blink::WebURLRequest::FrameTypeTopLevel |
5903 : blink::WebURLRequest::FrameTypeNested); | 5912 : blink::WebURLRequest::FrameTypeNested); |
5904 | 5913 |
5905 if (IsBrowserSideNavigationEnabled() && common_params.post_data) | 5914 if (IsBrowserSideNavigationEnabled() && common_params.post_data) |
5906 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); | 5915 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); |
5907 | 5916 |
5908 // Used to determine whether this frame is actually loading a request as part | 5917 // Used to determine whether this frame is actually loading a request as part |
5909 // of a history navigation. | 5918 // of a history navigation. |
5910 bool has_history_navigation_in_frame = false; | 5919 bool has_history_navigation_in_frame = false; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5961 } else { | 5970 } else { |
5962 // In --site-per-process, the browser process sends a single | 5971 // In --site-per-process, the browser process sends a single |
5963 // WebHistoryItem destined for this frame. | 5972 // WebHistoryItem destined for this frame. |
5964 // TODO(creis): Change PageState to FrameState. In the meantime, we | 5973 // TODO(creis): Change PageState to FrameState. In the meantime, we |
5965 // store the relevant frame's WebHistoryItem in the root of the | 5974 // store the relevant frame's WebHistoryItem in the root of the |
5966 // PageState. | 5975 // PageState. |
5967 item_for_history_navigation = entry->root(); | 5976 item_for_history_navigation = entry->root(); |
5968 history_load_type = request_params.is_same_document_history_load | 5977 history_load_type = request_params.is_same_document_history_load |
5969 ? blink::WebHistorySameDocumentLoad | 5978 ? blink::WebHistorySameDocumentLoad |
5970 : blink::WebHistoryDifferentDocumentLoad; | 5979 : blink::WebHistoryDifferentDocumentLoad; |
5980 | |
nasko
2017/01/13 02:51:10
nit: Why just an empty line here?
arthursonzogni
2017/01/13 15:18:37
Done.
| |
5971 load_type = request_params.is_history_navigation_in_new_child | 5981 load_type = request_params.is_history_navigation_in_new_child |
5972 ? blink::WebFrameLoadType::InitialHistoryLoad | 5982 ? blink::WebFrameLoadType::InitialHistoryLoad |
5973 : blink::WebFrameLoadType::BackForward; | 5983 : blink::WebFrameLoadType::BackForward; |
5974 should_load_request = true; | 5984 should_load_request = true; |
5975 | 5985 |
5976 // Keep track of which subframes the browser process has history items | 5986 // Keep track of which subframes the browser process has history items |
5977 // for during a history navigation. | 5987 // for during a history navigation. |
5978 history_subframe_unique_names_ = request_params.subframe_unique_names; | 5988 history_subframe_unique_names_ = request_params.subframe_unique_names; |
5979 | 5989 |
5980 if (history_load_type == blink::WebHistorySameDocumentLoad) { | 5990 if (history_load_type == blink::WebHistorySameDocumentLoad) { |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6863 // event target. Potentially a Pepper plugin will receive the event. | 6873 // event target. Potentially a Pepper plugin will receive the event. |
6864 // In order to tell whether a plugin gets the last mouse event and which it | 6874 // In order to tell whether a plugin gets the last mouse event and which it |
6865 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6875 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6866 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6876 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6867 // |pepper_last_mouse_event_target_|. | 6877 // |pepper_last_mouse_event_target_|. |
6868 pepper_last_mouse_event_target_ = nullptr; | 6878 pepper_last_mouse_event_target_ = nullptr; |
6869 #endif | 6879 #endif |
6870 } | 6880 } |
6871 | 6881 |
6872 } // namespace content | 6882 } // namespace content |
OLD | NEW |