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

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

Issue 2741313002: Renamed WasWithinSamePage to WasWithinSameDocument. (Closed)
Patch Set: Addressed review comments Created 3 years, 9 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 3609 matching lines...) Expand 10 before | Expand all | Expand 10 after
3620 DocumentState* document_state = 3620 DocumentState* document_state =
3621 DocumentState::FromDataSource(frame->dataSource()); 3621 DocumentState::FromDataSource(frame->dataSource());
3622 NavigationStateImpl* navigation_state = 3622 NavigationStateImpl* navigation_state =
3623 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 3623 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3624 const WebURLResponse& web_url_response = frame->dataSource()->response(); 3624 const WebURLResponse& web_url_response = frame->dataSource()->response();
3625 WebURLResponseExtraDataImpl* extra_data = 3625 WebURLResponseExtraDataImpl* extra_data =
3626 GetExtraDataFromResponse(web_url_response); 3626 GetExtraDataFromResponse(web_url_response);
3627 // Only update the PreviewsState and effective connection type states for new 3627 // Only update the PreviewsState and effective connection type states for new
3628 // main frame documents. Subframes inherit from the main frame and should not 3628 // main frame documents. Subframes inherit from the main frame and should not
3629 // change at commit time. 3629 // change at commit time.
3630 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { 3630 if (is_main_frame_ && !navigation_state->WasWithinSameDocument()) {
3631 previews_state_ = 3631 previews_state_ =
3632 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; 3632 extra_data ? extra_data->previews_state() : PREVIEWS_OFF;
3633 3633
3634 // Set lite pages off if a lite page was not loaded for the main frame. 3634 // Set lite pages off if a lite page was not loaded for the main frame.
3635 if (web_url_response 3635 if (web_url_response
3636 .httpHeaderField( 3636 .httpHeaderField(
3637 WebString::fromUTF8(kChromeProxyContentTransformHeader)) 3637 WebString::fromUTF8(kChromeProxyContentTransformHeader))
3638 .utf8() != kChromeProxyLitePageDirective) { 3638 .utf8() != kChromeProxyLitePageDirective) {
3639 previews_state_ &= ~(SERVER_LITE_PAGE_ON); 3639 previews_state_ &= ~(SERVER_LITE_PAGE_ON);
3640 } 3640 }
3641 3641
3642 if (extra_data) { 3642 if (extra_data) {
3643 effective_connection_type_ = 3643 effective_connection_type_ =
3644 EffectiveConnectionTypeToWebEffectiveConnectionType( 3644 EffectiveConnectionTypeToWebEffectiveConnectionType(
3645 extra_data->effective_connection_type()); 3645 extra_data->effective_connection_type());
3646 } 3646 }
3647 } 3647 }
3648 3648
3649 if (proxy_routing_id_ != MSG_ROUTING_NONE) { 3649 if (proxy_routing_id_ != MSG_ROUTING_NONE) {
3650 // If this is a provisional frame associated with a proxy (i.e., a frame 3650 // If this is a provisional frame associated with a proxy (i.e., a frame
3651 // created for a remote-to-local navigation), swap it into the frame tree 3651 // created for a remote-to-local navigation), swap it into the frame tree
3652 // now. 3652 // now.
3653 if (!SwapIn()) 3653 if (!SwapIn())
3654 return; 3654 return;
3655 } 3655 }
3656 3656
3657 // For new page navigations, the browser process needs to be notified of the 3657 // For navigations that change the document, the browser process needs to be
3658 // first paint of that page, so it can cancel the timer that waits for it. 3658 // notified of the first paint of that page, so it can cancel the timer that
3659 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { 3659 // waits for it.
3660 if (is_main_frame_ && !navigation_state->WasWithinSameDocument()) {
3660 GetRenderWidget()->IncrementContentSourceId(); 3661 GetRenderWidget()->IncrementContentSourceId();
3661 render_view_->QueueMessage( 3662 render_view_->QueueMessage(
3662 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), 3663 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_),
3663 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); 3664 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE);
3664 } 3665 }
3665 3666
3666 // When we perform a new navigation, we need to update the last committed 3667 // When we perform a new navigation, we need to update the last committed
3667 // session history entry with state for the page we are leaving. Do this 3668 // session history entry with state for the page we are leaving. Do this
3668 // before updating the current history item. 3669 // before updating the current history item.
3669 SendUpdateState(); 3670 SendUpdateState();
(...skipping 30 matching lines...) Expand all
3700 !request_params.intended_as_new_entry) { 3701 !request_params.intended_as_new_entry) {
3701 // This is a successful session history navigation! 3702 // This is a successful session history navigation!
3702 render_view_->history_list_offset_ = 3703 render_view_->history_list_offset_ =
3703 request_params.pending_history_list_offset; 3704 request_params.pending_history_list_offset;
3704 } 3705 }
3705 } 3706 }
3706 3707
3707 for (auto& observer : render_view_->observers_) 3708 for (auto& observer : render_view_->observers_)
3708 observer.DidCommitProvisionalLoad(frame, is_new_navigation); 3709 observer.DidCommitProvisionalLoad(frame, is_new_navigation);
3709 for (auto& observer : observers_) { 3710 for (auto& observer : observers_) {
3710 observer.DidCommitProvisionalLoad(is_new_navigation, 3711 observer.DidCommitProvisionalLoad(
3711 navigation_state->WasWithinSamePage()); 3712 is_new_navigation, navigation_state->WasWithinSameDocument());
3712 } 3713 }
3713 3714
3714 if (!frame->parent()) { // Only for top frames. 3715 if (!frame->parent()) { // Only for top frames.
3715 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 3716 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
3716 if (render_thread_impl) { // Can be NULL in tests. 3717 if (render_thread_impl) { // Can be NULL in tests.
3717 render_thread_impl->histogram_customizer()-> 3718 render_thread_impl->histogram_customizer()->
3718 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(), 3719 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(),
3719 RenderView::GetRenderViewCount()); 3720 RenderView::GetRenderViewCount());
3720 // The scheduler isn't interested in history inert commits unless they 3721 // The scheduler isn't interested in history inert commits unless they
3721 // are reloads. 3722 // are reloads.
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
4039 blink::WebHistoryCommitType commit_type, 4040 blink::WebHistoryCommitType commit_type,
4040 bool content_initiated) { 4041 bool content_initiated) {
4041 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didNavigateWithinPage", 4042 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didNavigateWithinPage",
4042 "id", routing_id_); 4043 "id", routing_id_);
4043 DCHECK_EQ(frame_, frame); 4044 DCHECK_EQ(frame_, frame);
4044 DocumentState* document_state = 4045 DocumentState* document_state =
4045 DocumentState::FromDataSource(frame->dataSource()); 4046 DocumentState::FromDataSource(frame->dataSource());
4046 UpdateNavigationState(document_state, true /* was_within_same_page */, 4047 UpdateNavigationState(document_state, true /* was_within_same_page */,
4047 content_initiated); 4048 content_initiated);
4048 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 4049 static_cast<NavigationStateImpl*>(document_state->navigation_state())
4049 ->set_was_within_same_page(true); 4050 ->set_was_within_same_document(true);
4050 4051
4051 didCommitProvisionalLoad(frame, item, commit_type); 4052 didCommitProvisionalLoad(frame, item, commit_type);
4052 } 4053 }
4053 4054
4054 void RenderFrameImpl::didUpdateCurrentHistoryItem() { 4055 void RenderFrameImpl::didUpdateCurrentHistoryItem() {
4055 render_view_->StartNavStateSyncTimerIfNecessary(this); 4056 render_view_->StartNavStateSyncTimerIfNecessary(this);
4056 } 4057 }
4057 4058
4058 void RenderFrameImpl::didChangeThemeColor() { 4059 void RenderFrameImpl::didChangeThemeColor() {
4059 if (frame_->parent()) 4060 if (frame_->parent())
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
4845 // We need to track the RenderViewHost routing_id because of downstream 4846 // We need to track the RenderViewHost routing_id because of downstream
4846 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, 4847 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager,
4847 // ResourceDispatcherHostImpl, MediaStreamUIProxy, 4848 // ResourceDispatcherHostImpl, MediaStreamUIProxy,
4848 // SpeechRecognitionDispatcherHost and possibly others). They look up the view 4849 // SpeechRecognitionDispatcherHost and possibly others). They look up the view
4849 // based on the ID stored in the resource requests. Once those dependencies 4850 // based on the ID stored in the resource requests. Once those dependencies
4850 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the 4851 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the
4851 // client to be based on the routing_id of the RenderFrameHost. 4852 // client to be based on the routing_id of the RenderFrameHost.
4852 params.render_view_routing_id = render_view_->routing_id(); 4853 params.render_view_routing_id = render_view_->routing_id();
4853 params.socket_address.set_host(response.remoteIPAddress().utf8()); 4854 params.socket_address.set_host(response.remoteIPAddress().utf8());
4854 params.socket_address.set_port(response.remotePort()); 4855 params.socket_address.set_port(response.remotePort());
4855 params.was_within_same_page = navigation_state->WasWithinSamePage(); 4856 params.was_within_same_document = navigation_state->WasWithinSameDocument();
4856 4857
4857 WebDocument frame_document = frame->document(); 4858 WebDocument frame_document = frame->document();
4858 // Set the origin of the frame. This will be replicated to the corresponding 4859 // Set the origin of the frame. This will be replicated to the corresponding
4859 // RenderFrameProxies in other processes. 4860 // RenderFrameProxies in other processes.
4860 WebSecurityOrigin frame_origin = frame_document.getSecurityOrigin(); 4861 WebSecurityOrigin frame_origin = frame_document.getSecurityOrigin();
4861 params.origin = frame_origin; 4862 params.origin = frame_origin;
4862 4863
4863 params.insecure_request_policy = frame->getInsecureRequestPolicy(); 4864 params.insecure_request_policy = frame->getInsecureRequestPolicy();
4864 4865
4865 params.has_potentially_trustworthy_unique_origin = 4866 params.has_potentially_trustworthy_unique_origin =
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
5008 .allow_universal_access_from_file_urls) { 5009 .allow_universal_access_from_file_urls) {
5009 base::debug::SetCrashKeyValue("origin_mismatch_url", params.url.spec()); 5010 base::debug::SetCrashKeyValue("origin_mismatch_url", params.url.spec());
5010 base::debug::SetCrashKeyValue("origin_mismatch_origin", 5011 base::debug::SetCrashKeyValue("origin_mismatch_origin",
5011 params.origin.Serialize()); 5012 params.origin.Serialize());
5012 base::debug::SetCrashKeyValue("origin_mismatch_transition", 5013 base::debug::SetCrashKeyValue("origin_mismatch_transition",
5013 base::IntToString(params.transition)); 5014 base::IntToString(params.transition));
5014 base::debug::SetCrashKeyValue("origin_mismatch_redirects", 5015 base::debug::SetCrashKeyValue("origin_mismatch_redirects",
5015 base::IntToString(params.redirects.size())); 5016 base::IntToString(params.redirects.size()));
5016 base::debug::SetCrashKeyValue( 5017 base::debug::SetCrashKeyValue(
5017 "origin_mismatch_same_page", 5018 "origin_mismatch_same_page",
5018 base::IntToString(params.was_within_same_page)); 5019 base::IntToString(params.was_within_same_document));
5019 CHECK(params.origin.IsSamePhysicalOriginWith(url::Origin(params.url))) 5020 CHECK(params.origin.IsSamePhysicalOriginWith(url::Origin(params.url)))
5020 << " url:" << params.url << " origin:" << params.origin; 5021 << " url:" << params.url << " origin:" << params.origin;
5021 } 5022 }
5022 } 5023 }
5023 5024
5024 // This message needs to be sent before any of allowScripts(), 5025 // This message needs to be sent before any of allowScripts(),
5025 // allowImages(), allowPlugins() is called for the new page, so that when 5026 // allowImages(), allowPlugins() is called for the new page, so that when
5026 // these functions send a ViewHostMsg_ContentBlocked message, it arrives 5027 // these functions send a ViewHostMsg_ContentBlocked message, it arrives
5027 // after the FrameHostMsg_DidCommitProvisionalLoad message. 5028 // after the FrameHostMsg_DidCommitProvisionalLoad message.
5028 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 5029 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
6889 // event target. Potentially a Pepper plugin will receive the event. 6890 // event target. Potentially a Pepper plugin will receive the event.
6890 // In order to tell whether a plugin gets the last mouse event and which it 6891 // In order to tell whether a plugin gets the last mouse event and which it
6891 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6892 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6892 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6893 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6893 // |pepper_last_mouse_event_target_|. 6894 // |pepper_last_mouse_event_target_|.
6894 pepper_last_mouse_event_target_ = nullptr; 6895 pepper_last_mouse_event_target_ = nullptr;
6895 #endif 6896 #endif
6896 } 6897 }
6897 6898
6898 } // namespace content 6899 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/navigation_state_impl.cc ('k') | content/renderer/render_frame_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698