| 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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 blink::WebFrame* previous_sibling_web_frame = nullptr; | 987 blink::WebFrame* previous_sibling_web_frame = nullptr; |
| 988 RenderFrameProxy* previous_sibling_proxy = | 988 RenderFrameProxy* previous_sibling_proxy = |
| 989 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); | 989 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); |
| 990 if (previous_sibling_proxy) | 990 if (previous_sibling_proxy) |
| 991 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); | 991 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); |
| 992 | 992 |
| 993 // Create the RenderFrame and WebLocalFrame, linking the two. | 993 // Create the RenderFrame and WebLocalFrame, linking the two. |
| 994 render_frame = | 994 render_frame = |
| 995 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); | 995 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); |
| 996 render_frame->InitializeBlameContext(FromRoutingID(parent_routing_id)); | 996 render_frame->InitializeBlameContext(FromRoutingID(parent_routing_id)); |
| 997 render_frame->unique_name_helper_.set_propagated_name( |
| 998 replicated_state.unique_name); |
| 997 web_frame = parent_web_frame->createLocalChild( | 999 web_frame = parent_web_frame->createLocalChild( |
| 998 replicated_state.scope, WebString::fromUTF8(replicated_state.name), | 1000 replicated_state.scope, WebString::fromUTF8(replicated_state.name), |
| 999 WebString::fromUTF8(replicated_state.unique_name), | |
| 1000 replicated_state.sandbox_flags, render_frame, | 1001 replicated_state.sandbox_flags, render_frame, |
| 1001 render_frame->blink_interface_provider_.get(), | 1002 render_frame->blink_interface_provider_.get(), |
| 1002 render_frame->blink_interface_registry_.get(), | 1003 render_frame->blink_interface_registry_.get(), |
| 1003 previous_sibling_web_frame, | 1004 previous_sibling_web_frame, |
| 1004 ConvertFrameOwnerPropertiesToWebFrameOwnerProperties( | 1005 ConvertFrameOwnerPropertiesToWebFrameOwnerProperties( |
| 1005 frame_owner_properties), | 1006 frame_owner_properties), |
| 1006 ResolveOpener(opener_routing_id)); | 1007 ResolveOpener(opener_routing_id)); |
| 1007 | 1008 |
| 1008 // The RenderFrame is created and inserted into the frame tree in the above | 1009 // The RenderFrame is created and inserted into the frame tree in the above |
| 1009 // call to createLocalChild. | 1010 // call to createLocalChild. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 | 1089 |
| 1089 blink::WebURL RenderFrameImpl::overrideFlashEmbedWithHTML( | 1090 blink::WebURL RenderFrameImpl::overrideFlashEmbedWithHTML( |
| 1090 const blink::WebURL& url) { | 1091 const blink::WebURL& url) { |
| 1091 return GetContentClient()->renderer()->OverrideFlashEmbedWithHTML(url); | 1092 return GetContentClient()->renderer()->OverrideFlashEmbedWithHTML(url); |
| 1092 } | 1093 } |
| 1093 | 1094 |
| 1094 // RenderFrameImpl ---------------------------------------------------------- | 1095 // RenderFrameImpl ---------------------------------------------------------- |
| 1095 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) | 1096 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) |
| 1096 : frame_(NULL), | 1097 : frame_(NULL), |
| 1097 is_main_frame_(true), | 1098 is_main_frame_(true), |
| 1099 unique_name_helper_(this), |
| 1098 in_browser_initiated_detach_(false), | 1100 in_browser_initiated_detach_(false), |
| 1099 in_frame_tree_(false), | 1101 in_frame_tree_(false), |
| 1100 render_view_(params.render_view), | 1102 render_view_(params.render_view), |
| 1101 routing_id_(params.routing_id), | 1103 routing_id_(params.routing_id), |
| 1102 proxy_routing_id_(MSG_ROUTING_NONE), | 1104 proxy_routing_id_(MSG_ROUTING_NONE), |
| 1103 #if BUILDFLAG(ENABLE_PLUGINS) | 1105 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1104 plugin_power_saver_helper_(nullptr), | 1106 plugin_power_saver_helper_(nullptr), |
| 1105 plugin_find_handler_(nullptr), | 1107 plugin_find_handler_(nullptr), |
| 1106 #endif | 1108 #endif |
| 1107 cookie_jar_(this), | 1109 cookie_jar_(this), |
| (...skipping 1930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3038 } | 3040 } |
| 3039 } | 3041 } |
| 3040 | 3042 |
| 3041 has_accessed_initial_document_ = true; | 3043 has_accessed_initial_document_ = true; |
| 3042 } | 3044 } |
| 3043 | 3045 |
| 3044 blink::WebLocalFrame* RenderFrameImpl::createChildFrame( | 3046 blink::WebLocalFrame* RenderFrameImpl::createChildFrame( |
| 3045 blink::WebLocalFrame* parent, | 3047 blink::WebLocalFrame* parent, |
| 3046 blink::WebTreeScopeType scope, | 3048 blink::WebTreeScopeType scope, |
| 3047 const blink::WebString& name, | 3049 const blink::WebString& name, |
| 3048 const blink::WebString& unique_name, | 3050 const blink::WebString& fallback_name, |
| 3049 blink::WebSandboxFlags sandbox_flags, | 3051 blink::WebSandboxFlags sandbox_flags, |
| 3050 const blink::WebFrameOwnerProperties& frame_owner_properties) { | 3052 const blink::WebFrameOwnerProperties& frame_owner_properties) { |
| 3051 // Synchronously notify the browser of a child frame creation to get the | 3053 // Synchronously notify the browser of a child frame creation to get the |
| 3052 // routing_id for the RenderFrame. | 3054 // routing_id for the RenderFrame. |
| 3053 int child_routing_id = MSG_ROUTING_NONE; | 3055 int child_routing_id = MSG_ROUTING_NONE; |
| 3054 FrameHostMsg_CreateChildFrame_Params params; | 3056 FrameHostMsg_CreateChildFrame_Params params; |
| 3055 params.parent_routing_id = routing_id_; | 3057 params.parent_routing_id = routing_id_; |
| 3056 params.scope = scope; | 3058 params.scope = scope; |
| 3057 params.frame_name = name.utf8(); | 3059 params.frame_name = name.utf8(); |
| 3058 params.frame_unique_name = unique_name.utf8(); | 3060 // The unique name generation logic was moved out of Blink, so for historical |
| 3061 // reasons, unique name generation needs to take something called the |
| 3062 // |fallback_name| into account. Normally, unique names are generated based on |
| 3063 // the browing context name. For new frames, the initial browsing context name |
| 3064 // comes from the name attribute of the browsing context container element. |
| 3065 // |
| 3066 // However, when the browsing context name is null, Blink instead uses the |
| 3067 // "fallback name" to derive the unique name. The exact contents of the |
| 3068 // "fallback name" are unspecified, but may contain the value of the |
| 3069 // 'subresource attribute' of the browsing context container element. |
| 3070 // |
| 3071 // Note that Blink can't be changed to just pass |fallback_name| as |name| in |
| 3072 // the case |name| is empty: |fallback_name| should never affect the actual |
| 3073 // browsing context name, only unique name generation. |
| 3074 params.frame_unique_name = UniqueNameHelper::GenerateNameForNewChildFrame( |
| 3075 parent, |
| 3076 params.frame_name.empty() ? fallback_name.utf8() : params.frame_name); |
| 3059 params.sandbox_flags = sandbox_flags; | 3077 params.sandbox_flags = sandbox_flags; |
| 3060 params.frame_owner_properties = | 3078 params.frame_owner_properties = |
| 3061 ConvertWebFrameOwnerPropertiesToFrameOwnerProperties( | 3079 ConvertWebFrameOwnerPropertiesToFrameOwnerProperties( |
| 3062 frame_owner_properties); | 3080 frame_owner_properties); |
| 3063 Send(new FrameHostMsg_CreateChildFrame(params, &child_routing_id)); | 3081 Send(new FrameHostMsg_CreateChildFrame(params, &child_routing_id)); |
| 3064 | 3082 |
| 3065 // Allocation of routing id failed, so we can't create a child frame. This can | 3083 // Allocation of routing id failed, so we can't create a child frame. This can |
| 3066 // happen if the synchronous IPC message above has failed. This can | 3084 // happen if the synchronous IPC message above has failed. This can |
| 3067 // legitimately happen when the browser process has already destroyed | 3085 // legitimately happen when the browser process has already destroyed |
| 3068 // RenderProcessHost, but the renderer process hasn't quit yet. | 3086 // RenderProcessHost, but the renderer process hasn't quit yet. |
| 3069 if (child_routing_id == MSG_ROUTING_NONE) | 3087 if (child_routing_id == MSG_ROUTING_NONE) |
| 3070 return nullptr; | 3088 return nullptr; |
| 3071 | 3089 |
| 3072 // This method is always called by local frames, never remote frames. | 3090 // This method is always called by local frames, never remote frames. |
| 3073 | 3091 |
| 3074 // Tracing analysis uses this to find main frames when this value is | 3092 // Tracing analysis uses this to find main frames when this value is |
| 3075 // MSG_ROUTING_NONE, and build the frame tree otherwise. | 3093 // MSG_ROUTING_NONE, and build the frame tree otherwise. |
| 3076 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::createChildFrame", | 3094 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::createChildFrame", |
| 3077 "id", routing_id_, | 3095 "id", routing_id_, |
| 3078 "child", child_routing_id); | 3096 "child", child_routing_id); |
| 3079 | 3097 |
| 3080 // Create the RenderFrame and WebLocalFrame, linking the two. | 3098 // Create the RenderFrame and WebLocalFrame, linking the two. |
| 3081 RenderFrameImpl* child_render_frame = | 3099 RenderFrameImpl* child_render_frame = |
| 3082 RenderFrameImpl::Create(render_view_, child_routing_id); | 3100 RenderFrameImpl::Create(render_view_, child_routing_id); |
| 3101 child_render_frame->unique_name_helper_.set_propagated_name( |
| 3102 params.frame_unique_name); |
| 3083 child_render_frame->InitializeBlameContext(this); | 3103 child_render_frame->InitializeBlameContext(this); |
| 3084 blink::WebLocalFrame* web_frame = WebLocalFrame::create( | 3104 blink::WebLocalFrame* web_frame = WebLocalFrame::create( |
| 3085 scope, child_render_frame, | 3105 scope, child_render_frame, |
| 3086 child_render_frame->blink_interface_provider_.get(), | 3106 child_render_frame->blink_interface_provider_.get(), |
| 3087 child_render_frame->blink_interface_registry_.get()); | 3107 child_render_frame->blink_interface_registry_.get()); |
| 3088 child_render_frame->BindToWebFrame(web_frame); | 3108 child_render_frame->BindToWebFrame(web_frame); |
| 3089 | 3109 |
| 3090 // Add the frame to the frame tree and initialize it. | 3110 // Add the frame to the frame tree and initialize it. |
| 3091 parent->appendChild(web_frame); | 3111 parent->appendChild(web_frame); |
| 3092 child_render_frame->in_frame_tree_ = true; | 3112 child_render_frame->in_frame_tree_ = true; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3181 | 3201 |
| 3182 void RenderFrameImpl::frameFocused() { | 3202 void RenderFrameImpl::frameFocused() { |
| 3183 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 3203 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
| 3184 } | 3204 } |
| 3185 | 3205 |
| 3186 void RenderFrameImpl::willCommitProvisionalLoad() { | 3206 void RenderFrameImpl::willCommitProvisionalLoad() { |
| 3187 for (auto& observer : observers_) | 3207 for (auto& observer : observers_) |
| 3188 observer.WillCommitProvisionalLoad(); | 3208 observer.WillCommitProvisionalLoad(); |
| 3189 } | 3209 } |
| 3190 | 3210 |
| 3191 void RenderFrameImpl::didChangeName(const blink::WebString& name, | 3211 void RenderFrameImpl::didChangeName(const blink::WebString& name) { |
| 3192 const blink::WebString& unique_name) { | 3212 if (current_history_item_.isNull()) { |
| 3193 Send(new FrameHostMsg_DidChangeName( | 3213 // Once a navigation has committed, the unique name must no longer change to |
| 3194 routing_id_, name.utf8(), unique_name.utf8())); | 3214 // avoid breaking back/forward navigations: https://crbug.com/607205 |
| 3215 unique_name_helper_.UpdateName(name.utf8()); |
| 3216 } |
| 3217 Send(new FrameHostMsg_DidChangeName(routing_id_, name.utf8(), |
| 3218 unique_name_helper_.value())); |
| 3195 | 3219 |
| 3196 if (!committed_first_load_) | 3220 if (!committed_first_load_) |
| 3197 name_changed_before_first_commit_ = true; | 3221 name_changed_before_first_commit_ = true; |
| 3198 } | 3222 } |
| 3199 | 3223 |
| 3200 void RenderFrameImpl::didEnforceInsecureRequestPolicy( | 3224 void RenderFrameImpl::didEnforceInsecureRequestPolicy( |
| 3201 blink::WebInsecureRequestPolicy policy) { | 3225 blink::WebInsecureRequestPolicy policy) { |
| 3202 Send(new FrameHostMsg_EnforceInsecureRequestPolicy(routing_id_, policy)); | 3226 Send(new FrameHostMsg_EnforceInsecureRequestPolicy(routing_id_, policy)); |
| 3203 } | 3227 } |
| 3204 | 3228 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3619 // subsequent invocations of this callback. | 3643 // subsequent invocations of this callback. |
| 3620 // * if |committed_first_load_| is false and |current_history_item_| is | 3644 // * if |committed_first_load_| is false and |current_history_item_| is |
| 3621 // *not* null, then the initial empty document has already committed. | 3645 // *not* null, then the initial empty document has already committed. |
| 3622 // Record if window.name has changed. | 3646 // Record if window.name has changed. |
| 3623 if (!committed_first_load_ && !current_history_item_.isNull()) { | 3647 if (!committed_first_load_ && !current_history_item_.isNull()) { |
| 3624 if (!IsMainFrame()) { | 3648 if (!IsMainFrame()) { |
| 3625 UMA_HISTOGRAM_BOOLEAN( | 3649 UMA_HISTOGRAM_BOOLEAN( |
| 3626 "SessionRestore.SubFrameUniqueNameChangedBeforeFirstCommit", | 3650 "SessionRestore.SubFrameUniqueNameChangedBeforeFirstCommit", |
| 3627 name_changed_before_first_commit_); | 3651 name_changed_before_first_commit_); |
| 3628 } | 3652 } |
| 3653 // TODO(dcheng): This signal is likely calculated incorrectly, and will be |
| 3654 // removed in a followup CL (as we've decided to try to preserve backwards |
| 3655 // compatibility as much as possible for the time being). |
| 3629 committed_first_load_ = true; | 3656 committed_first_load_ = true; |
| 3630 } | 3657 } |
| 3631 | 3658 |
| 3632 DocumentState* document_state = | 3659 DocumentState* document_state = |
| 3633 DocumentState::FromDataSource(frame->dataSource()); | 3660 DocumentState::FromDataSource(frame->dataSource()); |
| 3634 NavigationStateImpl* navigation_state = | 3661 NavigationStateImpl* navigation_state = |
| 3635 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3662 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 3636 const WebURLResponse& web_url_response = frame->dataSource()->response(); | 3663 const WebURLResponse& web_url_response = frame->dataSource()->response(); |
| 3637 WebURLResponseExtraDataImpl* extra_data = | 3664 WebURLResponseExtraDataImpl* extra_data = |
| 3638 GetExtraDataFromResponse(web_url_response); | 3665 GetExtraDataFromResponse(web_url_response); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3674 render_view_->QueueMessage( | 3701 render_view_->QueueMessage( |
| 3675 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), | 3702 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), |
| 3676 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 3703 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
| 3677 } | 3704 } |
| 3678 | 3705 |
| 3679 // When we perform a new navigation, we need to update the last committed | 3706 // When we perform a new navigation, we need to update the last committed |
| 3680 // session history entry with state for the page we are leaving. Do this | 3707 // session history entry with state for the page we are leaving. Do this |
| 3681 // before updating the current history item. | 3708 // before updating the current history item. |
| 3682 SendUpdateState(); | 3709 SendUpdateState(); |
| 3683 | 3710 |
| 3684 // Update the current history item for this frame (both in default Chrome and | 3711 // Update the current history item for this frame. |
| 3685 // subframe FrameNavigationEntry modes). | |
| 3686 current_history_item_ = item; | 3712 current_history_item_ = item; |
| 3713 // Note: don't reference |item| after this point, as its value may not match |
| 3714 // |current_history_item_|. |
| 3715 current_history_item_.setTarget( |
| 3716 blink::WebString::fromUTF8(unique_name_helper_.value())); |
| 3687 | 3717 |
| 3688 InternalDocumentStateData* internal_data = | 3718 InternalDocumentStateData* internal_data = |
| 3689 InternalDocumentStateData::FromDocumentState(document_state); | 3719 InternalDocumentStateData::FromDocumentState(document_state); |
| 3690 | 3720 |
| 3691 if (internal_data->must_reset_scroll_and_scale_state()) { | 3721 if (internal_data->must_reset_scroll_and_scale_state()) { |
| 3692 render_view_->webview()->resetScrollAndScaleState(); | 3722 render_view_->webview()->resetScrollAndScaleState(); |
| 3693 internal_data->set_must_reset_scroll_and_scale_state(false); | 3723 internal_data->set_must_reset_scroll_and_scale_state(false); |
| 3694 } | 3724 } |
| 3695 | 3725 |
| 3696 const RequestNavigationParams& request_params = | 3726 const RequestNavigationParams& request_params = |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3741 } | 3771 } |
| 3742 } | 3772 } |
| 3743 | 3773 |
| 3744 // Remember that we've already processed this request, so we don't update | 3774 // Remember that we've already processed this request, so we don't update |
| 3745 // the session history again. We do this regardless of whether this is | 3775 // the session history again. We do this regardless of whether this is |
| 3746 // a session history navigation, because if we attempted a session history | 3776 // a session history navigation, because if we attempted a session history |
| 3747 // navigation without valid HistoryItem state, WebCore will think it is a | 3777 // navigation without valid HistoryItem state, WebCore will think it is a |
| 3748 // new navigation. | 3778 // new navigation. |
| 3749 navigation_state->set_request_committed(true); | 3779 navigation_state->set_request_committed(true); |
| 3750 | 3780 |
| 3751 SendDidCommitProvisionalLoad(frame, commit_type, item); | 3781 SendDidCommitProvisionalLoad(frame, commit_type); |
| 3752 | 3782 |
| 3753 // Check whether we have new encoding name. | 3783 // Check whether we have new encoding name. |
| 3754 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3784 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 3755 } | 3785 } |
| 3756 | 3786 |
| 3757 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { | 3787 void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { |
| 3758 DCHECK(!frame_ || frame_ == frame); | 3788 DCHECK(!frame_ || frame_ == frame); |
| 3759 | 3789 |
| 3760 for (auto& observer : observers_) | 3790 for (auto& observer : observers_) |
| 3761 observer.DidCreateNewDocument(); | 3791 observer.DidCreateNewDocument(); |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4822 } | 4852 } |
| 4823 | 4853 |
| 4824 const RenderFrameImpl* RenderFrameImpl::GetLocalRoot() const { | 4854 const RenderFrameImpl* RenderFrameImpl::GetLocalRoot() const { |
| 4825 return IsLocalRoot() ? this | 4855 return IsLocalRoot() ? this |
| 4826 : RenderFrameImpl::FromWebFrame(frame_->localRoot()); | 4856 : RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
| 4827 } | 4857 } |
| 4828 | 4858 |
| 4829 // Tell the embedding application that the URL of the active page has changed. | 4859 // Tell the embedding application that the URL of the active page has changed. |
| 4830 void RenderFrameImpl::SendDidCommitProvisionalLoad( | 4860 void RenderFrameImpl::SendDidCommitProvisionalLoad( |
| 4831 blink::WebFrame* frame, | 4861 blink::WebFrame* frame, |
| 4832 blink::WebHistoryCommitType commit_type, | 4862 blink::WebHistoryCommitType commit_type) { |
| 4833 const blink::WebHistoryItem& item) { | |
| 4834 DCHECK_EQ(frame_, frame); | 4863 DCHECK_EQ(frame_, frame); |
| 4835 WebDataSource* ds = frame->dataSource(); | 4864 WebDataSource* ds = frame->dataSource(); |
| 4836 DCHECK(ds); | 4865 DCHECK(ds); |
| 4837 | 4866 |
| 4838 const WebURLRequest& request = ds->getRequest(); | 4867 const WebURLRequest& request = ds->getRequest(); |
| 4839 const WebURLResponse& response = ds->response(); | 4868 const WebURLResponse& response = ds->response(); |
| 4840 | 4869 |
| 4841 DocumentState* document_state = DocumentState::FromDataSource(ds); | 4870 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 4842 NavigationStateImpl* navigation_state = | 4871 NavigationStateImpl* navigation_state = |
| 4843 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 4872 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4896 params.searchable_form_url = internal_data->searchable_form_url(); | 4925 params.searchable_form_url = internal_data->searchable_form_url(); |
| 4897 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 4926 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
| 4898 | 4927 |
| 4899 params.gesture = render_view_->navigation_gesture_; | 4928 params.gesture = render_view_->navigation_gesture_; |
| 4900 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 4929 render_view_->navigation_gesture_ = NavigationGestureUnknown; |
| 4901 | 4930 |
| 4902 // Make navigation state a part of the DidCommitProvisionalLoad message so | 4931 // Make navigation state a part of the DidCommitProvisionalLoad message so |
| 4903 // that committed entry has it at all times. Send a single HistoryItem for | 4932 // that committed entry has it at all times. Send a single HistoryItem for |
| 4904 // this frame, rather than the whole tree. It will be stored in the | 4933 // this frame, rather than the whole tree. It will be stored in the |
| 4905 // corresponding FrameNavigationEntry. | 4934 // corresponding FrameNavigationEntry. |
| 4906 params.page_state = SingleHistoryItemToPageState(item); | 4935 params.page_state = SingleHistoryItemToPageState(current_history_item_); |
| 4907 | 4936 |
| 4908 params.content_source_id = GetRenderWidget()->GetContentSourceId(); | 4937 params.content_source_id = GetRenderWidget()->GetContentSourceId(); |
| 4909 | 4938 |
| 4910 params.method = request.httpMethod().latin1(); | 4939 params.method = request.httpMethod().latin1(); |
| 4911 if (params.method == "POST") | 4940 if (params.method == "POST") |
| 4912 params.post_id = ExtractPostId(item); | 4941 params.post_id = ExtractPostId(current_history_item_); |
| 4913 | 4942 |
| 4914 params.frame_unique_name = item.target().utf8(); | 4943 params.frame_unique_name = current_history_item_.target().utf8(); |
| 4915 params.item_sequence_number = item.itemSequenceNumber(); | 4944 params.item_sequence_number = current_history_item_.itemSequenceNumber(); |
| 4916 params.document_sequence_number = item.documentSequenceNumber(); | 4945 params.document_sequence_number = |
| 4946 current_history_item_.documentSequenceNumber(); |
| 4917 | 4947 |
| 4918 // If the page contained a client redirect (meta refresh, document.loc...), | 4948 // If the page contained a client redirect (meta refresh, document.loc...), |
| 4919 // set the referrer appropriately. | 4949 // set the referrer appropriately. |
| 4920 if (ds->isClientRedirect()) { | 4950 if (ds->isClientRedirect()) { |
| 4921 params.referrer = | 4951 params.referrer = |
| 4922 Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy()); | 4952 Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy()); |
| 4923 } else { | 4953 } else { |
| 4924 params.referrer = | 4954 params.referrer = |
| 4925 RenderViewImpl::GetReferrerFromRequest(frame, ds->getRequest()); | 4955 RenderViewImpl::GetReferrerFromRequest(frame, ds->getRequest()); |
| 4926 } | 4956 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5055 CHECK_NE(proxy_routing_id_, MSG_ROUTING_NONE); | 5085 CHECK_NE(proxy_routing_id_, MSG_ROUTING_NONE); |
| 5056 CHECK(!in_frame_tree_); | 5086 CHECK(!in_frame_tree_); |
| 5057 | 5087 |
| 5058 // The proxy should always exist. If it was detached while the provisional | 5088 // The proxy should always exist. If it was detached while the provisional |
| 5059 // LocalFrame was being navigated, the provisional frame would've been | 5089 // LocalFrame was being navigated, the provisional frame would've been |
| 5060 // cleaned up by RenderFrameProxy::frameDetached. See | 5090 // cleaned up by RenderFrameProxy::frameDetached. See |
| 5061 // https://crbug.com/526304 and https://crbug.com/568676 for context. | 5091 // https://crbug.com/526304 and https://crbug.com/568676 for context. |
| 5062 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(proxy_routing_id_); | 5092 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(proxy_routing_id_); |
| 5063 CHECK(proxy); | 5093 CHECK(proxy); |
| 5064 | 5094 |
| 5095 unique_name_helper_.set_propagated_name(proxy->unique_name()); |
| 5096 |
| 5097 // Note: Calling swap() will detach and delete |proxy|, so do not reference it |
| 5098 // after this. |
| 5065 int proxy_routing_id = proxy_routing_id_; | 5099 int proxy_routing_id = proxy_routing_id_; |
| 5066 if (!proxy->web_frame()->swap(frame_)) | 5100 if (!proxy->web_frame()->swap(frame_)) |
| 5067 return false; | 5101 return false; |
| 5068 | 5102 |
| 5069 proxy_routing_id_ = MSG_ROUTING_NONE; | 5103 proxy_routing_id_ = MSG_ROUTING_NONE; |
| 5070 in_frame_tree_ = true; | 5104 in_frame_tree_ = true; |
| 5071 | 5105 |
| 5072 // If this is the main frame going from a remote frame to a local frame, | 5106 // If this is the main frame going from a remote frame to a local frame, |
| 5073 // it needs to set RenderViewImpl's pointer for the main frame to itself | 5107 // it needs to set RenderViewImpl's pointer for the main frame to itself |
| 5074 // and ensure RenderWidget is no longer in swapped out mode. | 5108 // and ensure RenderWidget is no longer in swapped out mode. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5339 // staying at about:blank. If this frame isn't in the map of unique names | 5373 // staying at about:blank. If this frame isn't in the map of unique names |
| 5340 // that have history items, or if it's staying at the initial about:blank URL, | 5374 // that have history items, or if it's staying at the initial about:blank URL, |
| 5341 // fall back to loading the default url. (We remove each name as we encounter | 5375 // fall back to loading the default url. (We remove each name as we encounter |
| 5342 // it, because it will only be used once as the frame is created.) | 5376 // it, because it will only be used once as the frame is created.) |
| 5343 if (info.isHistoryNavigationInNewChildFrame && is_content_initiated && | 5377 if (info.isHistoryNavigationInNewChildFrame && is_content_initiated && |
| 5344 frame_->parent()) { | 5378 frame_->parent()) { |
| 5345 // Check whether the browser has a history item for this frame that isn't | 5379 // Check whether the browser has a history item for this frame that isn't |
| 5346 // just staying at the initial about:blank document. | 5380 // just staying at the initial about:blank document. |
| 5347 bool should_ask_browser = false; | 5381 bool should_ask_browser = false; |
| 5348 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); | 5382 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); |
| 5349 const auto& iter = parent->history_subframe_unique_names_.find( | 5383 auto iter = parent->history_subframe_unique_names_.find( |
| 5350 frame_->uniqueName().utf8()); | 5384 unique_name_helper_.value()); |
| 5351 if (iter != parent->history_subframe_unique_names_.end()) { | 5385 if (iter != parent->history_subframe_unique_names_.end()) { |
| 5352 bool history_item_is_about_blank = iter->second; | 5386 bool history_item_is_about_blank = iter->second; |
| 5353 should_ask_browser = | 5387 should_ask_browser = |
| 5354 !history_item_is_about_blank || url != url::kAboutBlankURL; | 5388 !history_item_is_about_blank || url != url::kAboutBlankURL; |
| 5355 parent->history_subframe_unique_names_.erase(frame_->uniqueName().utf8()); | 5389 parent->history_subframe_unique_names_.erase(iter); |
| 5356 } | 5390 } |
| 5357 | 5391 |
| 5358 if (should_ask_browser) { | 5392 if (should_ask_browser) { |
| 5359 // Don't do this if |info| also says it is a client redirect, in which | 5393 // Don't do this if |info| also says it is a client redirect, in which |
| 5360 // case JavaScript on the page is trying to interrupt the history | 5394 // case JavaScript on the page is trying to interrupt the history |
| 5361 // navigation. | 5395 // navigation. |
| 5362 if (!info.isClientRedirect) { | 5396 if (!info.isClientRedirect) { |
| 5363 OpenURL(url, IsHttpPost(info.urlRequest), | 5397 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5364 GetRequestBodyForWebURLRequest(info.urlRequest), | 5398 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5365 GetWebURLRequestHeaders(info.urlRequest), referrer, | 5399 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6932 policy(info.defaultPolicy), | 6966 policy(info.defaultPolicy), |
| 6933 replaces_current_history_item(info.replacesCurrentHistoryItem), | 6967 replaces_current_history_item(info.replacesCurrentHistoryItem), |
| 6934 history_navigation_in_new_child_frame( | 6968 history_navigation_in_new_child_frame( |
| 6935 info.isHistoryNavigationInNewChildFrame), | 6969 info.isHistoryNavigationInNewChildFrame), |
| 6936 client_redirect(info.isClientRedirect), | 6970 client_redirect(info.isClientRedirect), |
| 6937 cache_disabled(info.isCacheDisabled), | 6971 cache_disabled(info.isCacheDisabled), |
| 6938 form(info.form), | 6972 form(info.form), |
| 6939 source_location(info.sourceLocation) {} | 6973 source_location(info.sourceLocation) {} |
| 6940 | 6974 |
| 6941 } // namespace content | 6975 } // namespace content |
| OLD | NEW |