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

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

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: PlzNavigate: identify same-page browser-initiated navigation. Created 4 years 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 } 544 }
545 545
546 // Returns false unless this is a top-level navigation. 546 // Returns false unless this is a top-level navigation.
547 bool IsTopLevelNavigation(WebFrame* frame) { 547 bool IsTopLevelNavigation(WebFrame* frame) {
548 return frame->parent() == NULL; 548 return frame->parent() == NULL;
549 } 549 }
550 550
551 WebURLRequest CreateURLRequestForNavigation( 551 WebURLRequest CreateURLRequestForNavigation(
552 const CommonNavigationParams& common_params, 552 const CommonNavigationParams& common_params,
553 std::unique_ptr<StreamOverrideParameters> stream_override, 553 std::unique_ptr<StreamOverrideParameters> stream_override,
554 bool is_view_source_mode_enabled) { 554 bool is_view_source_mode_enabled,
555 bool is_same_document_navigation) {
555 WebURLRequest request(common_params.url); 556 WebURLRequest request(common_params.url);
556 if (is_view_source_mode_enabled) 557 if (is_view_source_mode_enabled)
557 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); 558 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad);
558 559
559 request.setHTTPMethod(WebString::fromUTF8(common_params.method)); 560 request.setHTTPMethod(WebString::fromUTF8(common_params.method));
560 if (common_params.referrer.url.is_valid()) { 561 if (common_params.referrer.url.is_valid()) {
561 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( 562 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader(
562 common_params.referrer.policy, 563 common_params.referrer.policy,
563 common_params.url, 564 common_params.url,
564 WebString::fromUTF8(common_params.referrer.url.spec())); 565 WebString::fromUTF8(common_params.referrer.url.spec()));
565 if (!web_referrer.isEmpty()) { 566 if (!web_referrer.isEmpty()) {
566 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); 567 request.setHTTPReferrer(web_referrer, common_params.referrer.policy);
567 request.addHTTPOriginIfNeeded( 568 request.addHTTPOriginIfNeeded(
568 WebSecurityOrigin(url::Origin(common_params.referrer.url))); 569 WebSecurityOrigin(url::Origin(common_params.referrer.url)));
569 } 570 }
570 } 571 }
571 572
573 request.setIsSameDocumentNavigation(is_same_document_navigation);
574
572 request.setLoFiState( 575 request.setLoFiState(
573 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state)); 576 static_cast<WebURLRequest::LoFiState>(common_params.lofi_state));
574 577
575 RequestExtraData* extra_data = new RequestExtraData(); 578 RequestExtraData* extra_data = new RequestExtraData();
576 extra_data->set_stream_override(std::move(stream_override)); 579 extra_data->set_stream_override(std::move(stream_override));
577 request.setExtraData(extra_data); 580 request.setExtraData(extra_data);
578 581
579 // 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
580 // 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
581 // 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
(...skipping 4474 matching lines...) Expand 10 before | Expand all | Expand 10 after
5056 frame_->setCommittedFirstRealLoad(); 5059 frame_->setCommittedFirstRealLoad();
5057 5060
5058 pending_navigation_params_.reset(new NavigationParams( 5061 pending_navigation_params_.reset(new NavigationParams(
5059 common_params, StartNavigationParams(), request_params)); 5062 common_params, StartNavigationParams(), request_params));
5060 5063
5061 // Send the provisional load failure. 5064 // Send the provisional load failure.
5062 blink::WebURLError error = 5065 blink::WebURLError error =
5063 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); 5066 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code);
5064 WebURLRequest failed_request = CreateURLRequestForNavigation( 5067 WebURLRequest failed_request = CreateURLRequestForNavigation(
5065 common_params, std::unique_ptr<StreamOverrideParameters>(), 5068 common_params, std::unique_ptr<StreamOverrideParameters>(),
5066 frame_->isViewSourceModeEnabled()); 5069 frame_->isViewSourceModeEnabled(),
5070 false); // is_same_document_navigation
5067 5071
5068 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { 5072 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) {
5069 // The browser expects this frame to be loading an error page. Inform it 5073 // The browser expects this frame to be loading an error page. Inform it
5070 // that the load stopped. 5074 // that the load stopped.
5071 Send(new FrameHostMsg_DidStopLoading(routing_id_)); 5075 Send(new FrameHostMsg_DidStopLoading(routing_id_));
5072 browser_side_navigation_pending_ = false; 5076 browser_side_navigation_pending_ = false;
5073 return; 5077 return;
5074 } 5078 }
5075 5079
5076 // On load failure, a frame can ask its owner to render fallback content. 5080 // On load failure, a frame can ask its owner to render fallback content.
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
5737 blink::WebFrameLoadType load_type = 5741 blink::WebFrameLoadType load_type =
5738 common_params.should_replace_current_entry 5742 common_params.should_replace_current_entry
5739 ? blink::WebFrameLoadType::ReplaceCurrentItem 5743 ? blink::WebFrameLoadType::ReplaceCurrentItem
5740 : blink::WebFrameLoadType::Standard; 5744 : blink::WebFrameLoadType::Standard;
5741 blink::WebHistoryLoadType history_load_type = 5745 blink::WebHistoryLoadType history_load_type =
5742 blink::WebHistoryDifferentDocumentLoad; 5746 blink::WebHistoryDifferentDocumentLoad;
5743 bool should_load_request = false; 5747 bool should_load_request = false;
5744 WebHistoryItem item_for_history_navigation; 5748 WebHistoryItem item_for_history_navigation;
5745 WebURLRequest request = 5749 WebURLRequest request =
5746 CreateURLRequestForNavigation(common_params, std::move(stream_params), 5750 CreateURLRequestForNavigation(common_params, std::move(stream_params),
5747 frame_->isViewSourceModeEnabled()); 5751 frame_->isViewSourceModeEnabled(),
5752 request_params.is_same_document_navigation);
5748 request.setFrameType(IsTopLevelNavigation(frame_) 5753 request.setFrameType(IsTopLevelNavigation(frame_)
5749 ? blink::WebURLRequest::FrameTypeTopLevel 5754 ? blink::WebURLRequest::FrameTypeTopLevel
5750 : blink::WebURLRequest::FrameTypeNested); 5755 : blink::WebURLRequest::FrameTypeNested);
5751 5756
5752 if (IsBrowserSideNavigationEnabled() && common_params.post_data) 5757 if (IsBrowserSideNavigationEnabled() && common_params.post_data)
5753 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data)); 5758 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data));
5754 5759
5755 // Used to determine whether this frame is actually loading a request as part 5760 // Used to determine whether this frame is actually loading a request as part
5756 // of a history navigation. 5761 // of a history navigation.
5757 bool has_history_navigation_in_frame = false; 5762 bool has_history_navigation_in_frame = false;
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
6676 // event target. Potentially a Pepper plugin will receive the event. 6681 // event target. Potentially a Pepper plugin will receive the event.
6677 // In order to tell whether a plugin gets the last mouse event and which it 6682 // In order to tell whether a plugin gets the last mouse event and which it
6678 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6683 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6679 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6684 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6680 // |pepper_last_mouse_event_target_|. 6685 // |pepper_last_mouse_event_target_|.
6681 pepper_last_mouse_event_target_ = nullptr; 6686 pepper_last_mouse_event_target_ = nullptr;
6682 #endif 6687 #endif
6683 } 6688 }
6684 6689
6685 } // namespace content 6690 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698