Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2652123002: PlzNavigate: Attempt to fix blink layout tests which fail due to duplicate output from WebFrameClie… (Closed)
Patch Set: Fix redness Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 549 }
550 550
551 // Returns false unless this is a top-level navigation. 551 // Returns false unless this is a top-level navigation.
552 bool IsTopLevelNavigation(WebFrame* frame) { 552 bool IsTopLevelNavigation(WebFrame* frame) {
553 return frame->parent() == NULL; 553 return frame->parent() == NULL;
554 } 554 }
555 555
556 WebURLRequest CreateURLRequestForNavigation( 556 WebURLRequest CreateURLRequestForNavigation(
557 const CommonNavigationParams& common_params, 557 const CommonNavigationParams& common_params,
558 std::unique_ptr<StreamOverrideParameters> stream_override, 558 std::unique_ptr<StreamOverrideParameters> stream_override,
559 bool is_view_source_mode_enabled) { 559 bool is_view_source_mode_enabled,
560 int nav_entry_id) {
560 WebURLRequest request(common_params.url); 561 WebURLRequest request(common_params.url);
561 if (is_view_source_mode_enabled) 562 if (is_view_source_mode_enabled)
562 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); 563 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad);
563 564
564 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); 565 request.setHTTPMethod(WebString::fromUTF8(common_params.method));
565 if (common_params.referrer.url.is_valid()) { 566 if (common_params.referrer.url.is_valid()) {
566 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( 567 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader(
567 common_params.referrer.policy, 568 common_params.referrer.policy,
568 common_params.url, 569 common_params.url,
569 WebString::fromUTF8(common_params.referrer.url.spec())); 570 WebString::fromUTF8(common_params.referrer.url.spec()));
570 if (!web_referrer.isEmpty()) { 571 if (!web_referrer.isEmpty()) {
571 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); 572 request.setHTTPReferrer(web_referrer, common_params.referrer.policy);
572 request.addHTTPOriginIfNeeded( 573 request.addHTTPOriginIfNeeded(
573 WebSecurityOrigin(url::Origin(common_params.referrer.url))); 574 WebSecurityOrigin(url::Origin(common_params.referrer.url)));
574 } 575 }
575 } 576 }
576 577
577 request.setPreviewsState( 578 request.setPreviewsState(
578 static_cast<WebURLRequest::PreviewsState>(common_params.previews_state)); 579 static_cast<WebURLRequest::PreviewsState>(common_params.previews_state));
579 580
580 RequestExtraData* extra_data = new RequestExtraData(); 581 RequestExtraData* extra_data = new RequestExtraData();
581 extra_data->set_stream_override(std::move(stream_override)); 582 extra_data->set_stream_override(std::move(stream_override));
583 extra_data->set_navigation_initiated_by_renderer(nav_entry_id == 0);
582 request.setExtraData(extra_data); 584 request.setExtraData(extra_data);
583 585
584 // Set the ui timestamp for this navigation. Currently the timestamp here is 586 // Set the ui timestamp for this navigation. Currently the timestamp here is
585 // only non empty when the navigation was triggered by an Android intent. The 587 // only non empty when the navigation was triggered by an Android intent. The
586 // timestamp is converted to a double version supported by blink. It will be 588 // timestamp is converted to a double version supported by blink. It will be
587 // passed back to the browser in the DidCommitProvisionalLoad and the 589 // passed back to the browser in the DidCommitProvisionalLoad and the
588 // DocumentLoadComplete IPCs. 590 // DocumentLoadComplete IPCs.
589 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); 591 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks();
590 request.setUiStartTime(ui_timestamp.InSecondsF()); 592 request.setUiStartTime(ui_timestamp.InSecondsF());
591 request.setInputPerfMetricReportPolicy( 593 request.setInputPerfMetricReportPolicy(
(...skipping 3736 matching lines...) Expand 10 before | Expand all | Expand 10 after
4328 frame->document().isSecureContext()); 4330 frame->document().isSecureContext());
4329 4331
4330 // Renderer process transfers apply only to navigational requests. 4332 // Renderer process transfers apply only to navigational requests.
4331 bool is_navigational_request = 4333 bool is_navigational_request =
4332 request.getFrameType() != WebURLRequest::FrameTypeNone; 4334 request.getFrameType() != WebURLRequest::FrameTypeNone;
4333 if (is_navigational_request) { 4335 if (is_navigational_request) {
4334 extra_data->set_transferred_request_child_id( 4336 extra_data->set_transferred_request_child_id(
4335 navigation_state->start_params().transferred_request_child_id); 4337 navigation_state->start_params().transferred_request_child_id);
4336 extra_data->set_transferred_request_request_id( 4338 extra_data->set_transferred_request_request_id(
4337 navigation_state->start_params().transferred_request_request_id); 4339 navigation_state->start_params().transferred_request_request_id);
4340
4341 // For navigation requests, we should copy the flag which indicates if this
4342 // was a navigation initiated by the renderer to the new RequestExtraData
4343 // instance.
4344 RequestExtraData* current_request_data = static_cast<RequestExtraData*>(
4345 request.getExtraData());
4346 if (current_request_data) {
4347 extra_data->set_navigation_initiated_by_renderer(
4348 current_request_data->navigation_initiated_by_renderer());
4349 }
4338 } 4350 }
4339 4351
4340 request.setExtraData(extra_data); 4352 request.setExtraData(extra_data);
4341 4353
4342 if (request.getPreviewsState() == WebURLRequest::PreviewsUnspecified) { 4354 if (request.getPreviewsState() == WebURLRequest::PreviewsUnspecified) {
4343 if (is_main_frame_ && !navigation_state->request_committed()) { 4355 if (is_main_frame_ && !navigation_state->request_committed()) {
4344 request.setPreviewsState(static_cast<WebURLRequest::PreviewsState>( 4356 request.setPreviewsState(static_cast<WebURLRequest::PreviewsState>(
4345 navigation_state->common_params().previews_state)); 4357 navigation_state->common_params().previews_state));
4346 } else { 4358 } else {
4347 request.setPreviewsState( 4359 request.setPreviewsState(
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
5165 frame_->setCommittedFirstRealLoad(); 5177 frame_->setCommittedFirstRealLoad();
5166 5178
5167 pending_navigation_params_.reset(new NavigationParams( 5179 pending_navigation_params_.reset(new NavigationParams(
5168 common_params, StartNavigationParams(), request_params)); 5180 common_params, StartNavigationParams(), request_params));
5169 5181
5170 // Send the provisional load failure. 5182 // Send the provisional load failure.
5171 blink::WebURLError error = 5183 blink::WebURLError error =
5172 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); 5184 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code);
5173 WebURLRequest failed_request = CreateURLRequestForNavigation( 5185 WebURLRequest failed_request = CreateURLRequestForNavigation(
5174 common_params, std::unique_ptr<StreamOverrideParameters>(), 5186 common_params, std::unique_ptr<StreamOverrideParameters>(),
5175 frame_->isViewSourceModeEnabled()); 5187 frame_->isViewSourceModeEnabled(), request_params.nav_entry_id);
5176 5188
5177 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { 5189 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) {
5178 // The browser expects this frame to be loading an error page. Inform it 5190 // The browser expects this frame to be loading an error page. Inform it
5179 // that the load stopped. 5191 // that the load stopped.
5180 Send(new FrameHostMsg_DidStopLoading(routing_id_)); 5192 Send(new FrameHostMsg_DidStopLoading(routing_id_));
5181 browser_side_navigation_pending_ = false; 5193 browser_side_navigation_pending_ = false;
5182 return; 5194 return;
5183 } 5195 }
5184 5196
5185 // On load failure, a frame can ask its owner to render fallback content. 5197 // On load failure, a frame can ask its owner to render fallback content.
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
5839 blink::WebFrameLoadType load_type = 5851 blink::WebFrameLoadType load_type =
5840 common_params.should_replace_current_entry 5852 common_params.should_replace_current_entry
5841 ? blink::WebFrameLoadType::ReplaceCurrentItem 5853 ? blink::WebFrameLoadType::ReplaceCurrentItem
5842 : blink::WebFrameLoadType::Standard; 5854 : blink::WebFrameLoadType::Standard;
5843 blink::WebHistoryLoadType history_load_type = 5855 blink::WebHistoryLoadType history_load_type =
5844 blink::WebHistoryDifferentDocumentLoad; 5856 blink::WebHistoryDifferentDocumentLoad;
5845 bool should_load_request = false; 5857 bool should_load_request = false;
5846 WebHistoryItem item_for_history_navigation; 5858 WebHistoryItem item_for_history_navigation;
5847 WebURLRequest request = 5859 WebURLRequest request =
5848 CreateURLRequestForNavigation(common_params, std::move(stream_params), 5860 CreateURLRequestForNavigation(common_params, std::move(stream_params),
5849 frame_->isViewSourceModeEnabled()); 5861 frame_->isViewSourceModeEnabled(),
5862 request_params.nav_entry_id);
5850 request.setFrameType(IsTopLevelNavigation(frame_) 5863 request.setFrameType(IsTopLevelNavigation(frame_)
5851 ? blink::WebURLRequest::FrameTypeTopLevel 5864 ? blink::WebURLRequest::FrameTypeTopLevel
5852 : blink::WebURLRequest::FrameTypeNested); 5865 : blink::WebURLRequest::FrameTypeNested);
5853 5866
5854 if (IsBrowserSideNavigationEnabled() && common_params.post_data) 5867 if (IsBrowserSideNavigationEnabled() && common_params.post_data)
5855 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); 5868 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data));
5856 5869
5857 // Used to determine whether this frame is actually loading a request as part 5870 // Used to determine whether this frame is actually loading a request as part
5858 // of a history navigation. 5871 // of a history navigation.
5859 bool has_history_navigation_in_frame = false; 5872 bool has_history_navigation_in_frame = false;
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
6800 // event target. Potentially a Pepper plugin will receive the event. 6813 // event target. Potentially a Pepper plugin will receive the event.
6801 // In order to tell whether a plugin gets the last mouse event and which it 6814 // In order to tell whether a plugin gets the last mouse event and which it
6802 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6815 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6803 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6816 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6804 // |pepper_last_mouse_event_target_|. 6817 // |pepper_last_mouse_event_target_|.
6805 pepper_last_mouse_event_target_ = nullptr; 6818 pepper_last_mouse_event_target_ = nullptr;
6806 #endif 6819 #endif
6807 } 6820 }
6808 6821
6809 } // namespace content 6822 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/layouttest_support.h ('k') | content/shell/renderer/layout_test/blink_test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698