| 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } | 548 } |
| 549 | 549 |
| 550 // Returns false unless this is a top-level navigation. | 550 // Returns false unless this is a top-level navigation. |
| 551 bool IsTopLevelNavigation(WebFrame* frame) { | 551 bool IsTopLevelNavigation(WebFrame* frame) { |
| 552 return frame->parent() == NULL; | 552 return frame->parent() == NULL; |
| 553 } | 553 } |
| 554 | 554 |
| 555 WebURLRequest CreateURLRequestForNavigation( | 555 WebURLRequest CreateURLRequestForNavigation( |
| 556 const CommonNavigationParams& common_params, | 556 const CommonNavigationParams& common_params, |
| 557 std::unique_ptr<StreamOverrideParameters> stream_override, | 557 std::unique_ptr<StreamOverrideParameters> stream_override, |
| 558 bool is_view_source_mode_enabled) { | 558 bool is_view_source_mode_enabled, |
| 559 int nav_entry_id) { |
| 559 WebURLRequest request(common_params.url); | 560 WebURLRequest request(common_params.url); |
| 560 if (is_view_source_mode_enabled) | 561 if (is_view_source_mode_enabled) |
| 561 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); | 562 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); |
| 562 | 563 |
| 563 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); | 564 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); |
| 564 if (common_params.referrer.url.is_valid()) { | 565 if (common_params.referrer.url.is_valid()) { |
| 565 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( | 566 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( |
| 566 common_params.referrer.policy, | 567 common_params.referrer.policy, |
| 567 common_params.url, | 568 common_params.url, |
| 568 WebString::fromUTF8(common_params.referrer.url.spec())); | 569 WebString::fromUTF8(common_params.referrer.url.spec())); |
| 569 if (!web_referrer.isEmpty()) { | 570 if (!web_referrer.isEmpty()) { |
| 570 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); | 571 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); |
| 571 request.addHTTPOriginIfNeeded( | 572 request.addHTTPOriginIfNeeded( |
| 572 WebSecurityOrigin(url::Origin(common_params.referrer.url))); | 573 WebSecurityOrigin(url::Origin(common_params.referrer.url))); |
| 573 } | 574 } |
| 574 } | 575 } |
| 575 | 576 |
| 576 request.setPreviewsState( | 577 request.setPreviewsState( |
| 577 static_cast<WebURLRequest::PreviewsState>(common_params.previews_state)); | 578 static_cast<WebURLRequest::PreviewsState>(common_params.previews_state)); |
| 578 | 579 |
| 579 RequestExtraData* extra_data = new RequestExtraData(); | 580 RequestExtraData* extra_data = new RequestExtraData(); |
| 580 extra_data->set_stream_override(std::move(stream_override)); | 581 extra_data->set_stream_override(std::move(stream_override)); |
| 582 extra_data->set_navigation_initiated_by_renderer(nav_entry_id == 0); |
| 581 request.setExtraData(extra_data); | 583 request.setExtraData(extra_data); |
| 582 | 584 |
| 583 // 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 |
| 584 // 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 |
| 585 // 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 |
| 586 // passed back to the browser in the DidCommitProvisionalLoad and the | 588 // passed back to the browser in the DidCommitProvisionalLoad and the |
| 587 // DocumentLoadComplete IPCs. | 589 // DocumentLoadComplete IPCs. |
| 588 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); | 590 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); |
| 589 request.setUiStartTime(ui_timestamp.InSecondsF()); | 591 request.setUiStartTime(ui_timestamp.InSecondsF()); |
| 590 request.setInputPerfMetricReportPolicy( | 592 request.setInputPerfMetricReportPolicy( |
| (...skipping 3751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4342 frame->document().isSecureContext()); | 4344 frame->document().isSecureContext()); |
| 4343 | 4345 |
| 4344 // Renderer process transfers apply only to navigational requests. | 4346 // Renderer process transfers apply only to navigational requests. |
| 4345 bool is_navigational_request = | 4347 bool is_navigational_request = |
| 4346 request.getFrameType() != WebURLRequest::FrameTypeNone; | 4348 request.getFrameType() != WebURLRequest::FrameTypeNone; |
| 4347 if (is_navigational_request) { | 4349 if (is_navigational_request) { |
| 4348 extra_data->set_transferred_request_child_id( | 4350 extra_data->set_transferred_request_child_id( |
| 4349 navigation_state->start_params().transferred_request_child_id); | 4351 navigation_state->start_params().transferred_request_child_id); |
| 4350 extra_data->set_transferred_request_request_id( | 4352 extra_data->set_transferred_request_request_id( |
| 4351 navigation_state->start_params().transferred_request_request_id); | 4353 navigation_state->start_params().transferred_request_request_id); |
| 4354 |
| 4355 // For navigation requests, we should copy the flag which indicates if this |
| 4356 // was a navigation initiated by the renderer to the new RequestExtraData |
| 4357 // instance. |
| 4358 RequestExtraData* current_request_data = static_cast<RequestExtraData*>( |
| 4359 request.getExtraData()); |
| 4360 if (current_request_data) { |
| 4361 extra_data->set_navigation_initiated_by_renderer( |
| 4362 current_request_data->navigation_initiated_by_renderer()); |
| 4363 } |
| 4352 } | 4364 } |
| 4353 | 4365 |
| 4354 request.setExtraData(extra_data); | 4366 request.setExtraData(extra_data); |
| 4355 | 4367 |
| 4356 if (request.getPreviewsState() == WebURLRequest::PreviewsUnspecified) { | 4368 if (request.getPreviewsState() == WebURLRequest::PreviewsUnspecified) { |
| 4357 if (is_main_frame_ && !navigation_state->request_committed()) { | 4369 if (is_main_frame_ && !navigation_state->request_committed()) { |
| 4358 request.setPreviewsState(static_cast<WebURLRequest::PreviewsState>( | 4370 request.setPreviewsState(static_cast<WebURLRequest::PreviewsState>( |
| 4359 navigation_state->common_params().previews_state)); | 4371 navigation_state->common_params().previews_state)); |
| 4360 } else { | 4372 } else { |
| 4361 request.setPreviewsState( | 4373 request.setPreviewsState( |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5202 frame_->setCommittedFirstRealLoad(); | 5214 frame_->setCommittedFirstRealLoad(); |
| 5203 | 5215 |
| 5204 pending_navigation_params_.reset(new NavigationParams( | 5216 pending_navigation_params_.reset(new NavigationParams( |
| 5205 common_params, StartNavigationParams(), request_params)); | 5217 common_params, StartNavigationParams(), request_params)); |
| 5206 | 5218 |
| 5207 // Send the provisional load failure. | 5219 // Send the provisional load failure. |
| 5208 blink::WebURLError error = | 5220 blink::WebURLError error = |
| 5209 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 5221 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
| 5210 WebURLRequest failed_request = CreateURLRequestForNavigation( | 5222 WebURLRequest failed_request = CreateURLRequestForNavigation( |
| 5211 common_params, std::unique_ptr<StreamOverrideParameters>(), | 5223 common_params, std::unique_ptr<StreamOverrideParameters>(), |
| 5212 frame_->isViewSourceModeEnabled()); | 5224 frame_->isViewSourceModeEnabled(), request_params.nav_entry_id); |
| 5213 | 5225 |
| 5214 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 5226 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
| 5215 // The browser expects this frame to be loading an error page. Inform it | 5227 // The browser expects this frame to be loading an error page. Inform it |
| 5216 // that the load stopped. | 5228 // that the load stopped. |
| 5217 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 5229 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 5218 browser_side_navigation_pending_ = false; | 5230 browser_side_navigation_pending_ = false; |
| 5219 return; | 5231 return; |
| 5220 } | 5232 } |
| 5221 | 5233 |
| 5222 // On load failure, a frame can ask its owner to render fallback content. | 5234 // On load failure, a frame can ask its owner to render fallback content. |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5893 blink::WebFrameLoadType load_type = | 5905 blink::WebFrameLoadType load_type = |
| 5894 common_params.should_replace_current_entry | 5906 common_params.should_replace_current_entry |
| 5895 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5907 ? blink::WebFrameLoadType::ReplaceCurrentItem |
| 5896 : blink::WebFrameLoadType::Standard; | 5908 : blink::WebFrameLoadType::Standard; |
| 5897 blink::WebHistoryLoadType history_load_type = | 5909 blink::WebHistoryLoadType history_load_type = |
| 5898 blink::WebHistoryDifferentDocumentLoad; | 5910 blink::WebHistoryDifferentDocumentLoad; |
| 5899 bool should_load_request = false; | 5911 bool should_load_request = false; |
| 5900 WebHistoryItem item_for_history_navigation; | 5912 WebHistoryItem item_for_history_navigation; |
| 5901 WebURLRequest request = | 5913 WebURLRequest request = |
| 5902 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5914 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
| 5903 frame_->isViewSourceModeEnabled()); | 5915 frame_->isViewSourceModeEnabled(), |
| 5916 request_params.nav_entry_id); |
| 5904 request.setFrameType(IsTopLevelNavigation(frame_) | 5917 request.setFrameType(IsTopLevelNavigation(frame_) |
| 5905 ? blink::WebURLRequest::FrameTypeTopLevel | 5918 ? blink::WebURLRequest::FrameTypeTopLevel |
| 5906 : blink::WebURLRequest::FrameTypeNested); | 5919 : blink::WebURLRequest::FrameTypeNested); |
| 5907 | 5920 |
| 5908 if (IsBrowserSideNavigationEnabled() && common_params.post_data) | 5921 if (IsBrowserSideNavigationEnabled() && common_params.post_data) |
| 5909 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); | 5922 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); |
| 5910 | 5923 |
| 5911 // Used to determine whether this frame is actually loading a request as part | 5924 // Used to determine whether this frame is actually loading a request as part |
| 5912 // of a history navigation. | 5925 // of a history navigation. |
| 5913 bool has_history_navigation_in_frame = false; | 5926 bool has_history_navigation_in_frame = false; |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6878 // event target. Potentially a Pepper plugin will receive the event. | 6891 // event target. Potentially a Pepper plugin will receive the event. |
| 6879 // In order to tell whether a plugin gets the last mouse event and which it | 6892 // In order to tell whether a plugin gets the last mouse event and which it |
| 6880 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6893 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6881 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6894 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6882 // |pepper_last_mouse_event_target_|. | 6895 // |pepper_last_mouse_event_target_|. |
| 6883 pepper_last_mouse_event_target_ = nullptr; | 6896 pepper_last_mouse_event_target_ = nullptr; |
| 6884 #endif | 6897 #endif |
| 6885 } | 6898 } |
| 6886 | 6899 |
| 6887 } // namespace content | 6900 } // namespace content |
| OLD | NEW |