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 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3577 DocumentState* document_state = | 3577 DocumentState* document_state = |
3578 DocumentState::FromDataSource(frame->dataSource()); | 3578 DocumentState::FromDataSource(frame->dataSource()); |
3579 NavigationStateImpl* navigation_state = | 3579 NavigationStateImpl* navigation_state = |
3580 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3580 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
3581 const WebURLResponse& web_url_response = frame->dataSource()->response(); | 3581 const WebURLResponse& web_url_response = frame->dataSource()->response(); |
3582 WebURLResponseExtraDataImpl* extra_data = | 3582 WebURLResponseExtraDataImpl* extra_data = |
3583 GetExtraDataFromResponse(web_url_response); | 3583 GetExtraDataFromResponse(web_url_response); |
3584 // Only update the PreviewsState and effective connection type states for new | 3584 // Only update the PreviewsState and effective connection type states for new |
3585 // main frame documents. Subframes inherit from the main frame and should not | 3585 // main frame documents. Subframes inherit from the main frame and should not |
3586 // change at commit time. | 3586 // change at commit time. |
3587 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3587 if (is_main_frame_ && !navigation_state->WasWithinSameDocument()) { |
3588 previews_state_ = | 3588 previews_state_ = |
3589 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; | 3589 extra_data ? extra_data->previews_state() : PREVIEWS_OFF; |
3590 | 3590 |
3591 // Set lite pages off if a lite page was not loaded for the main frame. | 3591 // Set lite pages off if a lite page was not loaded for the main frame. |
3592 if (web_url_response | 3592 if (web_url_response |
3593 .httpHeaderField( | 3593 .httpHeaderField( |
3594 WebString::fromUTF8(kChromeProxyContentTransformHeader)) | 3594 WebString::fromUTF8(kChromeProxyContentTransformHeader)) |
3595 .utf8() != kChromeProxyLitePageDirective) { | 3595 .utf8() != kChromeProxyLitePageDirective) { |
3596 previews_state_ &= ~(SERVER_LITE_PAGE_ON); | 3596 previews_state_ &= ~(SERVER_LITE_PAGE_ON); |
3597 } | 3597 } |
3598 | 3598 |
3599 if (extra_data) { | 3599 if (extra_data) { |
3600 effective_connection_type_ = | 3600 effective_connection_type_ = |
3601 EffectiveConnectionTypeToWebEffectiveConnectionType( | 3601 EffectiveConnectionTypeToWebEffectiveConnectionType( |
3602 extra_data->effective_connection_type()); | 3602 extra_data->effective_connection_type()); |
3603 } | 3603 } |
3604 } | 3604 } |
3605 | 3605 |
3606 if (proxy_routing_id_ != MSG_ROUTING_NONE) { | 3606 if (proxy_routing_id_ != MSG_ROUTING_NONE) { |
3607 // If this is a provisional frame associated with a proxy (i.e., a frame | 3607 // If this is a provisional frame associated with a proxy (i.e., a frame |
3608 // created for a remote-to-local navigation), swap it into the frame tree | 3608 // created for a remote-to-local navigation), swap it into the frame tree |
3609 // now. | 3609 // now. |
3610 if (!SwapIn()) | 3610 if (!SwapIn()) |
3611 return; | 3611 return; |
3612 } | 3612 } |
3613 | 3613 |
3614 // For new page navigations, the browser process needs to be notified of the | 3614 // For navigations that change the document, the browser process needs to be |
3615 // first paint of that page, so it can cancel the timer that waits for it. | 3615 // notified of the first paint of that page, so it can cancel the timer that |
3616 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3616 // waits for it. |
3617 if (is_main_frame_ && !navigation_state->WasWithinSameDocument()) { | |
3617 GetRenderWidget()->IncrementContentSourceId(); | 3618 GetRenderWidget()->IncrementContentSourceId(); |
3618 render_view_->QueueMessage( | 3619 render_view_->QueueMessage( |
3619 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), | 3620 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), |
3620 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 3621 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
3621 } | 3622 } |
3622 | 3623 |
3623 // When we perform a new navigation, we need to update the last committed | 3624 // When we perform a new navigation, we need to update the last committed |
3624 // session history entry with state for the page we are leaving. Do this | 3625 // session history entry with state for the page we are leaving. Do this |
3625 // before updating the current history item. | 3626 // before updating the current history item. |
3626 SendUpdateState(); | 3627 SendUpdateState(); |
(...skipping 30 matching lines...) Expand all Loading... | |
3657 !request_params.intended_as_new_entry) { | 3658 !request_params.intended_as_new_entry) { |
3658 // This is a successful session history navigation! | 3659 // This is a successful session history navigation! |
3659 render_view_->history_list_offset_ = | 3660 render_view_->history_list_offset_ = |
3660 request_params.pending_history_list_offset; | 3661 request_params.pending_history_list_offset; |
3661 } | 3662 } |
3662 } | 3663 } |
3663 | 3664 |
3664 for (auto& observer : render_view_->observers_) | 3665 for (auto& observer : render_view_->observers_) |
3665 observer.DidCommitProvisionalLoad(frame, is_new_navigation); | 3666 observer.DidCommitProvisionalLoad(frame, is_new_navigation); |
3666 for (auto& observer : observers_) { | 3667 for (auto& observer : observers_) { |
3667 observer.DidCommitProvisionalLoad(is_new_navigation, | 3668 observer.DidCommitProvisionalLoad( |
3668 navigation_state->WasWithinSamePage()); | 3669 is_new_navigation, navigation_state->WasWithinSameDocument()); |
3669 } | 3670 } |
3670 | 3671 |
3671 if (!frame->parent()) { // Only for top frames. | 3672 if (!frame->parent()) { // Only for top frames. |
3672 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 3673 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
3673 if (render_thread_impl) { // Can be NULL in tests. | 3674 if (render_thread_impl) { // Can be NULL in tests. |
3674 render_thread_impl->histogram_customizer()-> | 3675 render_thread_impl->histogram_customizer()-> |
3675 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(), | 3676 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(), |
3676 RenderView::GetRenderViewCount()); | 3677 RenderView::GetRenderViewCount()); |
3677 // The scheduler isn't interested in history inert commits unless they | 3678 // The scheduler isn't interested in history inert commits unless they |
3678 // are reloads. | 3679 // are reloads. |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3993 void RenderFrameImpl::didNavigateWithinPage( | 3994 void RenderFrameImpl::didNavigateWithinPage( |
3994 blink::WebLocalFrame* frame, | 3995 blink::WebLocalFrame* frame, |
3995 const blink::WebHistoryItem& item, | 3996 const blink::WebHistoryItem& item, |
3996 blink::WebHistoryCommitType commit_type, | 3997 blink::WebHistoryCommitType commit_type, |
3997 bool content_initiated) { | 3998 bool content_initiated) { |
3998 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didNavigateWithinPage", | 3999 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didNavigateWithinPage", |
3999 "id", routing_id_); | 4000 "id", routing_id_); |
4000 DCHECK_EQ(frame_, frame); | 4001 DCHECK_EQ(frame_, frame); |
4001 DocumentState* document_state = | 4002 DocumentState* document_state = |
4002 DocumentState::FromDataSource(frame->dataSource()); | 4003 DocumentState::FromDataSource(frame->dataSource()); |
4003 UpdateNavigationState(document_state, true /* was_within_same_page */, | 4004 UpdateNavigationState(document_state, true /* was_within_same_page */, |
Charlie Reis
2017/03/15 02:43:10
You're planning to update this (and the method nam
Eugene But (OOO till 7-30)
2017/03/15 16:16:17
Yes. There are many |SamePage| and |same_page| nam
| |
4004 content_initiated); | 4005 content_initiated); |
4005 static_cast<NavigationStateImpl*>(document_state->navigation_state()) | 4006 static_cast<NavigationStateImpl*>(document_state->navigation_state()) |
4006 ->set_was_within_same_page(true); | 4007 ->set_was_within_same_document(true); |
4007 | 4008 |
4008 didCommitProvisionalLoad(frame, item, commit_type); | 4009 didCommitProvisionalLoad(frame, item, commit_type); |
4009 } | 4010 } |
4010 | 4011 |
4011 void RenderFrameImpl::didUpdateCurrentHistoryItem() { | 4012 void RenderFrameImpl::didUpdateCurrentHistoryItem() { |
4012 render_view_->StartNavStateSyncTimerIfNecessary(this); | 4013 render_view_->StartNavStateSyncTimerIfNecessary(this); |
4013 } | 4014 } |
4014 | 4015 |
4015 void RenderFrameImpl::didChangeThemeColor() { | 4016 void RenderFrameImpl::didChangeThemeColor() { |
4016 if (frame_->parent()) | 4017 if (frame_->parent()) |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4833 // We need to track the RenderViewHost routing_id because of downstream | 4834 // We need to track the RenderViewHost routing_id because of downstream |
4834 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 4835 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
4835 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 4836 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
4836 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 4837 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
4837 // based on the ID stored in the resource requests. Once those dependencies | 4838 // based on the ID stored in the resource requests. Once those dependencies |
4838 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the | 4839 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the |
4839 // client to be based on the routing_id of the RenderFrameHost. | 4840 // client to be based on the routing_id of the RenderFrameHost. |
4840 params.render_view_routing_id = render_view_->routing_id(); | 4841 params.render_view_routing_id = render_view_->routing_id(); |
4841 params.socket_address.set_host(response.remoteIPAddress().utf8()); | 4842 params.socket_address.set_host(response.remoteIPAddress().utf8()); |
4842 params.socket_address.set_port(response.remotePort()); | 4843 params.socket_address.set_port(response.remotePort()); |
4843 params.was_within_same_page = navigation_state->WasWithinSamePage(); | 4844 params.was_within_same_document = navigation_state->WasWithinSameDocument(); |
4844 | 4845 |
4845 WebDocument frame_document = frame->document(); | 4846 WebDocument frame_document = frame->document(); |
4846 // Set the origin of the frame. This will be replicated to the corresponding | 4847 // Set the origin of the frame. This will be replicated to the corresponding |
4847 // RenderFrameProxies in other processes. | 4848 // RenderFrameProxies in other processes. |
4848 WebSecurityOrigin frame_origin = frame_document.getSecurityOrigin(); | 4849 WebSecurityOrigin frame_origin = frame_document.getSecurityOrigin(); |
4849 params.origin = frame_origin; | 4850 params.origin = frame_origin; |
4850 | 4851 |
4851 params.insecure_request_policy = frame->getInsecureRequestPolicy(); | 4852 params.insecure_request_policy = frame->getInsecureRequestPolicy(); |
4852 | 4853 |
4853 params.has_potentially_trustworthy_unique_origin = | 4854 params.has_potentially_trustworthy_unique_origin = |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4996 .allow_universal_access_from_file_urls) { | 4997 .allow_universal_access_from_file_urls) { |
4997 base::debug::SetCrashKeyValue("origin_mismatch_url", params.url.spec()); | 4998 base::debug::SetCrashKeyValue("origin_mismatch_url", params.url.spec()); |
4998 base::debug::SetCrashKeyValue("origin_mismatch_origin", | 4999 base::debug::SetCrashKeyValue("origin_mismatch_origin", |
4999 params.origin.Serialize()); | 5000 params.origin.Serialize()); |
5000 base::debug::SetCrashKeyValue("origin_mismatch_transition", | 5001 base::debug::SetCrashKeyValue("origin_mismatch_transition", |
5001 base::IntToString(params.transition)); | 5002 base::IntToString(params.transition)); |
5002 base::debug::SetCrashKeyValue("origin_mismatch_redirects", | 5003 base::debug::SetCrashKeyValue("origin_mismatch_redirects", |
5003 base::IntToString(params.redirects.size())); | 5004 base::IntToString(params.redirects.size())); |
5004 base::debug::SetCrashKeyValue( | 5005 base::debug::SetCrashKeyValue( |
5005 "origin_mismatch_same_page", | 5006 "origin_mismatch_same_page", |
5006 base::IntToString(params.was_within_same_page)); | 5007 base::IntToString(params.was_within_same_document)); |
5007 CHECK(params.origin.IsSamePhysicalOriginWith(url::Origin(params.url))) | 5008 CHECK(params.origin.IsSamePhysicalOriginWith(url::Origin(params.url))) |
5008 << " url:" << params.url << " origin:" << params.origin; | 5009 << " url:" << params.url << " origin:" << params.origin; |
5009 } | 5010 } |
5010 } | 5011 } |
5011 | 5012 |
5012 // This message needs to be sent before any of allowScripts(), | 5013 // This message needs to be sent before any of allowScripts(), |
5013 // allowImages(), allowPlugins() is called for the new page, so that when | 5014 // allowImages(), allowPlugins() is called for the new page, so that when |
5014 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 5015 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
5015 // after the FrameHostMsg_DidCommitProvisionalLoad message. | 5016 // after the FrameHostMsg_DidCommitProvisionalLoad message. |
5016 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 5017 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6852 // event target. Potentially a Pepper plugin will receive the event. | 6853 // event target. Potentially a Pepper plugin will receive the event. |
6853 // In order to tell whether a plugin gets the last mouse event and which it | 6854 // In order to tell whether a plugin gets the last mouse event and which it |
6854 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6855 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6855 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6856 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6856 // |pepper_last_mouse_event_target_|. | 6857 // |pepper_last_mouse_event_target_|. |
6857 pepper_last_mouse_event_target_ = nullptr; | 6858 pepper_last_mouse_event_target_ = nullptr; |
6858 #endif | 6859 #endif |
6859 } | 6860 } |
6860 | 6861 |
6861 } // namespace content | 6862 } // namespace content |
OLD | NEW |