| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 #include "content/renderer/accessibility/render_accessibility_impl.h" | 93 #include "content/renderer/accessibility/render_accessibility_impl.h" |
| 94 #include "content/renderer/browser_plugin/browser_plugin.h" | 94 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 95 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 95 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 96 #include "content/renderer/child_frame_compositing_helper.h" | 96 #include "content/renderer/child_frame_compositing_helper.h" |
| 97 #include "content/renderer/context_menu_params_builder.h" | 97 #include "content/renderer/context_menu_params_builder.h" |
| 98 #include "content/renderer/devtools/devtools_agent.h" | 98 #include "content/renderer/devtools/devtools_agent.h" |
| 99 #include "content/renderer/dom_automation_controller.h" | 99 #include "content/renderer/dom_automation_controller.h" |
| 100 #include "content/renderer/effective_connection_type_helper.h" | 100 #include "content/renderer/effective_connection_type_helper.h" |
| 101 #include "content/renderer/external_popup_menu.h" | 101 #include "content/renderer/external_popup_menu.h" |
| 102 #include "content/renderer/gpu/gpu_benchmarking_extension.h" | 102 #include "content/renderer/gpu/gpu_benchmarking_extension.h" |
| 103 #include "content/renderer/history_controller.h" | 103 #include "content/renderer/history_entry.h" |
| 104 #include "content/renderer/history_serialization.h" | 104 #include "content/renderer/history_serialization.h" |
| 105 #include "content/renderer/image_downloader/image_downloader_impl.h" | 105 #include "content/renderer/image_downloader/image_downloader_impl.h" |
| 106 #include "content/renderer/ime_event_guard.h" | 106 #include "content/renderer/ime_event_guard.h" |
| 107 #include "content/renderer/input/input_handler_manager.h" | 107 #include "content/renderer/input/input_handler_manager.h" |
| 108 #include "content/renderer/internal_document_state_data.h" | 108 #include "content/renderer/internal_document_state_data.h" |
| 109 #include "content/renderer/manifest/manifest_manager.h" | 109 #include "content/renderer/manifest/manifest_manager.h" |
| 110 #include "content/renderer/media/audio_device_factory.h" | 110 #include "content/renderer/media/audio_device_factory.h" |
| 111 #include "content/renderer/media/media_devices_listener_impl.h" | 111 #include "content/renderer/media/media_devices_listener_impl.h" |
| 112 #include "content/renderer/media/media_permission_dispatcher.h" | 112 #include "content/renderer/media/media_permission_dispatcher.h" |
| 113 #include "content/renderer/media/media_stream_dispatcher.h" | 113 #include "content/renderer/media/media_stream_dispatcher.h" |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 | 1682 |
| 1683 // This codepath should only be hit for subframes when in --site-per-process. | 1683 // This codepath should only be hit for subframes when in --site-per-process. |
| 1684 CHECK(is_main_frame_ || SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 1684 CHECK(is_main_frame_ || SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 1685 | 1685 |
| 1686 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 1686 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
| 1687 // a different process. This involves running the unload handler and | 1687 // a different process. This involves running the unload handler and |
| 1688 // clearing the page. We also allow this process to exit if there are no | 1688 // clearing the page. We also allow this process to exit if there are no |
| 1689 // other active RenderFrames in it. | 1689 // other active RenderFrames in it. |
| 1690 | 1690 |
| 1691 // Send an UpdateState message before we get deleted. | 1691 // Send an UpdateState message before we get deleted. |
| 1692 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 1692 SendUpdateState(); |
| 1693 SendUpdateState(); | |
| 1694 else | |
| 1695 render_view_->SendUpdateState(); | |
| 1696 | 1693 |
| 1697 // There should always be a proxy to replace this RenderFrame. Create it now | 1694 // There should always be a proxy to replace this RenderFrame. Create it now |
| 1698 // so its routing id is registered for receiving IPC messages. | 1695 // so its routing id is registered for receiving IPC messages. |
| 1699 CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE); | 1696 CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE); |
| 1700 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( | 1697 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( |
| 1701 this, proxy_routing_id, replicated_frame_state.scope); | 1698 this, proxy_routing_id, replicated_frame_state.scope); |
| 1702 | 1699 |
| 1703 // Synchronously run the unload handler before sending the ACK. | 1700 // Synchronously run the unload handler before sending the ACK. |
| 1704 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support | 1701 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support |
| 1705 // unload on subframes as well. | 1702 // unload on subframes as well. |
| (...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 if (focused_pepper_plugin_) | 3087 if (focused_pepper_plugin_) |
| 3091 GetRenderWidget()->set_focused_pepper_plugin(nullptr); | 3088 GetRenderWidget()->set_focused_pepper_plugin(nullptr); |
| 3092 #endif | 3089 #endif |
| 3093 | 3090 |
| 3094 for (auto& observer : observers_) | 3091 for (auto& observer : observers_) |
| 3095 observer.FrameDetached(); | 3092 observer.FrameDetached(); |
| 3096 for (auto& observer : render_view_->observers()) | 3093 for (auto& observer : render_view_->observers()) |
| 3097 observer.FrameDetached(frame); | 3094 observer.FrameDetached(frame); |
| 3098 | 3095 |
| 3099 // Send a state update before the frame is detached. | 3096 // Send a state update before the frame is detached. |
| 3100 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3097 SendUpdateState(); |
| 3101 SendUpdateState(); | |
| 3102 | 3098 |
| 3103 // We only notify the browser process when the frame is being detached for | 3099 // We only notify the browser process when the frame is being detached for |
| 3104 // removal and it was initiated from the renderer process. | 3100 // removal and it was initiated from the renderer process. |
| 3105 if (!in_browser_initiated_detach_ && type == DetachType::Remove) | 3101 if (!in_browser_initiated_detach_ && type == DetachType::Remove) |
| 3106 Send(new FrameHostMsg_Detach(routing_id_)); | 3102 Send(new FrameHostMsg_Detach(routing_id_)); |
| 3107 | 3103 |
| 3108 // Clean up the associated RenderWidget for the frame, if there is one. | 3104 // Clean up the associated RenderWidget for the frame, if there is one. |
| 3109 if (render_widget_) { | 3105 if (render_widget_) { |
| 3110 render_widget_->UnregisterRenderFrame(this); | 3106 render_widget_->UnregisterRenderFrame(this); |
| 3111 render_widget_->CloseForFrame(); | 3107 render_widget_->CloseForFrame(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3294 Send(new FrameHostMsg_DownloadUrl(params)); | 3290 Send(new FrameHostMsg_DownloadUrl(params)); |
| 3295 } else { | 3291 } else { |
| 3296 OpenURL(request.url(), IsHttpPost(request), | 3292 OpenURL(request.url(), IsHttpPost(request), |
| 3297 GetRequestBodyForWebURLRequest(request), | 3293 GetRequestBodyForWebURLRequest(request), |
| 3298 GetWebURLRequestHeaders(request), referrer, policy, | 3294 GetWebURLRequestHeaders(request), referrer, policy, |
| 3299 should_replace_current_entry, false); | 3295 should_replace_current_entry, false); |
| 3300 } | 3296 } |
| 3301 } | 3297 } |
| 3302 | 3298 |
| 3303 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { | 3299 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
| 3304 // OOPIF enabled modes will punt this navigation to the browser in | 3300 // We will punt this navigation to the browser in decidePolicyForNavigation. |
| 3305 // decidePolicyForNavigation. | 3301 // TODO(creis): Look into cleaning this up. |
| 3306 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3302 return WebHistoryItem(); |
| 3307 return WebHistoryItem(); | |
| 3308 | |
| 3309 return render_view_->history_controller()->GetItemForNewChildFrame(this); | |
| 3310 } | 3303 } |
| 3311 | 3304 |
| 3312 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { | 3305 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { |
| 3313 for (auto& observer : observers_) | 3306 for (auto& observer : observers_) |
| 3314 observer.WillSendSubmitEvent(form); | 3307 observer.WillSendSubmitEvent(form); |
| 3315 } | 3308 } |
| 3316 | 3309 |
| 3317 void RenderFrameImpl::willSubmitForm(const blink::WebFormElement& form) { | 3310 void RenderFrameImpl::willSubmitForm(const blink::WebFormElement& form) { |
| 3318 // With PlzNavigate-enabled, this will be called before a DataSource has been | 3311 // With PlzNavigate-enabled, this will be called before a DataSource has been |
| 3319 // set-up. | 3312 // set-up. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3469 observer.DidStartProvisionalLoad(); | 3462 observer.DidStartProvisionalLoad(); |
| 3470 | 3463 |
| 3471 Send(new FrameHostMsg_DidStartProvisionalLoad( | 3464 Send(new FrameHostMsg_DidStartProvisionalLoad( |
| 3472 routing_id_, ds->getRequest().url(), navigation_start)); | 3465 routing_id_, ds->getRequest().url(), navigation_start)); |
| 3473 } | 3466 } |
| 3474 | 3467 |
| 3475 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 3468 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
| 3476 blink::WebLocalFrame* frame) { | 3469 blink::WebLocalFrame* frame) { |
| 3477 DCHECK_EQ(frame_, frame); | 3470 DCHECK_EQ(frame_, frame); |
| 3478 | 3471 |
| 3479 // We don't use HistoryController in OOPIF enabled modes. | 3472 // TODO(creis): Determine if this can be removed or if we need to clear any |
| 3480 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3473 // local state here to fix https://crbug.com/671276. |
| 3481 return; | |
| 3482 | |
| 3483 render_view_->history_controller()->RemoveChildrenForRedirect(this); | |
| 3484 } | 3474 } |
| 3485 | 3475 |
| 3486 void RenderFrameImpl::didFailProvisionalLoad( | 3476 void RenderFrameImpl::didFailProvisionalLoad( |
| 3487 blink::WebLocalFrame* frame, | 3477 blink::WebLocalFrame* frame, |
| 3488 const blink::WebURLError& error, | 3478 const blink::WebURLError& error, |
| 3489 blink::WebHistoryCommitType commit_type) { | 3479 blink::WebHistoryCommitType commit_type) { |
| 3490 TRACE_EVENT1("navigation,benchmark,rail", | 3480 TRACE_EVENT1("navigation,benchmark,rail", |
| 3491 "RenderFrameImpl::didFailProvisionalLoad", "id", routing_id_); | 3481 "RenderFrameImpl::didFailProvisionalLoad", "id", routing_id_); |
| 3492 DCHECK_EQ(frame_, frame); | 3482 DCHECK_EQ(frame_, frame); |
| 3493 WebDataSource* ds = frame->provisionalDataSource(); | 3483 WebDataSource* ds = frame->provisionalDataSource(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3612 // first paint of that page, so it can cancel the timer that waits for it. | 3602 // first paint of that page, so it can cancel the timer that waits for it. |
| 3613 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3603 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
| 3614 render_view_->QueueMessage( | 3604 render_view_->QueueMessage( |
| 3615 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), | 3605 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), |
| 3616 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 3606 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
| 3617 } | 3607 } |
| 3618 | 3608 |
| 3619 // When we perform a new navigation, we need to update the last committed | 3609 // When we perform a new navigation, we need to update the last committed |
| 3620 // session history entry with state for the page we are leaving. Do this | 3610 // session history entry with state for the page we are leaving. Do this |
| 3621 // before updating the current history item. | 3611 // before updating the current history item. |
| 3622 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3612 SendUpdateState(); |
| 3623 SendUpdateState(); | 3613 |
| 3624 } else { | |
| 3625 render_view_->SendUpdateState(); | |
| 3626 render_view_->history_controller()->UpdateForCommit( | |
| 3627 this, item, commit_type, navigation_state->WasWithinSamePage()); | |
| 3628 } | |
| 3629 // Update the current history item for this frame (both in default Chrome and | 3614 // Update the current history item for this frame (both in default Chrome and |
| 3630 // subframe FrameNavigationEntry modes). | 3615 // subframe FrameNavigationEntry modes). |
| 3631 current_history_item_ = item; | 3616 current_history_item_ = item; |
| 3632 | 3617 |
| 3633 InternalDocumentStateData* internal_data = | 3618 InternalDocumentStateData* internal_data = |
| 3634 InternalDocumentStateData::FromDocumentState(document_state); | 3619 InternalDocumentStateData::FromDocumentState(document_state); |
| 3635 | 3620 |
| 3636 if (internal_data->must_reset_scroll_and_scale_state()) { | 3621 if (internal_data->must_reset_scroll_and_scale_state()) { |
| 3637 render_view_->webview()->resetScrollAndScaleState(); | 3622 render_view_->webview()->resetScrollAndScaleState(); |
| 3638 internal_data->set_must_reset_scroll_and_scale_state(false); | 3623 internal_data->set_must_reset_scroll_and_scale_state(false); |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4877 params.should_update_history = | 4862 params.should_update_history = |
| 4878 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; | 4863 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; |
| 4879 | 4864 |
| 4880 params.searchable_form_url = internal_data->searchable_form_url(); | 4865 params.searchable_form_url = internal_data->searchable_form_url(); |
| 4881 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 4866 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
| 4882 | 4867 |
| 4883 params.gesture = render_view_->navigation_gesture_; | 4868 params.gesture = render_view_->navigation_gesture_; |
| 4884 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 4869 render_view_->navigation_gesture_ = NavigationGestureUnknown; |
| 4885 | 4870 |
| 4886 // Make navigation state a part of the DidCommitProvisionalLoad message so | 4871 // Make navigation state a part of the DidCommitProvisionalLoad message so |
| 4887 // that committed entry has it at all times. | 4872 // that committed entry has it at all times. Send a single HistoryItem for |
| 4888 int64_t post_id = -1; | 4873 // this frame, rather than the whole tree. It will be stored in the |
| 4889 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 4874 // corresponding FrameNavigationEntry. |
| 4890 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); | 4875 params.page_state = SingleHistoryItemToPageState(item); |
| 4891 if (entry) { | |
| 4892 params.page_state = HistoryEntryToPageState(entry); | |
| 4893 post_id = ExtractPostId(entry->root()); | |
| 4894 } else { | |
| 4895 params.page_state = PageState::CreateFromURL(request.url()); | |
| 4896 } | |
| 4897 } else { | |
| 4898 // In --site-per-process, just send a single HistoryItem for this frame, | |
| 4899 // rather than the whole tree. It will be stored in the corresponding | |
| 4900 // FrameNavigationEntry. | |
| 4901 params.page_state = SingleHistoryItemToPageState(item); | |
| 4902 post_id = ExtractPostId(item); | |
| 4903 } | |
| 4904 | 4876 |
| 4905 // When using subframe navigation entries, method and post id are set for all | 4877 params.method = request.httpMethod().latin1(); |
| 4906 // frames. Otherwise, they are only set for the main frame navigation. | 4878 if (params.method == "POST") |
| 4907 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 4879 params.post_id = ExtractPostId(item); |
| 4908 params.method = request.httpMethod().latin1(); | |
| 4909 if (params.method == "POST") | |
| 4910 params.post_id = post_id; | |
| 4911 } | |
| 4912 | 4880 |
| 4913 params.frame_unique_name = item.target().utf8(); | 4881 params.frame_unique_name = item.target().utf8(); |
| 4914 params.item_sequence_number = item.itemSequenceNumber(); | 4882 params.item_sequence_number = item.itemSequenceNumber(); |
| 4915 params.document_sequence_number = item.documentSequenceNumber(); | 4883 params.document_sequence_number = item.documentSequenceNumber(); |
| 4916 | 4884 |
| 4917 // If the page contained a client redirect (meta refresh, document.loc...), | 4885 // If the page contained a client redirect (meta refresh, document.loc...), |
| 4918 // set the referrer appropriately. | 4886 // set the referrer appropriately. |
| 4919 if (ds->isClientRedirect()) { | 4887 if (ds->isClientRedirect()) { |
| 4920 params.referrer = | 4888 params.referrer = |
| 4921 Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy()); | 4889 Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4975 params.transition = ui::PAGE_TRANSITION_LINK; | 4943 params.transition = ui::PAGE_TRANSITION_LINK; |
| 4976 } | 4944 } |
| 4977 | 4945 |
| 4978 // If the page contained a client redirect (meta refresh, document.loc...), | 4946 // If the page contained a client redirect (meta refresh, document.loc...), |
| 4979 // set the transition appropriately. | 4947 // set the transition appropriately. |
| 4980 if (ds->isClientRedirect()) { | 4948 if (ds->isClientRedirect()) { |
| 4981 params.transition = ui::PageTransitionFromInt( | 4949 params.transition = ui::PageTransitionFromInt( |
| 4982 params.transition | ui::PAGE_TRANSITION_CLIENT_REDIRECT); | 4950 params.transition | ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
| 4983 } | 4951 } |
| 4984 | 4952 |
| 4985 // When using subframe navigation entries, method and post id have already | |
| 4986 // been set. | |
| 4987 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | |
| 4988 params.method = request.httpMethod().latin1(); | |
| 4989 if (params.method == "POST") | |
| 4990 params.post_id = post_id; | |
| 4991 } | |
| 4992 | |
| 4993 // Send the user agent override back. | 4953 // Send the user agent override back. |
| 4994 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); | 4954 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
| 4995 | 4955 |
| 4996 // Track the URL of the original request. We use the first entry of the | 4956 // Track the URL of the original request. We use the first entry of the |
| 4997 // redirect chain if it exists because the chain may have started in another | 4957 // redirect chain if it exists because the chain may have started in another |
| 4998 // process. | 4958 // process. |
| 4999 params.original_request_url = GetOriginalRequestURL(ds); | 4959 params.original_request_url = GetOriginalRequestURL(ds); |
| 5000 | 4960 |
| 5001 params.history_list_was_cleared = | 4961 params.history_list_was_cleared = |
| 5002 navigation_state->request_params().should_clear_history_list; | 4962 navigation_state->request_params().should_clear_history_list; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5291 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 5251 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
| 5292 render_view_->renderer_preferences_ | 5252 render_view_->renderer_preferences_ |
| 5293 .browser_handles_all_top_level_requests) { | 5253 .browser_handles_all_top_level_requests) { |
| 5294 OpenURL(url, IsHttpPost(info.urlRequest), | 5254 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5295 GetRequestBodyForWebURLRequest(info.urlRequest), | 5255 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5296 GetWebURLRequestHeaders(info.urlRequest), referrer, | 5256 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| 5297 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5257 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 5298 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5258 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5299 } | 5259 } |
| 5300 | 5260 |
| 5301 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 5261 // Back/forward navigations in newly created subframes should be sent to the |
| 5302 // should be sent to the browser if there is a matching FrameNavigationEntry, | 5262 // browser if there is a matching FrameNavigationEntry, and if it isn't just |
| 5303 // and if it isn't just staying at about:blank. If this frame isn't in the | 5263 // staying at about:blank. If this frame isn't in the map of unique names |
| 5304 // map of unique names that have history items, or if it's staying at the | 5264 // that have history items, or if it's staying at the initial about:blank URL, |
| 5305 // initial about:blank URL, fall back to loading the default url. (We remove | 5265 // fall back to loading the default url. (We remove each name as we encounter |
| 5306 // each name as we encounter it, because it will only be used once as the | 5266 // it, because it will only be used once as the frame is created.) |
| 5307 // frame is created.) | 5267 if (info.isHistoryNavigationInNewChildFrame && is_content_initiated && |
| 5308 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | |
| 5309 info.isHistoryNavigationInNewChildFrame && is_content_initiated && | |
| 5310 frame_->parent()) { | 5268 frame_->parent()) { |
| 5311 // Check whether the browser has a history item for this frame that isn't | 5269 // Check whether the browser has a history item for this frame that isn't |
| 5312 // just staying at the initial about:blank document. | 5270 // just staying at the initial about:blank document. |
| 5313 bool should_ask_browser = false; | 5271 bool should_ask_browser = false; |
| 5314 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); | 5272 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); |
| 5315 const auto& iter = parent->history_subframe_unique_names_.find( | 5273 const auto& iter = parent->history_subframe_unique_names_.find( |
| 5316 frame_->uniqueName().utf8()); | 5274 frame_->uniqueName().utf8()); |
| 5317 if (iter != parent->history_subframe_unique_names_.end()) { | 5275 if (iter != parent->history_subframe_unique_names_.end()) { |
| 5318 bool history_item_is_about_blank = iter->second; | 5276 bool history_item_is_about_blank = iter->second; |
| 5319 should_ask_browser = | 5277 should_ask_browser = |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5819 if (GetContentClient()->renderer()->AllowPopup()) | 5777 if (GetContentClient()->renderer()->AllowPopup()) |
| 5820 params.user_gesture = true; | 5778 params.user_gesture = true; |
| 5821 | 5779 |
| 5822 if (policy == blink::WebNavigationPolicyNewBackgroundTab || | 5780 if (policy == blink::WebNavigationPolicyNewBackgroundTab || |
| 5823 policy == blink::WebNavigationPolicyNewForegroundTab || | 5781 policy == blink::WebNavigationPolicyNewForegroundTab || |
| 5824 policy == blink::WebNavigationPolicyNewWindow || | 5782 policy == blink::WebNavigationPolicyNewWindow || |
| 5825 policy == blink::WebNavigationPolicyNewPopup) { | 5783 policy == blink::WebNavigationPolicyNewPopup) { |
| 5826 WebUserGestureIndicator::consumeUserGesture(); | 5784 WebUserGestureIndicator::consumeUserGesture(); |
| 5827 } | 5785 } |
| 5828 | 5786 |
| 5829 if (is_history_navigation_in_new_child) { | 5787 if (is_history_navigation_in_new_child) |
| 5830 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | |
| 5831 params.is_history_navigation_in_new_child = true; | 5788 params.is_history_navigation_in_new_child = true; |
| 5832 } | |
| 5833 | 5789 |
| 5834 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 5790 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 5835 } | 5791 } |
| 5836 | 5792 |
| 5837 void RenderFrameImpl::NavigateInternal( | 5793 void RenderFrameImpl::NavigateInternal( |
| 5838 const CommonNavigationParams& common_params, | 5794 const CommonNavigationParams& common_params, |
| 5839 const StartNavigationParams& start_params, | 5795 const StartNavigationParams& start_params, |
| 5840 const RequestNavigationParams& request_params, | 5796 const RequestNavigationParams& request_params, |
| 5841 std::unique_ptr<StreamOverrideParameters> stream_params) { | 5797 std::unique_ptr<StreamOverrideParameters> stream_params) { |
| 5842 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | 5798 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
| 5843 | 5799 |
| 5844 // Lower bound for browser initiated navigation start time. | 5800 // Lower bound for browser initiated navigation start time. |
| 5845 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 5801 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
| 5846 bool is_reload = IsReload(common_params.navigation_type); | 5802 bool is_reload = IsReload(common_params.navigation_type); |
| 5847 bool is_history_navigation = request_params.page_state.IsValid(); | 5803 bool is_history_navigation = request_params.page_state.IsValid(); |
| 5848 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; | 5804 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
| 5849 RenderFrameImpl::PrepareRenderViewForNavigation( | 5805 RenderFrameImpl::PrepareRenderViewForNavigation( |
| 5850 common_params.url, request_params); | 5806 common_params.url, request_params); |
| 5851 | 5807 |
| 5852 GetContentClient()->SetActiveURL(common_params.url); | 5808 GetContentClient()->SetActiveURL(common_params.url); |
| 5853 | 5809 |
| 5854 // If this frame isn't in the same process as the main frame, it may naively | 5810 // If this frame isn't in the same process as the main frame, it may naively |
| 5855 // assume that this is the first navigation in the iframe, but this may not | 5811 // assume that this is the first navigation in the iframe, but this may not |
| 5856 // actually be the case. Inform the frame's state machine if this frame has | 5812 // actually be the case. Inform the frame's state machine if this frame has |
| 5857 // already committed other loads. | 5813 // already committed other loads. |
| 5858 if (request_params.has_committed_real_load && frame_->parent()) | 5814 if (request_params.has_committed_real_load && frame_->parent()) |
| 5859 frame_->setCommittedFirstRealLoad(); | 5815 frame_->setCommittedFirstRealLoad(); |
| 5860 | 5816 |
| 5861 bool no_current_entry = | 5817 if (is_reload && current_history_item_.isNull()) { |
| 5862 SiteIsolationPolicy::UseSubframeNavigationEntries() | |
| 5863 ? current_history_item_.isNull() | |
| 5864 : !render_view_->history_controller()->GetCurrentEntry(); | |
| 5865 if (is_reload && no_current_entry) { | |
| 5866 // We cannot reload if we do not have any history state. This happens, for | 5818 // We cannot reload if we do not have any history state. This happens, for |
| 5867 // example, when recovering from a crash. | 5819 // example, when recovering from a crash. |
| 5868 is_reload = false; | 5820 is_reload = false; |
| 5869 cache_policy = WebCachePolicy::ValidatingCacheData; | 5821 cache_policy = WebCachePolicy::ValidatingCacheData; |
| 5870 } | 5822 } |
| 5871 | 5823 |
| 5872 // If the navigation is for "view source", the WebLocalFrame needs to be put | 5824 // If the navigation is for "view source", the WebLocalFrame needs to be put |
| 5873 // in a special mode. | 5825 // in a special mode. |
| 5874 if (request_params.is_view_source) | 5826 if (request_params.is_view_source) |
| 5875 frame_->enableViewSourceMode(true); | 5827 frame_->enableViewSourceMode(true); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5937 } | 5889 } |
| 5938 should_load_request = true; | 5890 should_load_request = true; |
| 5939 } else if (is_history_navigation) { | 5891 } else if (is_history_navigation) { |
| 5940 // We must know the nav entry ID of the page we are navigating back to, | 5892 // We must know the nav entry ID of the page we are navigating back to, |
| 5941 // which should be the case because history navigations are routed via the | 5893 // which should be the case because history navigations are routed via the |
| 5942 // browser. | 5894 // browser. |
| 5943 DCHECK_NE(0, request_params.nav_entry_id); | 5895 DCHECK_NE(0, request_params.nav_entry_id); |
| 5944 std::unique_ptr<HistoryEntry> entry = | 5896 std::unique_ptr<HistoryEntry> entry = |
| 5945 PageStateToHistoryEntry(request_params.page_state); | 5897 PageStateToHistoryEntry(request_params.page_state); |
| 5946 if (entry) { | 5898 if (entry) { |
| 5947 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5899 // The browser process sends a single WebHistoryItem for this frame. |
| 5948 // By default, tell the HistoryController to go the deserialized | 5900 // TODO(creis): Change PageState to FrameState. In the meantime, we |
| 5949 // HistoryEntry. This only works if all frames are in the same | 5901 // store the relevant frame's WebHistoryItem in the root of the |
| 5950 // process. | 5902 // PageState. |
| 5951 DCHECK(!frame_->parent()); | 5903 item_for_history_navigation = entry->root(); |
| 5952 DCHECK(!browser_side_navigation); | 5904 history_load_type = request_params.is_same_document_history_load |
| 5953 std::unique_ptr<NavigationParams> navigation_params( | 5905 ? blink::WebHistorySameDocumentLoad |
| 5954 new NavigationParams(*pending_navigation_params_.get())); | 5906 : blink::WebHistoryDifferentDocumentLoad; |
| 5955 has_history_navigation_in_frame = | 5907 load_type = request_params.is_history_navigation_in_new_child |
| 5956 render_view_->history_controller()->GoToEntry( | 5908 ? blink::WebFrameLoadType::InitialHistoryLoad |
| 5957 frame_, std::move(entry), std::move(navigation_params), | 5909 : blink::WebFrameLoadType::BackForward; |
| 5958 cache_policy); | 5910 should_load_request = true; |
| 5959 } else { | |
| 5960 // In --site-per-process, the browser process sends a single | |
| 5961 // WebHistoryItem destined for this frame. | |
| 5962 // TODO(creis): Change PageState to FrameState. In the meantime, we | |
| 5963 // store the relevant frame's WebHistoryItem in the root of the | |
| 5964 // PageState. | |
| 5965 item_for_history_navigation = entry->root(); | |
| 5966 history_load_type = request_params.is_same_document_history_load | |
| 5967 ? blink::WebHistorySameDocumentLoad | |
| 5968 : blink::WebHistoryDifferentDocumentLoad; | |
| 5969 load_type = request_params.is_history_navigation_in_new_child | |
| 5970 ? blink::WebFrameLoadType::InitialHistoryLoad | |
| 5971 : blink::WebFrameLoadType::BackForward; | |
| 5972 should_load_request = true; | |
| 5973 | 5911 |
| 5974 // Keep track of which subframes the browser process has history items | 5912 // Keep track of which subframes the browser process has history items |
| 5975 // for during a history navigation. | 5913 // for during a history navigation. |
| 5976 history_subframe_unique_names_ = request_params.subframe_unique_names; | 5914 history_subframe_unique_names_ = request_params.subframe_unique_names; |
| 5977 | 5915 |
| 5978 if (history_load_type == blink::WebHistorySameDocumentLoad) { | 5916 if (history_load_type == blink::WebHistorySameDocumentLoad) { |
| 5979 // If this is marked as a same document load but we haven't committed | 5917 // If this is marked as a same document load but we haven't committed |
| 5980 // anything, treat it as a new load. The browser shouldn't let this | 5918 // anything, treat it as a new load. The browser shouldn't let this |
| 5981 // happen. | 5919 // happen. |
| 5982 if (current_history_item_.isNull()) { | 5920 if (current_history_item_.isNull()) { |
| 5921 history_load_type = blink::WebHistoryDifferentDocumentLoad; |
| 5922 NOTREACHED(); |
| 5923 } else { |
| 5924 // Additionally, if the |current_history_item_|'s document |
| 5925 // sequence number doesn't match the one sent from the browser, it |
| 5926 // is possible that this renderer has committed a different |
| 5927 // document. In such case, don't use WebHistorySameDocumentLoad. |
| 5928 if (current_history_item_.documentSequenceNumber() != |
| 5929 item_for_history_navigation.documentSequenceNumber()) { |
| 5983 history_load_type = blink::WebHistoryDifferentDocumentLoad; | 5930 history_load_type = blink::WebHistoryDifferentDocumentLoad; |
| 5984 NOTREACHED(); | |
| 5985 } else { | |
| 5986 // Additionally, if the |current_history_item_|'s document | |
| 5987 // sequence number doesn't match the one sent from the browser, it | |
| 5988 // is possible that this renderer has committed a different | |
| 5989 // document. In such case, don't use WebHistorySameDocumentLoad. | |
| 5990 if (current_history_item_.documentSequenceNumber() != | |
| 5991 item_for_history_navigation.documentSequenceNumber()) { | |
| 5992 history_load_type = blink::WebHistoryDifferentDocumentLoad; | |
| 5993 } | |
| 5994 } | 5931 } |
| 5995 } | 5932 } |
| 5933 } |
| 5996 | 5934 |
| 5997 // If this navigation is to a history item for a new child frame, we may | 5935 // If this navigation is to a history item for a new child frame, we may |
| 5998 // want to ignore it in some cases. If a Javascript navigation (i.e., | 5936 // want to ignore it in some cases. If a Javascript navigation (i.e., |
| 5999 // client redirect) interrupted it and has either been scheduled, | 5937 // client redirect) interrupted it and has either been scheduled, |
| 6000 // started loading, or has committed, we should ignore the history item. | 5938 // started loading, or has committed, we should ignore the history item. |
| 6001 bool interrupted_by_client_redirect = | 5939 bool interrupted_by_client_redirect = |
| 6002 frame_->isNavigationScheduledWithin(0) || | 5940 frame_->isNavigationScheduledWithin(0) || |
| 6003 frame_->provisionalDataSource() || | 5941 frame_->provisionalDataSource() || !current_history_item_.isNull(); |
| 6004 !current_history_item_.isNull(); | 5942 if (request_params.is_history_navigation_in_new_child && |
| 6005 if (request_params.is_history_navigation_in_new_child && | 5943 interrupted_by_client_redirect) { |
| 6006 interrupted_by_client_redirect) { | 5944 should_load_request = false; |
| 6007 should_load_request = false; | 5945 has_history_navigation_in_frame = false; |
| 6008 has_history_navigation_in_frame = false; | 5946 } |
| 6009 } | |
| 6010 | 5947 |
| 6011 // Generate the request for the load from the HistoryItem. | 5948 // Generate the request for the load from the HistoryItem. |
| 6012 // PlzNavigate: use the data sent by the browser for the url and the | 5949 // PlzNavigate: use the data sent by the browser for the url and the |
| 6013 // HTTP state. The restoration of user state such as scroll position | 5950 // HTTP state. The restoration of user state such as scroll position |
| 6014 // will be done based on the history item during the load. | 5951 // will be done based on the history item during the load. |
| 6015 if (!browser_side_navigation && should_load_request) { | 5952 if (!browser_side_navigation && should_load_request) { |
| 6016 request = frame_->requestFromHistoryItem(item_for_history_navigation, | 5953 request = frame_->requestFromHistoryItem(item_for_history_navigation, |
| 6017 cache_policy); | 5954 cache_policy); |
| 6018 } | |
| 6019 } | 5955 } |
| 6020 } | 5956 } |
| 6021 } else { | 5957 } else { |
| 6022 // Navigate to the given URL. | 5958 // Navigate to the given URL. |
| 6023 if (!start_params.extra_headers.empty() && !browser_side_navigation) { | 5959 if (!start_params.extra_headers.empty() && !browser_side_navigation) { |
| 6024 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), | 5960 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), |
| 6025 start_params.extra_headers.end(), | 5961 start_params.extra_headers.end(), |
| 6026 "\n"); | 5962 "\n"); |
| 6027 i.GetNext();) { | 5963 i.GetNext();) { |
| 6028 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 5964 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6069 history_load_type, is_client_redirect); | 6005 history_load_type, is_client_redirect); |
| 6070 | 6006 |
| 6071 if (!weak_this) | 6007 if (!weak_this) |
| 6072 return; | 6008 return; |
| 6073 } | 6009 } |
| 6074 } else { | 6010 } else { |
| 6075 // The browser expects the frame to be loading this navigation. Inform it | 6011 // The browser expects the frame to be loading this navigation. Inform it |
| 6076 // that the load stopped if needed. | 6012 // that the load stopped if needed. |
| 6077 // Note: in the case of history navigations, |should_load_request| will be | 6013 // Note: in the case of history navigations, |should_load_request| will be |
| 6078 // false, and the frame may not have been set in a loading state. Do not | 6014 // false, and the frame may not have been set in a loading state. Do not |
| 6079 // send a stop message if the HistoryController is loading in this frame | 6015 // send a stop message if a history navigation is loading in this frame |
| 6080 // nonetheless. This behavior will go away with subframe navigation | 6016 // nonetheless. This behavior will go away with subframe navigation |
| 6081 // entries. | 6017 // entries. |
| 6082 if (frame_ && !frame_->isLoading() && !has_history_navigation_in_frame) | 6018 if (frame_ && !frame_->isLoading() && !has_history_navigation_in_frame) |
| 6083 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 6019 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 6084 } | 6020 } |
| 6085 | 6021 |
| 6086 // In case LoadRequest failed before didCreateDataSource was called. | 6022 // In case LoadRequest failed before didCreateDataSource was called. |
| 6087 pending_navigation_params_.reset(); | 6023 pending_navigation_params_.reset(); |
| 6088 } | 6024 } |
| 6089 | 6025 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6347 // Needed so that history-url-only changes don't become reloads. | 6283 // Needed so that history-url-only changes don't become reloads. |
| 6348 params.history_url_for_data_url, replace, load_type, | 6284 params.history_url_for_data_url, replace, load_type, |
| 6349 item_for_history_navigation, history_load_type, is_client_redirect); | 6285 item_for_history_navigation, history_load_type, is_client_redirect); |
| 6350 } else { | 6286 } else { |
| 6351 CHECK(false) << "Invalid URL passed: " | 6287 CHECK(false) << "Invalid URL passed: " |
| 6352 << params.url.possibly_invalid_spec(); | 6288 << params.url.possibly_invalid_spec(); |
| 6353 } | 6289 } |
| 6354 } | 6290 } |
| 6355 | 6291 |
| 6356 void RenderFrameImpl::SendUpdateState() { | 6292 void RenderFrameImpl::SendUpdateState() { |
| 6357 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | |
| 6358 if (current_history_item_.isNull()) | 6293 if (current_history_item_.isNull()) |
| 6359 return; | 6294 return; |
| 6360 | 6295 |
| 6361 Send(new FrameHostMsg_UpdateState( | 6296 Send(new FrameHostMsg_UpdateState( |
| 6362 routing_id_, SingleHistoryItemToPageState(current_history_item_))); | 6297 routing_id_, SingleHistoryItemToPageState(current_history_item_))); |
| 6363 } | 6298 } |
| 6364 | 6299 |
| 6365 void RenderFrameImpl::MaybeEnableMojoBindings() { | 6300 void RenderFrameImpl::MaybeEnableMojoBindings() { |
| 6366 int enabled_bindings = RenderProcess::current()->GetEnabledBindings(); | 6301 int enabled_bindings = RenderProcess::current()->GetEnabledBindings(); |
| 6367 // BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO and BINDINGS_POLICY_HEADLESS | 6302 // BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO and BINDINGS_POLICY_HEADLESS |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6866 // event target. Potentially a Pepper plugin will receive the event. | 6801 // event target. Potentially a Pepper plugin will receive the event. |
| 6867 // In order to tell whether a plugin gets the last mouse event and which it | 6802 // In order to tell whether a plugin gets the last mouse event and which it |
| 6868 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6803 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6869 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6804 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6870 // |pepper_last_mouse_event_target_|. | 6805 // |pepper_last_mouse_event_target_|. |
| 6871 pepper_last_mouse_event_target_ = nullptr; | 6806 pepper_last_mouse_event_target_ = nullptr; |
| 6872 #endif | 6807 #endif |
| 6873 } | 6808 } |
| 6874 | 6809 |
| 6875 } // namespace content | 6810 } // namespace content |
| OLD | NEW |