Chromium Code Reviews| 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 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3089 if (focused_pepper_plugin_) | 3086 if (focused_pepper_plugin_) |
| 3090 GetRenderWidget()->set_focused_pepper_plugin(nullptr); | 3087 GetRenderWidget()->set_focused_pepper_plugin(nullptr); |
| 3091 #endif | 3088 #endif |
| 3092 | 3089 |
| 3093 for (auto& observer : observers_) | 3090 for (auto& observer : observers_) |
| 3094 observer.FrameDetached(); | 3091 observer.FrameDetached(); |
| 3095 for (auto& observer : render_view_->observers()) | 3092 for (auto& observer : render_view_->observers()) |
| 3096 observer.FrameDetached(frame); | 3093 observer.FrameDetached(frame); |
| 3097 | 3094 |
| 3098 // Send a state update before the frame is detached. | 3095 // Send a state update before the frame is detached. |
| 3099 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3096 SendUpdateState(); |
| 3100 SendUpdateState(); | |
| 3101 | 3097 |
| 3102 // We only notify the browser process when the frame is being detached for | 3098 // We only notify the browser process when the frame is being detached for |
| 3103 // removal and it was initiated from the renderer process. | 3099 // removal and it was initiated from the renderer process. |
| 3104 if (!in_browser_initiated_detach_ && type == DetachType::Remove) | 3100 if (!in_browser_initiated_detach_ && type == DetachType::Remove) |
| 3105 Send(new FrameHostMsg_Detach(routing_id_)); | 3101 Send(new FrameHostMsg_Detach(routing_id_)); |
| 3106 | 3102 |
| 3107 // Clean up the associated RenderWidget for the frame, if there is one. | 3103 // Clean up the associated RenderWidget for the frame, if there is one. |
| 3108 if (render_widget_) { | 3104 if (render_widget_) { |
| 3109 render_widget_->UnregisterRenderFrame(this); | 3105 render_widget_->UnregisterRenderFrame(this); |
| 3110 render_widget_->CloseForFrame(); | 3106 render_widget_->CloseForFrame(); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3289 Send(new FrameHostMsg_DownloadUrl(params)); | 3285 Send(new FrameHostMsg_DownloadUrl(params)); |
| 3290 } else { | 3286 } else { |
| 3291 OpenURL(request.url(), IsHttpPost(request), | 3287 OpenURL(request.url(), IsHttpPost(request), |
| 3292 GetRequestBodyForWebURLRequest(request), | 3288 GetRequestBodyForWebURLRequest(request), |
| 3293 GetWebURLRequestHeaders(request), referrer, policy, | 3289 GetWebURLRequestHeaders(request), referrer, policy, |
| 3294 should_replace_current_entry, false); | 3290 should_replace_current_entry, false); |
| 3295 } | 3291 } |
| 3296 } | 3292 } |
| 3297 | 3293 |
| 3298 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { | 3294 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { |
| 3299 // OOPIF enabled modes will punt this navigation to the browser in | 3295 // We will punt this navigation to the browser in decidePolicyForNavigation. |
| 3300 // decidePolicyForNavigation. | 3296 // TODO(creis): Look into cleaning this up. |
| 3301 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3297 return WebHistoryItem(); |
| 3302 return WebHistoryItem(); | |
| 3303 | |
| 3304 return render_view_->history_controller()->GetItemForNewChildFrame(this); | |
| 3305 } | 3298 } |
| 3306 | 3299 |
| 3307 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { | 3300 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { |
| 3308 for (auto& observer : observers_) | 3301 for (auto& observer : observers_) |
| 3309 observer.WillSendSubmitEvent(form); | 3302 observer.WillSendSubmitEvent(form); |
| 3310 } | 3303 } |
| 3311 | 3304 |
| 3312 void RenderFrameImpl::willSubmitForm(const blink::WebFormElement& form) { | 3305 void RenderFrameImpl::willSubmitForm(const blink::WebFormElement& form) { |
| 3313 // With PlzNavigate-enabled, this will be called before a DataSource has been | 3306 // With PlzNavigate-enabled, this will be called before a DataSource has been |
| 3314 // set-up. | 3307 // set-up. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3464 observer.DidStartProvisionalLoad(); | 3457 observer.DidStartProvisionalLoad(); |
| 3465 | 3458 |
| 3466 Send(new FrameHostMsg_DidStartProvisionalLoad( | 3459 Send(new FrameHostMsg_DidStartProvisionalLoad( |
| 3467 routing_id_, ds->getRequest().url(), navigation_start)); | 3460 routing_id_, ds->getRequest().url(), navigation_start)); |
| 3468 } | 3461 } |
| 3469 | 3462 |
| 3470 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 3463 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
| 3471 blink::WebLocalFrame* frame) { | 3464 blink::WebLocalFrame* frame) { |
| 3472 DCHECK_EQ(frame_, frame); | 3465 DCHECK_EQ(frame_, frame); |
| 3473 | 3466 |
| 3474 // We don't use HistoryController in OOPIF enabled modes. | 3467 // TODO(creis): Determine if this can be removed or if we need to clear any |
| 3475 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 3468 // local state here to fix https://crbug.com/671276. |
| 3476 return; | |
| 3477 | |
| 3478 render_view_->history_controller()->RemoveChildrenForRedirect(this); | |
| 3479 } | 3469 } |
| 3480 | 3470 |
| 3481 void RenderFrameImpl::didFailProvisionalLoad( | 3471 void RenderFrameImpl::didFailProvisionalLoad( |
| 3482 blink::WebLocalFrame* frame, | 3472 blink::WebLocalFrame* frame, |
| 3483 const blink::WebURLError& error, | 3473 const blink::WebURLError& error, |
| 3484 blink::WebHistoryCommitType commit_type) { | 3474 blink::WebHistoryCommitType commit_type) { |
| 3485 TRACE_EVENT1("navigation,benchmark,rail", | 3475 TRACE_EVENT1("navigation,benchmark,rail", |
| 3486 "RenderFrameImpl::didFailProvisionalLoad", "id", routing_id_); | 3476 "RenderFrameImpl::didFailProvisionalLoad", "id", routing_id_); |
| 3487 DCHECK_EQ(frame_, frame); | 3477 DCHECK_EQ(frame_, frame); |
| 3488 WebDataSource* ds = frame->provisionalDataSource(); | 3478 WebDataSource* ds = frame->provisionalDataSource(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3607 // first paint of that page, so it can cancel the timer that waits for it. | 3597 // first paint of that page, so it can cancel the timer that waits for it. |
| 3608 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3598 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
| 3609 render_view_->QueueMessage( | 3599 render_view_->QueueMessage( |
| 3610 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), | 3600 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), |
| 3611 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 3601 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
| 3612 } | 3602 } |
| 3613 | 3603 |
| 3614 // When we perform a new navigation, we need to update the last committed | 3604 // When we perform a new navigation, we need to update the last committed |
| 3615 // session history entry with state for the page we are leaving. Do this | 3605 // session history entry with state for the page we are leaving. Do this |
| 3616 // before updating the current history item. | 3606 // before updating the current history item. |
| 3617 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3607 SendUpdateState(); |
| 3618 SendUpdateState(); | 3608 |
| 3619 } else { | |
| 3620 render_view_->SendUpdateState(); | |
| 3621 render_view_->history_controller()->UpdateForCommit( | |
| 3622 this, item, commit_type, navigation_state->WasWithinSamePage()); | |
| 3623 } | |
| 3624 // Update the current history item for this frame (both in default Chrome and | 3609 // Update the current history item for this frame (both in default Chrome and |
| 3625 // subframe FrameNavigationEntry modes). | 3610 // subframe FrameNavigationEntry modes). |
| 3626 current_history_item_ = item; | 3611 current_history_item_ = item; |
| 3627 | 3612 |
| 3628 InternalDocumentStateData* internal_data = | 3613 InternalDocumentStateData* internal_data = |
| 3629 InternalDocumentStateData::FromDocumentState(document_state); | 3614 InternalDocumentStateData::FromDocumentState(document_state); |
| 3630 | 3615 |
| 3631 if (internal_data->must_reset_scroll_and_scale_state()) { | 3616 if (internal_data->must_reset_scroll_and_scale_state()) { |
| 3632 render_view_->webview()->resetScrollAndScaleState(); | 3617 render_view_->webview()->resetScrollAndScaleState(); |
| 3633 internal_data->set_must_reset_scroll_and_scale_state(false); | 3618 internal_data->set_must_reset_scroll_and_scale_state(false); |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4872 params.should_update_history = | 4857 params.should_update_history = |
| 4873 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; | 4858 !ds->hasUnreachableURL() && response.httpStatusCode() != 404; |
| 4874 | 4859 |
| 4875 params.searchable_form_url = internal_data->searchable_form_url(); | 4860 params.searchable_form_url = internal_data->searchable_form_url(); |
| 4876 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 4861 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
| 4877 | 4862 |
| 4878 params.gesture = render_view_->navigation_gesture_; | 4863 params.gesture = render_view_->navigation_gesture_; |
| 4879 render_view_->navigation_gesture_ = NavigationGestureUnknown; | 4864 render_view_->navigation_gesture_ = NavigationGestureUnknown; |
| 4880 | 4865 |
| 4881 // Make navigation state a part of the DidCommitProvisionalLoad message so | 4866 // Make navigation state a part of the DidCommitProvisionalLoad message so |
| 4882 // that committed entry has it at all times. | 4867 // that committed entry has it at all times. Send a single HistoryItem for |
| 4883 int64_t post_id = -1; | 4868 // this frame, rather than the whole tree. It will be stored in the |
| 4884 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 4869 // corresponding FrameNavigationEntry. |
| 4885 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); | 4870 params.page_state = SingleHistoryItemToPageState(item); |
| 4886 if (entry) { | |
| 4887 params.page_state = HistoryEntryToPageState(entry); | |
| 4888 post_id = ExtractPostId(entry->root()); | |
| 4889 } else { | |
| 4890 params.page_state = PageState::CreateFromURL(request.url()); | |
| 4891 } | |
| 4892 } else { | |
| 4893 // In --site-per-process, just send a single HistoryItem for this frame, | |
| 4894 // rather than the whole tree. It will be stored in the corresponding | |
| 4895 // FrameNavigationEntry. | |
| 4896 params.page_state = SingleHistoryItemToPageState(item); | |
| 4897 post_id = ExtractPostId(item); | |
| 4898 } | |
| 4899 | 4871 |
| 4900 // When using subframe navigation entries, method and post id are set for all | 4872 // Method and post id are set for all frames. |
|
nasko
2017/01/26 00:56:20
Does this comment still add meaningful info? Why w
Charlie Reis
2017/01/26 01:07:47
Done.
| |
| 4901 // frames. Otherwise, they are only set for the main frame navigation. | 4873 params.method = request.httpMethod().latin1(); |
| 4902 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 4874 if (params.method == "POST") |
| 4903 params.method = request.httpMethod().latin1(); | 4875 params.post_id = ExtractPostId(item); |
| 4904 if (params.method == "POST") | |
| 4905 params.post_id = post_id; | |
| 4906 } | |
| 4907 | 4876 |
| 4908 params.frame_unique_name = item.target().utf8(); | 4877 params.frame_unique_name = item.target().utf8(); |
| 4909 params.item_sequence_number = item.itemSequenceNumber(); | 4878 params.item_sequence_number = item.itemSequenceNumber(); |
| 4910 params.document_sequence_number = item.documentSequenceNumber(); | 4879 params.document_sequence_number = item.documentSequenceNumber(); |
| 4911 | 4880 |
| 4912 // If the page contained a client redirect (meta refresh, document.loc...), | 4881 // If the page contained a client redirect (meta refresh, document.loc...), |
| 4913 // set the referrer appropriately. | 4882 // set the referrer appropriately. |
| 4914 if (ds->isClientRedirect()) { | 4883 if (ds->isClientRedirect()) { |
| 4915 params.referrer = | 4884 params.referrer = |
| 4916 Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy()); | 4885 Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4970 params.transition = ui::PAGE_TRANSITION_LINK; | 4939 params.transition = ui::PAGE_TRANSITION_LINK; |
| 4971 } | 4940 } |
| 4972 | 4941 |
| 4973 // If the page contained a client redirect (meta refresh, document.loc...), | 4942 // If the page contained a client redirect (meta refresh, document.loc...), |
| 4974 // set the transition appropriately. | 4943 // set the transition appropriately. |
| 4975 if (ds->isClientRedirect()) { | 4944 if (ds->isClientRedirect()) { |
| 4976 params.transition = ui::PageTransitionFromInt( | 4945 params.transition = ui::PageTransitionFromInt( |
| 4977 params.transition | ui::PAGE_TRANSITION_CLIENT_REDIRECT); | 4946 params.transition | ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
| 4978 } | 4947 } |
| 4979 | 4948 |
| 4980 // When using subframe navigation entries, method and post id have already | |
| 4981 // been set. | |
| 4982 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | |
| 4983 params.method = request.httpMethod().latin1(); | |
| 4984 if (params.method == "POST") | |
| 4985 params.post_id = post_id; | |
| 4986 } | |
| 4987 | |
| 4988 // Send the user agent override back. | 4949 // Send the user agent override back. |
| 4989 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); | 4950 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
| 4990 | 4951 |
| 4991 // Track the URL of the original request. We use the first entry of the | 4952 // Track the URL of the original request. We use the first entry of the |
| 4992 // redirect chain if it exists because the chain may have started in another | 4953 // redirect chain if it exists because the chain may have started in another |
| 4993 // process. | 4954 // process. |
| 4994 params.original_request_url = GetOriginalRequestURL(ds); | 4955 params.original_request_url = GetOriginalRequestURL(ds); |
| 4995 | 4956 |
| 4996 params.history_list_was_cleared = | 4957 params.history_list_was_cleared = |
| 4997 navigation_state->request_params().should_clear_history_list; | 4958 navigation_state->request_params().should_clear_history_list; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5287 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 5248 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
| 5288 render_view_->renderer_preferences_ | 5249 render_view_->renderer_preferences_ |
| 5289 .browser_handles_all_top_level_requests) { | 5250 .browser_handles_all_top_level_requests) { |
| 5290 OpenURL(url, IsHttpPost(info.urlRequest), | 5251 OpenURL(url, IsHttpPost(info.urlRequest), |
| 5291 GetRequestBodyForWebURLRequest(info.urlRequest), | 5252 GetRequestBodyForWebURLRequest(info.urlRequest), |
| 5292 GetWebURLRequestHeaders(info.urlRequest), referrer, | 5253 GetWebURLRequestHeaders(info.urlRequest), referrer, |
| 5293 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 5254 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
| 5294 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 5255 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
| 5295 } | 5256 } |
| 5296 | 5257 |
| 5297 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 5258 // Back/forward navigations in newly created subframes should be sent to the |
| 5298 // should be sent to the browser if there is a matching FrameNavigationEntry, | 5259 // browser if there is a matching FrameNavigationEntry, and if it isn't just |
| 5299 // and if it isn't just staying at about:blank. If this frame isn't in the | 5260 // staying at about:blank. If this frame isn't in the map of unique names |
| 5300 // map of unique names that have history items, or if it's staying at the | 5261 // that have history items, or if it's staying at the initial about:blank URL, |
| 5301 // initial about:blank URL, fall back to loading the default url. (We remove | 5262 // fall back to loading the default url. (We remove each name as we encounter |
| 5302 // each name as we encounter it, because it will only be used once as the | 5263 // it, because it will only be used once as the frame is created.) |
| 5303 // frame is created.) | 5264 if (info.isHistoryNavigationInNewChildFrame && is_content_initiated && |
| 5304 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | |
| 5305 info.isHistoryNavigationInNewChildFrame && is_content_initiated && | |
| 5306 frame_->parent()) { | 5265 frame_->parent()) { |
| 5307 // Check whether the browser has a history item for this frame that isn't | 5266 // Check whether the browser has a history item for this frame that isn't |
| 5308 // just staying at the initial about:blank document. | 5267 // just staying at the initial about:blank document. |
| 5309 bool should_ask_browser = false; | 5268 bool should_ask_browser = false; |
| 5310 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); | 5269 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); |
| 5311 const auto& iter = parent->history_subframe_unique_names_.find( | 5270 const auto& iter = parent->history_subframe_unique_names_.find( |
| 5312 frame_->uniqueName().utf8()); | 5271 frame_->uniqueName().utf8()); |
| 5313 if (iter != parent->history_subframe_unique_names_.end()) { | 5272 if (iter != parent->history_subframe_unique_names_.end()) { |
| 5314 bool history_item_is_about_blank = iter->second; | 5273 bool history_item_is_about_blank = iter->second; |
| 5315 should_ask_browser = | 5274 should_ask_browser = |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5824 if (GetContentClient()->renderer()->AllowPopup()) | 5783 if (GetContentClient()->renderer()->AllowPopup()) |
| 5825 params.user_gesture = true; | 5784 params.user_gesture = true; |
| 5826 | 5785 |
| 5827 if (policy == blink::WebNavigationPolicyNewBackgroundTab || | 5786 if (policy == blink::WebNavigationPolicyNewBackgroundTab || |
| 5828 policy == blink::WebNavigationPolicyNewForegroundTab || | 5787 policy == blink::WebNavigationPolicyNewForegroundTab || |
| 5829 policy == blink::WebNavigationPolicyNewWindow || | 5788 policy == blink::WebNavigationPolicyNewWindow || |
| 5830 policy == blink::WebNavigationPolicyNewPopup) { | 5789 policy == blink::WebNavigationPolicyNewPopup) { |
| 5831 WebUserGestureIndicator::consumeUserGesture(); | 5790 WebUserGestureIndicator::consumeUserGesture(); |
| 5832 } | 5791 } |
| 5833 | 5792 |
| 5834 if (is_history_navigation_in_new_child) { | 5793 if (is_history_navigation_in_new_child) |
| 5835 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | |
| 5836 params.is_history_navigation_in_new_child = true; | 5794 params.is_history_navigation_in_new_child = true; |
| 5837 } | |
| 5838 | 5795 |
| 5839 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 5796 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 5840 } | 5797 } |
| 5841 | 5798 |
| 5842 void RenderFrameImpl::NavigateInternal( | 5799 void RenderFrameImpl::NavigateInternal( |
| 5843 const CommonNavigationParams& common_params, | 5800 const CommonNavigationParams& common_params, |
| 5844 const StartNavigationParams& start_params, | 5801 const StartNavigationParams& start_params, |
| 5845 const RequestNavigationParams& request_params, | 5802 const RequestNavigationParams& request_params, |
| 5846 std::unique_ptr<StreamOverrideParameters> stream_params) { | 5803 std::unique_ptr<StreamOverrideParameters> stream_params) { |
| 5847 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | 5804 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
| 5848 | 5805 |
| 5849 // Lower bound for browser initiated navigation start time. | 5806 // Lower bound for browser initiated navigation start time. |
| 5850 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 5807 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
| 5851 bool is_reload = IsReload(common_params.navigation_type); | 5808 bool is_reload = IsReload(common_params.navigation_type); |
| 5852 bool is_history_navigation = request_params.page_state.IsValid(); | 5809 bool is_history_navigation = request_params.page_state.IsValid(); |
| 5853 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; | 5810 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
| 5854 RenderFrameImpl::PrepareRenderViewForNavigation( | 5811 RenderFrameImpl::PrepareRenderViewForNavigation( |
| 5855 common_params.url, request_params); | 5812 common_params.url, request_params); |
| 5856 | 5813 |
| 5857 GetContentClient()->SetActiveURL(common_params.url); | 5814 GetContentClient()->SetActiveURL(common_params.url); |
| 5858 | 5815 |
| 5859 // If this frame isn't in the same process as the main frame, it may naively | 5816 // If this frame isn't in the same process as the main frame, it may naively |
| 5860 // assume that this is the first navigation in the iframe, but this may not | 5817 // assume that this is the first navigation in the iframe, but this may not |
| 5861 // actually be the case. Inform the frame's state machine if this frame has | 5818 // actually be the case. Inform the frame's state machine if this frame has |
| 5862 // already committed other loads. | 5819 // already committed other loads. |
| 5863 if (request_params.has_committed_real_load && frame_->parent()) | 5820 if (request_params.has_committed_real_load && frame_->parent()) |
| 5864 frame_->setCommittedFirstRealLoad(); | 5821 frame_->setCommittedFirstRealLoad(); |
| 5865 | 5822 |
| 5866 bool no_current_entry = | 5823 if (is_reload && current_history_item_.isNull()) { |
| 5867 SiteIsolationPolicy::UseSubframeNavigationEntries() | |
| 5868 ? current_history_item_.isNull() | |
| 5869 : !render_view_->history_controller()->GetCurrentEntry(); | |
| 5870 if (is_reload && no_current_entry) { | |
| 5871 // We cannot reload if we do not have any history state. This happens, for | 5824 // We cannot reload if we do not have any history state. This happens, for |
| 5872 // example, when recovering from a crash. | 5825 // example, when recovering from a crash. |
| 5873 is_reload = false; | 5826 is_reload = false; |
| 5874 cache_policy = WebCachePolicy::ValidatingCacheData; | 5827 cache_policy = WebCachePolicy::ValidatingCacheData; |
| 5875 } | 5828 } |
| 5876 | 5829 |
| 5877 // If the navigation is for "view source", the WebLocalFrame needs to be put | 5830 // If the navigation is for "view source", the WebLocalFrame needs to be put |
| 5878 // in a special mode. | 5831 // in a special mode. |
| 5879 if (request_params.is_view_source) | 5832 if (request_params.is_view_source) |
| 5880 frame_->enableViewSourceMode(true); | 5833 frame_->enableViewSourceMode(true); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5942 } | 5895 } |
| 5943 should_load_request = true; | 5896 should_load_request = true; |
| 5944 } else if (is_history_navigation) { | 5897 } else if (is_history_navigation) { |
| 5945 // We must know the nav entry ID of the page we are navigating back to, | 5898 // We must know the nav entry ID of the page we are navigating back to, |
| 5946 // which should be the case because history navigations are routed via the | 5899 // which should be the case because history navigations are routed via the |
| 5947 // browser. | 5900 // browser. |
| 5948 DCHECK_NE(0, request_params.nav_entry_id); | 5901 DCHECK_NE(0, request_params.nav_entry_id); |
| 5949 std::unique_ptr<HistoryEntry> entry = | 5902 std::unique_ptr<HistoryEntry> entry = |
| 5950 PageStateToHistoryEntry(request_params.page_state); | 5903 PageStateToHistoryEntry(request_params.page_state); |
| 5951 if (entry) { | 5904 if (entry) { |
| 5952 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 5905 // The browser process sends a single WebHistoryItem for this frame. |
| 5953 // By default, tell the HistoryController to go the deserialized | 5906 // TODO(creis): Change PageState to FrameState. In the meantime, we |
| 5954 // HistoryEntry. This only works if all frames are in the same | 5907 // store the relevant frame's WebHistoryItem in the root of the |
| 5955 // process. | 5908 // PageState. |
| 5956 DCHECK(!frame_->parent()); | 5909 item_for_history_navigation = entry->root(); |
| 5957 DCHECK(!browser_side_navigation); | 5910 history_load_type = request_params.is_same_document_history_load |
| 5958 std::unique_ptr<NavigationParams> navigation_params( | 5911 ? blink::WebHistorySameDocumentLoad |
| 5959 new NavigationParams(*pending_navigation_params_.get())); | 5912 : blink::WebHistoryDifferentDocumentLoad; |
| 5960 has_history_navigation_in_frame = | 5913 load_type = request_params.is_history_navigation_in_new_child |
| 5961 render_view_->history_controller()->GoToEntry( | 5914 ? blink::WebFrameLoadType::InitialHistoryLoad |
| 5962 frame_, std::move(entry), std::move(navigation_params), | 5915 : blink::WebFrameLoadType::BackForward; |
| 5963 cache_policy); | 5916 should_load_request = true; |
| 5964 } else { | |
| 5965 // In --site-per-process, the browser process sends a single | |
| 5966 // WebHistoryItem destined for this frame. | |
| 5967 // TODO(creis): Change PageState to FrameState. In the meantime, we | |
| 5968 // store the relevant frame's WebHistoryItem in the root of the | |
| 5969 // PageState. | |
| 5970 item_for_history_navigation = entry->root(); | |
| 5971 history_load_type = request_params.is_same_document_history_load | |
| 5972 ? blink::WebHistorySameDocumentLoad | |
| 5973 : blink::WebHistoryDifferentDocumentLoad; | |
| 5974 load_type = request_params.is_history_navigation_in_new_child | |
| 5975 ? blink::WebFrameLoadType::InitialHistoryLoad | |
| 5976 : blink::WebFrameLoadType::BackForward; | |
| 5977 should_load_request = true; | |
| 5978 | 5917 |
| 5979 // Keep track of which subframes the browser process has history items | 5918 // Keep track of which subframes the browser process has history items |
| 5980 // for during a history navigation. | 5919 // for during a history navigation. |
| 5981 history_subframe_unique_names_ = request_params.subframe_unique_names; | 5920 history_subframe_unique_names_ = request_params.subframe_unique_names; |
| 5982 | 5921 |
| 5983 if (history_load_type == blink::WebHistorySameDocumentLoad) { | 5922 if (history_load_type == blink::WebHistorySameDocumentLoad) { |
| 5984 // If this is marked as a same document load but we haven't committed | 5923 // If this is marked as a same document load but we haven't committed |
| 5985 // anything, treat it as a new load. The browser shouldn't let this | 5924 // anything, treat it as a new load. The browser shouldn't let this |
| 5986 // happen. | 5925 // happen. |
| 5987 if (current_history_item_.isNull()) { | 5926 if (current_history_item_.isNull()) { |
| 5927 history_load_type = blink::WebHistoryDifferentDocumentLoad; | |
| 5928 NOTREACHED(); | |
| 5929 } else { | |
| 5930 // Additionally, if the |current_history_item_|'s document | |
| 5931 // sequence number doesn't match the one sent from the browser, it | |
| 5932 // is possible that this renderer has committed a different | |
| 5933 // document. In such case, don't use WebHistorySameDocumentLoad. | |
| 5934 if (current_history_item_.documentSequenceNumber() != | |
| 5935 item_for_history_navigation.documentSequenceNumber()) { | |
| 5988 history_load_type = blink::WebHistoryDifferentDocumentLoad; | 5936 history_load_type = blink::WebHistoryDifferentDocumentLoad; |
| 5989 NOTREACHED(); | |
| 5990 } else { | |
| 5991 // Additionally, if the |current_history_item_|'s document | |
| 5992 // sequence number doesn't match the one sent from the browser, it | |
| 5993 // is possible that this renderer has committed a different | |
| 5994 // document. In such case, don't use WebHistorySameDocumentLoad. | |
| 5995 if (current_history_item_.documentSequenceNumber() != | |
| 5996 item_for_history_navigation.documentSequenceNumber()) { | |
| 5997 history_load_type = blink::WebHistoryDifferentDocumentLoad; | |
| 5998 } | |
| 5999 } | 5937 } |
| 6000 } | 5938 } |
| 5939 } | |
| 6001 | 5940 |
| 6002 // If this navigation is to a history item for a new child frame, we may | 5941 // If this navigation is to a history item for a new child frame, we may |
| 6003 // want to ignore it in some cases. If a Javascript navigation (i.e., | 5942 // want to ignore it in some cases. If a Javascript navigation (i.e., |
| 6004 // client redirect) interrupted it and has either been scheduled, | 5943 // client redirect) interrupted it and has either been scheduled, |
| 6005 // started loading, or has committed, we should ignore the history item. | 5944 // started loading, or has committed, we should ignore the history item. |
| 6006 bool interrupted_by_client_redirect = | 5945 bool interrupted_by_client_redirect = |
| 6007 frame_->isNavigationScheduledWithin(0) || | 5946 frame_->isNavigationScheduledWithin(0) || |
| 6008 frame_->provisionalDataSource() || | 5947 frame_->provisionalDataSource() || !current_history_item_.isNull(); |
| 6009 !current_history_item_.isNull(); | 5948 if (request_params.is_history_navigation_in_new_child && |
| 6010 if (request_params.is_history_navigation_in_new_child && | 5949 interrupted_by_client_redirect) { |
| 6011 interrupted_by_client_redirect) { | 5950 should_load_request = false; |
| 6012 should_load_request = false; | 5951 has_history_navigation_in_frame = false; |
| 6013 has_history_navigation_in_frame = false; | 5952 } |
| 6014 } | |
| 6015 | 5953 |
| 6016 // Generate the request for the load from the HistoryItem. | 5954 // Generate the request for the load from the HistoryItem. |
| 6017 // PlzNavigate: use the data sent by the browser for the url and the | 5955 // PlzNavigate: use the data sent by the browser for the url and the |
| 6018 // HTTP state. The restoration of user state such as scroll position | 5956 // HTTP state. The restoration of user state such as scroll position |
| 6019 // will be done based on the history item during the load. | 5957 // will be done based on the history item during the load. |
| 6020 if (!browser_side_navigation && should_load_request) { | 5958 if (!browser_side_navigation && should_load_request) { |
| 6021 request = frame_->requestFromHistoryItem(item_for_history_navigation, | 5959 request = frame_->requestFromHistoryItem(item_for_history_navigation, |
| 6022 cache_policy); | 5960 cache_policy); |
| 6023 } | |
| 6024 } | 5961 } |
| 6025 } | 5962 } |
| 6026 } else { | 5963 } else { |
| 6027 // Navigate to the given URL. | 5964 // Navigate to the given URL. |
| 6028 if (!start_params.extra_headers.empty() && !browser_side_navigation) { | 5965 if (!start_params.extra_headers.empty() && !browser_side_navigation) { |
| 6029 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), | 5966 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), |
| 6030 start_params.extra_headers.end(), | 5967 start_params.extra_headers.end(), |
| 6031 "\n"); | 5968 "\n"); |
| 6032 i.GetNext();) { | 5969 i.GetNext();) { |
| 6033 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 5970 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6074 history_load_type, is_client_redirect); | 6011 history_load_type, is_client_redirect); |
| 6075 | 6012 |
| 6076 if (!weak_this) | 6013 if (!weak_this) |
| 6077 return; | 6014 return; |
| 6078 } | 6015 } |
| 6079 } else { | 6016 } else { |
| 6080 // The browser expects the frame to be loading this navigation. Inform it | 6017 // The browser expects the frame to be loading this navigation. Inform it |
| 6081 // that the load stopped if needed. | 6018 // that the load stopped if needed. |
| 6082 // Note: in the case of history navigations, |should_load_request| will be | 6019 // Note: in the case of history navigations, |should_load_request| will be |
| 6083 // false, and the frame may not have been set in a loading state. Do not | 6020 // false, and the frame may not have been set in a loading state. Do not |
| 6084 // send a stop message if the HistoryController is loading in this frame | 6021 // send a stop message if a history navigation is loading in this frame |
| 6085 // nonetheless. This behavior will go away with subframe navigation | 6022 // nonetheless. This behavior will go away with subframe navigation |
| 6086 // entries. | 6023 // entries. |
| 6087 if (frame_ && !frame_->isLoading() && !has_history_navigation_in_frame) | 6024 if (frame_ && !frame_->isLoading() && !has_history_navigation_in_frame) |
| 6088 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 6025 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 6089 } | 6026 } |
| 6090 | 6027 |
| 6091 // In case LoadRequest failed before didCreateDataSource was called. | 6028 // In case LoadRequest failed before didCreateDataSource was called. |
| 6092 pending_navigation_params_.reset(); | 6029 pending_navigation_params_.reset(); |
| 6093 } | 6030 } |
| 6094 | 6031 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6352 // Needed so that history-url-only changes don't become reloads. | 6289 // Needed so that history-url-only changes don't become reloads. |
| 6353 params.history_url_for_data_url, replace, load_type, | 6290 params.history_url_for_data_url, replace, load_type, |
| 6354 item_for_history_navigation, history_load_type, is_client_redirect); | 6291 item_for_history_navigation, history_load_type, is_client_redirect); |
| 6355 } else { | 6292 } else { |
| 6356 CHECK(false) << "Invalid URL passed: " | 6293 CHECK(false) << "Invalid URL passed: " |
| 6357 << params.url.possibly_invalid_spec(); | 6294 << params.url.possibly_invalid_spec(); |
| 6358 } | 6295 } |
| 6359 } | 6296 } |
| 6360 | 6297 |
| 6361 void RenderFrameImpl::SendUpdateState() { | 6298 void RenderFrameImpl::SendUpdateState() { |
| 6362 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | |
| 6363 if (current_history_item_.isNull()) | 6299 if (current_history_item_.isNull()) |
| 6364 return; | 6300 return; |
| 6365 | 6301 |
| 6366 Send(new FrameHostMsg_UpdateState( | 6302 Send(new FrameHostMsg_UpdateState( |
| 6367 routing_id_, SingleHistoryItemToPageState(current_history_item_))); | 6303 routing_id_, SingleHistoryItemToPageState(current_history_item_))); |
| 6368 } | 6304 } |
| 6369 | 6305 |
| 6370 void RenderFrameImpl::MaybeEnableMojoBindings() { | 6306 void RenderFrameImpl::MaybeEnableMojoBindings() { |
| 6371 int enabled_bindings = RenderProcess::current()->GetEnabledBindings(); | 6307 int enabled_bindings = RenderProcess::current()->GetEnabledBindings(); |
| 6372 // BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO and BINDINGS_POLICY_HEADLESS | 6308 // BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO and BINDINGS_POLICY_HEADLESS |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6878 // event target. Potentially a Pepper plugin will receive the event. | 6814 // event target. Potentially a Pepper plugin will receive the event. |
| 6879 // In order to tell whether a plugin gets the last mouse event and which it | 6815 // In order to tell whether a plugin gets the last mouse event and which it |
| 6880 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6816 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6881 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6817 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6882 // |pepper_last_mouse_event_target_|. | 6818 // |pepper_last_mouse_event_target_|. |
| 6883 pepper_last_mouse_event_target_ = nullptr; | 6819 pepper_last_mouse_event_target_ = nullptr; |
| 6884 #endif | 6820 #endif |
| 6885 } | 6821 } |
| 6886 | 6822 |
| 6887 } // namespace content | 6823 } // namespace content |
| OLD | NEW |