| 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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); | 1665 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); |
| 1676 else | 1666 else |
| 1677 delegate_->ExitFullscreenMode(); | 1667 delegate_->ExitFullscreenMode(); |
| 1678 | 1668 |
| 1679 // The previous call might change the fullscreen state. We need to make sure | 1669 // The previous call might change the fullscreen state. We need to make sure |
| 1680 // the renderer is aware of that, which is done via the resize message. | 1670 // the renderer is aware of that, which is done via the resize message. |
| 1681 render_view_host_->GetWidget()->WasResized(); | 1671 render_view_host_->GetWidget()->WasResized(); |
| 1682 } | 1672 } |
| 1683 | 1673 |
| 1684 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { | 1674 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { |
| 1685 // Any main frame load to a new document should reset the load since it will | |
| 1686 // replace the current page and any frames. | |
| 1687 if (to_different_document && !GetParent()) | |
| 1688 is_loading_ = false; | |
| 1689 | |
| 1690 // This method should never be called when the frame is loading. | |
| 1691 // Unfortunately, it can happen if a history navigation happens during a | |
| 1692 // BeforeUnload or Unload event. | |
| 1693 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | |
| 1694 // refactored in Blink. See crbug.com/466089 | |
| 1695 if (is_loading_) { | |
| 1696 LOG(WARNING) << "OnDidStartLoading was called twice."; | |
| 1697 return; | |
| 1698 } | |
| 1699 | |
| 1700 frame_tree_node_->DidStartLoading(to_different_document); | 1675 frame_tree_node_->DidStartLoading(to_different_document); |
| 1701 is_loading_ = true; | 1676 is_loading_ = true; |
| 1702 } | 1677 } |
| 1703 | 1678 |
| 1704 void RenderFrameHostImpl::OnDidStopLoading() { | 1679 void RenderFrameHostImpl::OnDidStopLoading() { |
| 1705 // This method should never be called when the frame is not loading. | 1680 // This method should never be called when the frame is not loading. |
| 1706 // Unfortunately, it can happen if a history navigation happens during a | 1681 // Unfortunately, it can happen if a history navigation happens during a |
| 1707 // BeforeUnload or Unload event. | 1682 // BeforeUnload or Unload event. |
| 1708 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | 1683 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been |
| 1709 // refactored in Blink. See crbug.com/466089 | 1684 // refactored in Blink. See crbug.com/466089 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 // message will be received asynchronously from the UI of the browser. But the | 1861 // message will be received asynchronously from the UI of the browser. But the |
| 1887 // throbber needs to be kept in sync with what's happening in the UI. For | 1862 // throbber needs to be kept in sync with what's happening in the UI. For |
| 1888 // example, the throbber will start immediately when the user navigates even | 1863 // example, the throbber will start immediately when the user navigates even |
| 1889 // if the renderer is delayed. There is also an issue with the throbber | 1864 // if the renderer is delayed. There is also an issue with the throbber |
| 1890 // starting because the WebUI (which controls whether the favicon is | 1865 // starting because the WebUI (which controls whether the favicon is |
| 1891 // displayed) happens synchronously. If the start loading messages was | 1866 // displayed) happens synchronously. If the start loading messages was |
| 1892 // asynchronous, then the default favicon would flash in. | 1867 // asynchronous, then the default favicon would flash in. |
| 1893 // | 1868 // |
| 1894 // Blink doesn't send throb notifications for JavaScript URLs, so it is not | 1869 // Blink doesn't send throb notifications for JavaScript URLs, so it is not |
| 1895 // done here either. | 1870 // done here either. |
| 1896 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) | 1871 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) { |
| 1897 frame_tree_node_->DidStartLoading(true); | 1872 frame_tree_node_->DidStartLoading(true); |
| 1873 is_loading_ = true; |
| 1874 } |
| 1898 } | 1875 } |
| 1899 | 1876 |
| 1900 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 1877 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
| 1901 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 1878 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
| 1902 CommonNavigationParams common_params( | 1879 CommonNavigationParams common_params( |
| 1903 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 1880 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
| 1904 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), | 1881 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), |
| 1905 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, | 1882 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, |
| 1906 base::TimeTicks::Now()); | 1883 base::TimeTicks::Now()); |
| 1907 if (IsBrowserSideNavigationEnabled()) { | 1884 if (IsBrowserSideNavigationEnabled()) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 | 2205 |
| 2229 const image_downloader::ImageDownloaderPtr& | 2206 const image_downloader::ImageDownloaderPtr& |
| 2230 RenderFrameHostImpl::GetMojoImageDownloader() { | 2207 RenderFrameHostImpl::GetMojoImageDownloader() { |
| 2231 if (!mojo_image_downloader_.get() && GetServiceRegistry()) { | 2208 if (!mojo_image_downloader_.get() && GetServiceRegistry()) { |
| 2232 GetServiceRegistry()->ConnectToRemoteService( | 2209 GetServiceRegistry()->ConnectToRemoteService( |
| 2233 mojo::GetProxy(&mojo_image_downloader_)); | 2210 mojo::GetProxy(&mojo_image_downloader_)); |
| 2234 } | 2211 } |
| 2235 return mojo_image_downloader_; | 2212 return mojo_image_downloader_; |
| 2236 } | 2213 } |
| 2237 | 2214 |
| 2215 void RenderFrameHostImpl::ResetLoadingState() { |
| 2216 if (is_loading()) |
| 2217 OnDidStopLoading(); |
| 2218 } |
| 2219 |
| 2238 bool RenderFrameHostImpl::IsSameSiteInstance( | 2220 bool RenderFrameHostImpl::IsSameSiteInstance( |
| 2239 RenderFrameHostImpl* other_render_frame_host) { | 2221 RenderFrameHostImpl* other_render_frame_host) { |
| 2240 // As a sanity check, make sure the frame belongs to the same BrowserContext. | 2222 // As a sanity check, make sure the frame belongs to the same BrowserContext. |
| 2241 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), | 2223 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), |
| 2242 other_render_frame_host->GetSiteInstance()->GetBrowserContext()); | 2224 other_render_frame_host->GetSiteInstance()->GetBrowserContext()); |
| 2243 return GetSiteInstance() == other_render_frame_host->GetSiteInstance(); | 2225 return GetSiteInstance() == other_render_frame_host->GetSiteInstance(); |
| 2244 } | 2226 } |
| 2245 | 2227 |
| 2246 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 2228 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| 2247 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 2229 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2531 *dst = src; | 2513 *dst = src; |
| 2532 | 2514 |
| 2533 if (src.routing_id != -1) | 2515 if (src.routing_id != -1) |
| 2534 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); | 2516 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); |
| 2535 | 2517 |
| 2536 if (src.parent_routing_id != -1) | 2518 if (src.parent_routing_id != -1) |
| 2537 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); | 2519 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); |
| 2538 } | 2520 } |
| 2539 | 2521 |
| 2540 } // namespace content | 2522 } // namespace content |
| OLD | NEW |