| 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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) | 506 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) |
| 507 IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused) | 507 IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused) |
| 508 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoad, | 508 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoad, |
| 509 OnDidStartProvisionalLoad) | 509 OnDidStartProvisionalLoad) |
| 510 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError, | 510 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError, |
| 511 OnDidFailProvisionalLoadWithError) | 511 OnDidFailProvisionalLoadWithError) |
| 512 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, | 512 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, |
| 513 OnDidFailLoadWithError) | 513 OnDidFailLoadWithError) |
| 514 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, | 514 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, |
| 515 OnDidCommitProvisionalLoad(msg)) | 515 OnDidCommitProvisionalLoad(msg)) |
| 516 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDropNavigation, OnDidDropNavigation) | |
| 517 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateState, OnUpdateState) | 516 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateState, OnUpdateState) |
| 518 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 517 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
| 519 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, | 518 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, |
| 520 OnDocumentOnLoadCompleted) | 519 OnDocumentOnLoadCompleted) |
| 521 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) | 520 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) |
| 522 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) | 521 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) |
| 523 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) | 522 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) |
| 524 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, | 523 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, |
| 525 OnJavaScriptExecuteResponse) | 524 OnJavaScriptExecuteResponse) |
| 526 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse, | 525 IPC_MESSAGE_HANDLER(FrameHostMsg_VisualStateResponse, |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 !validated_params.was_within_same_page) { | 1019 !validated_params.was_within_same_page) { |
| 1021 RenderWidgetHostImpl::From(GetView()->GetRenderWidgetHost()) | 1020 RenderWidgetHostImpl::From(GetView()->GetRenderWidgetHost()) |
| 1022 ->StartNewContentRenderingTimeout(); | 1021 ->StartNewContentRenderingTimeout(); |
| 1023 } | 1022 } |
| 1024 | 1023 |
| 1025 // PlzNavigate | 1024 // PlzNavigate |
| 1026 if (IsBrowserSideNavigationEnabled()) | 1025 if (IsBrowserSideNavigationEnabled()) |
| 1027 pending_commit_ = false; | 1026 pending_commit_ = false; |
| 1028 } | 1027 } |
| 1029 | 1028 |
| 1030 void RenderFrameHostImpl::OnDidDropNavigation() { | |
| 1031 // At the end of Navigate(), the FrameTreeNode's DidStartLoading is called to | |
| 1032 // force the spinner to start, even if the renderer didn't yet begin the load. | |
| 1033 // If it turns out that the renderer dropped the navigation, the spinner needs | |
| 1034 // to be turned off. | |
| 1035 frame_tree_node_->DidStopLoading(); | |
| 1036 navigation_handle_.reset(); | |
| 1037 } | |
| 1038 | |
| 1039 void RenderFrameHostImpl::OnUpdateState(const PageState& state) { | 1029 void RenderFrameHostImpl::OnUpdateState(const PageState& state) { |
| 1040 // TODO(creis): Verify the state's ISN matches the last committed FNE. | 1030 // TODO(creis): Verify the state's ISN matches the last committed FNE. |
| 1041 | 1031 |
| 1042 // Without this check, the renderer can trick the browser into using | 1032 // Without this check, the renderer can trick the browser into using |
| 1043 // filenames it can't access in a future session restore. | 1033 // filenames it can't access in a future session restore. |
| 1044 // TODO(creis): Move CanAccessFilesOfPageState to RenderFrameHostImpl. | 1034 // TODO(creis): Move CanAccessFilesOfPageState to RenderFrameHostImpl. |
| 1045 if (!render_view_host_->CanAccessFilesOfPageState(state)) { | 1035 if (!render_view_host_->CanAccessFilesOfPageState(state)) { |
| 1046 bad_message::ReceivedBadMessage( | 1036 bad_message::ReceivedBadMessage( |
| 1047 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); | 1037 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); |
| 1048 return; | 1038 return; |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); | 1662 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); |
| 1673 else | 1663 else |
| 1674 delegate_->ExitFullscreenMode(); | 1664 delegate_->ExitFullscreenMode(); |
| 1675 | 1665 |
| 1676 // The previous call might change the fullscreen state. We need to make sure | 1666 // The previous call might change the fullscreen state. We need to make sure |
| 1677 // the renderer is aware of that, which is done via the resize message. | 1667 // the renderer is aware of that, which is done via the resize message. |
| 1678 render_view_host_->GetWidget()->WasResized(); | 1668 render_view_host_->GetWidget()->WasResized(); |
| 1679 } | 1669 } |
| 1680 | 1670 |
| 1681 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { | 1671 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { |
| 1682 // Any main frame load to a new document should reset the load since it will | |
| 1683 // replace the current page and any frames. | |
| 1684 if (to_different_document && !GetParent()) | |
| 1685 is_loading_ = false; | |
| 1686 | |
| 1687 // This method should never be called when the frame is loading. | |
| 1688 // Unfortunately, it can happen if a history navigation happens during a | |
| 1689 // BeforeUnload or Unload event. | |
| 1690 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | |
| 1691 // refactored in Blink. See crbug.com/466089 | |
| 1692 if (is_loading_) { | |
| 1693 LOG(WARNING) << "OnDidStartLoading was called twice."; | |
| 1694 return; | |
| 1695 } | |
| 1696 | |
| 1697 frame_tree_node_->DidStartLoading(to_different_document); | 1672 frame_tree_node_->DidStartLoading(to_different_document); |
| 1698 is_loading_ = true; | 1673 is_loading_ = true; |
| 1699 } | 1674 } |
| 1700 | 1675 |
| 1701 void RenderFrameHostImpl::OnDidStopLoading() { | 1676 void RenderFrameHostImpl::OnDidStopLoading() { |
| 1702 // This method should never be called when the frame is not loading. | 1677 // This method should never be called when the frame is not loading. |
| 1703 // Unfortunately, it can happen if a history navigation happens during a | 1678 // Unfortunately, it can happen if a history navigation happens during a |
| 1704 // BeforeUnload or Unload event. | 1679 // BeforeUnload or Unload event. |
| 1705 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | 1680 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been |
| 1706 // refactored in Blink. See crbug.com/466089 | 1681 // refactored in Blink. See crbug.com/466089 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 // message will be received asynchronously from the UI of the browser. But the | 1858 // message will be received asynchronously from the UI of the browser. But the |
| 1884 // throbber needs to be kept in sync with what's happening in the UI. For | 1859 // throbber needs to be kept in sync with what's happening in the UI. For |
| 1885 // example, the throbber will start immediately when the user navigates even | 1860 // example, the throbber will start immediately when the user navigates even |
| 1886 // if the renderer is delayed. There is also an issue with the throbber | 1861 // if the renderer is delayed. There is also an issue with the throbber |
| 1887 // starting because the WebUI (which controls whether the favicon is | 1862 // starting because the WebUI (which controls whether the favicon is |
| 1888 // displayed) happens synchronously. If the start loading messages was | 1863 // displayed) happens synchronously. If the start loading messages was |
| 1889 // asynchronous, then the default favicon would flash in. | 1864 // asynchronous, then the default favicon would flash in. |
| 1890 // | 1865 // |
| 1891 // Blink doesn't send throb notifications for JavaScript URLs, so it is not | 1866 // Blink doesn't send throb notifications for JavaScript URLs, so it is not |
| 1892 // done here either. | 1867 // done here either. |
| 1893 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) | 1868 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) { |
| 1894 frame_tree_node_->DidStartLoading(true); | 1869 frame_tree_node_->DidStartLoading(true); |
| 1870 is_loading_ = true; |
| 1871 } |
| 1895 } | 1872 } |
| 1896 | 1873 |
| 1897 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 1874 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
| 1898 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 1875 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
| 1899 CommonNavigationParams common_params( | 1876 CommonNavigationParams common_params( |
| 1900 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 1877 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
| 1901 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), | 1878 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), |
| 1902 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, | 1879 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, |
| 1903 base::TimeTicks::Now()); | 1880 base::TimeTicks::Now()); |
| 1904 if (IsBrowserSideNavigationEnabled()) { | 1881 if (IsBrowserSideNavigationEnabled()) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 | 2202 |
| 2226 const image_downloader::ImageDownloaderPtr& | 2203 const image_downloader::ImageDownloaderPtr& |
| 2227 RenderFrameHostImpl::GetMojoImageDownloader() { | 2204 RenderFrameHostImpl::GetMojoImageDownloader() { |
| 2228 if (!mojo_image_downloader_.get() && GetServiceRegistry()) { | 2205 if (!mojo_image_downloader_.get() && GetServiceRegistry()) { |
| 2229 GetServiceRegistry()->ConnectToRemoteService( | 2206 GetServiceRegistry()->ConnectToRemoteService( |
| 2230 mojo::GetProxy(&mojo_image_downloader_)); | 2207 mojo::GetProxy(&mojo_image_downloader_)); |
| 2231 } | 2208 } |
| 2232 return mojo_image_downloader_; | 2209 return mojo_image_downloader_; |
| 2233 } | 2210 } |
| 2234 | 2211 |
| 2212 void RenderFrameHostImpl::ResetLoadingState() { |
| 2213 if (is_loading()) |
| 2214 OnDidStopLoading(); |
| 2215 } |
| 2216 |
| 2235 bool RenderFrameHostImpl::IsSameSiteInstance( | 2217 bool RenderFrameHostImpl::IsSameSiteInstance( |
| 2236 RenderFrameHostImpl* other_render_frame_host) { | 2218 RenderFrameHostImpl* other_render_frame_host) { |
| 2237 // As a sanity check, make sure the frame belongs to the same BrowserContext. | 2219 // As a sanity check, make sure the frame belongs to the same BrowserContext. |
| 2238 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), | 2220 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), |
| 2239 other_render_frame_host->GetSiteInstance()->GetBrowserContext()); | 2221 other_render_frame_host->GetSiteInstance()->GetBrowserContext()); |
| 2240 return GetSiteInstance() == other_render_frame_host->GetSiteInstance(); | 2222 return GetSiteInstance() == other_render_frame_host->GetSiteInstance(); |
| 2241 } | 2223 } |
| 2242 | 2224 |
| 2243 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 2225 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| 2244 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 2226 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2528 *dst = src; | 2510 *dst = src; |
| 2529 | 2511 |
| 2530 if (src.routing_id != -1) | 2512 if (src.routing_id != -1) |
| 2531 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); | 2513 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); |
| 2532 | 2514 |
| 2533 if (src.parent_routing_id != -1) | 2515 if (src.parent_routing_id != -1) |
| 2534 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); | 2516 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); |
| 2535 } | 2517 } |
| 2536 | 2518 |
| 2537 } // namespace content | 2519 } // namespace content |
| OLD | NEW |