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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 // out-of-process iframes implementation is ready, we should check for | 1532 // out-of-process iframes implementation is ready, we should check for |
1533 // cross-site URLs that are not allowed to commit in this process. | 1533 // cross-site URLs that are not allowed to commit in this process. |
1534 | 1534 |
1535 // Give the client a chance to disallow URLs from committing. | 1535 // Give the client a chance to disallow URLs from committing. |
1536 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); | 1536 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); |
1537 } | 1537 } |
1538 | 1538 |
1539 void RenderFrameHostImpl::Navigate( | 1539 void RenderFrameHostImpl::Navigate( |
1540 const CommonNavigationParams& common_params, | 1540 const CommonNavigationParams& common_params, |
1541 const StartNavigationParams& start_params, | 1541 const StartNavigationParams& start_params, |
1542 const CommitNavigationParams& commit_params, | 1542 const RequestNavigationParams& request_params) { |
1543 const HistoryNavigationParams& history_params) { | |
1544 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); | 1543 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); |
1545 // Browser plugin guests are not allowed to navigate outside web-safe schemes, | 1544 // Browser plugin guests are not allowed to navigate outside web-safe schemes, |
1546 // so do not grant them the ability to request additional URLs. | 1545 // so do not grant them the ability to request additional URLs. |
1547 if (!GetProcess()->IsIsolatedGuest()) { | 1546 if (!GetProcess()->IsIsolatedGuest()) { |
1548 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1547 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
1549 GetProcess()->GetID(), common_params.url); | 1548 GetProcess()->GetID(), common_params.url); |
1550 if (common_params.url.SchemeIs(url::kDataScheme) && | 1549 if (common_params.url.SchemeIs(url::kDataScheme) && |
1551 common_params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { | 1550 common_params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { |
1552 // If 'data:' is used, and we have a 'file:' base url, grant access to | 1551 // If 'data:' is used, and we have a 'file:' base url, grant access to |
1553 // local files. | 1552 // local files. |
1554 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1553 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
1555 GetProcess()->GetID(), common_params.base_url_for_data_url); | 1554 GetProcess()->GetID(), common_params.base_url_for_data_url); |
1556 } | 1555 } |
1557 } | 1556 } |
1558 | 1557 |
1559 // We may be returning to an existing NavigationEntry that had been granted | 1558 // We may be returning to an existing NavigationEntry that had been granted |
1560 // file access. If this is a different process, we will need to grant the | 1559 // file access. If this is a different process, we will need to grant the |
1561 // access again. The files listed in the page state are validated when they | 1560 // access again. The files listed in the page state are validated when they |
1562 // are received from the renderer to prevent abuse. | 1561 // are received from the renderer to prevent abuse. |
1563 if (history_params.page_state.IsValid()) { | 1562 if (request_params.page_state.IsValid()) { |
1564 render_view_host_->GrantFileAccessFromPageState(history_params.page_state); | 1563 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); |
1565 } | 1564 } |
1566 | 1565 |
1567 // Only send the message if we aren't suspended at the start of a cross-site | 1566 // Only send the message if we aren't suspended at the start of a cross-site |
1568 // request. | 1567 // request. |
1569 if (navigations_suspended_) { | 1568 if (navigations_suspended_) { |
1570 // Shouldn't be possible to have a second navigation while suspended, since | 1569 // Shouldn't be possible to have a second navigation while suspended, since |
1571 // navigations will only be suspended during a cross-site request. If a | 1570 // navigations will only be suspended during a cross-site request. If a |
1572 // second navigation occurs, RenderFrameHostManager will cancel this pending | 1571 // second navigation occurs, RenderFrameHostManager will cancel this pending |
1573 // RFH and create a new pending RFH. | 1572 // RFH and create a new pending RFH. |
1574 DCHECK(!suspended_nav_params_.get()); | 1573 DCHECK(!suspended_nav_params_.get()); |
1575 suspended_nav_params_.reset(new NavigationParams( | 1574 suspended_nav_params_.reset( |
1576 common_params, start_params, commit_params, history_params)); | 1575 new NavigationParams(common_params, start_params, request_params)); |
1577 } else { | 1576 } else { |
1578 // Get back to a clean state, in case we start a new navigation without | 1577 // Get back to a clean state, in case we start a new navigation without |
1579 // completing a RFH swap or unload handler. | 1578 // completing a RFH swap or unload handler. |
1580 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 1579 SetState(RenderFrameHostImpl::STATE_DEFAULT); |
1581 | 1580 |
1582 Send(new FrameMsg_Navigate(routing_id_, common_params, start_params, | 1581 Send(new FrameMsg_Navigate(routing_id_, common_params, start_params, |
1583 commit_params, history_params)); | 1582 request_params)); |
1584 } | 1583 } |
1585 | 1584 |
1586 // Force the throbber to start. We do this because Blink's "started | 1585 // Force the throbber to start. We do this because Blink's "started |
1587 // loading" message will be received asynchronously from the UI of the | 1586 // loading" message will be received asynchronously from the UI of the |
1588 // browser. But we want to keep the throbber in sync with what's happening | 1587 // browser. But we want to keep the throbber in sync with what's happening |
1589 // in the UI. For example, we want to start throbbing immediately when the | 1588 // in the UI. For example, we want to start throbbing immediately when the |
1590 // user navigates even if the renderer is delayed. There is also an issue | 1589 // user navigates even if the renderer is delayed. There is also an issue |
1591 // with the throbber starting because the WebUI (which controls whether the | 1590 // with the throbber starting because the WebUI (which controls whether the |
1592 // favicon is displayed) happens synchronously. If the start loading | 1591 // favicon is displayed) happens synchronously. If the start loading |
1593 // messages was asynchronous, then the default favicon would flash in. | 1592 // messages was asynchronous, then the default favicon would flash in. |
1594 // | 1593 // |
1595 // Blink doesn't send throb notifications for JavaScript URLs, so we | 1594 // Blink doesn't send throb notifications for JavaScript URLs, so we |
1596 // don't want to either. | 1595 // don't want to either. |
1597 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) | 1596 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) |
1598 delegate_->DidStartLoading(this, true); | 1597 delegate_->DidStartLoading(this, true); |
1599 } | 1598 } |
1600 | 1599 |
1601 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { | 1600 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { |
1602 CommonNavigationParams common_params( | 1601 CommonNavigationParams common_params( |
1603 url, Referrer(), ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::NORMAL, | 1602 url, Referrer(), ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::NORMAL, |
1604 true, base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, | 1603 true, base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, |
1605 GURL(), GURL()); | 1604 GURL(), GURL()); |
1606 Navigate(common_params, StartNavigationParams(), CommitNavigationParams(), | 1605 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
1607 HistoryNavigationParams()); | |
1608 } | 1606 } |
1609 | 1607 |
1610 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params, | 1608 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params, |
1611 SiteInstance* source_site_instance) { | 1609 SiteInstance* source_site_instance) { |
1612 GURL validated_url(params.url); | 1610 GURL validated_url(params.url); |
1613 GetProcess()->FilterURL(false, &validated_url); | 1611 GetProcess()->FilterURL(false, &validated_url); |
1614 | 1612 |
1615 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OpenURL", "url", | 1613 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OpenURL", "url", |
1616 validated_url.possibly_invalid_spec()); | 1614 validated_url.possibly_invalid_spec()); |
1617 frame_tree_node_->navigator()->RequestOpenURL( | 1615 frame_tree_node_->navigator()->RequestOpenURL( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 // correctly while waiting for a response. | 1707 // correctly while waiting for a response. |
1710 if (is_waiting && dialog_was_suppressed) | 1708 if (is_waiting && dialog_was_suppressed) |
1711 render_view_host_->delegate_->RendererUnresponsive(render_view_host_); | 1709 render_view_host_->delegate_->RendererUnresponsive(render_view_host_); |
1712 } | 1710 } |
1713 | 1711 |
1714 // PlzNavigate | 1712 // PlzNavigate |
1715 void RenderFrameHostImpl::CommitNavigation( | 1713 void RenderFrameHostImpl::CommitNavigation( |
1716 ResourceResponse* response, | 1714 ResourceResponse* response, |
1717 scoped_ptr<StreamHandle> body, | 1715 scoped_ptr<StreamHandle> body, |
1718 const CommonNavigationParams& common_params, | 1716 const CommonNavigationParams& common_params, |
1719 const CommitNavigationParams& commit_params, | 1717 const RequestNavigationParams& request_params) { |
1720 const HistoryNavigationParams& history_params) { | |
1721 DCHECK((response && body.get()) || | 1718 DCHECK((response && body.get()) || |
1722 !NavigationRequest::ShouldMakeNetworkRequest(common_params.url)); | 1719 !NavigationRequest::ShouldMakeNetworkRequest(common_params.url)); |
1723 // TODO(clamy): Check if we have to add security checks for the browser plugin | 1720 // TODO(clamy): Check if we have to add security checks for the browser plugin |
1724 // guests. | 1721 // guests. |
1725 | 1722 |
1726 // Get back to a clean state, in case we start a new navigation without | 1723 // Get back to a clean state, in case we start a new navigation without |
1727 // completing a RFH swap or unload handler. | 1724 // completing a RFH swap or unload handler. |
1728 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 1725 SetState(RenderFrameHostImpl::STATE_DEFAULT); |
1729 | 1726 |
1730 const GURL body_url = body.get() ? body->GetURL() : GURL(); | 1727 const GURL body_url = body.get() ? body->GetURL() : GURL(); |
1731 const ResourceResponseHead head = response ? | 1728 const ResourceResponseHead head = response ? |
1732 response->head : ResourceResponseHead(); | 1729 response->head : ResourceResponseHead(); |
1733 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, | 1730 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, |
1734 commit_params, history_params)); | 1731 request_params)); |
1735 // TODO(clamy): Check if we should start the throbber for non javascript urls | 1732 // TODO(clamy): Check if we should start the throbber for non javascript urls |
1736 // here. | 1733 // here. |
1737 | 1734 |
1738 // TODO(clamy): Release the stream handle once the renderer has finished | 1735 // TODO(clamy): Release the stream handle once the renderer has finished |
1739 // reading it. | 1736 // reading it. |
1740 stream_handle_ = body.Pass(); | 1737 stream_handle_ = body.Pass(); |
1741 } | 1738 } |
1742 | 1739 |
1743 void RenderFrameHostImpl::SetUpMojoIfNeeded() { | 1740 void RenderFrameHostImpl::SetUpMojoIfNeeded() { |
1744 if (service_registry_.get()) | 1741 if (service_registry_.get()) |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 "RenderFrameHostImpl navigation suspended", this); | 1936 "RenderFrameHostImpl navigation suspended", this); |
1940 } | 1937 } |
1941 | 1938 |
1942 if (!suspend && suspended_nav_params_) { | 1939 if (!suspend && suspended_nav_params_) { |
1943 // There's navigation message params waiting to be sent. Now that we're not | 1940 // There's navigation message params waiting to be sent. Now that we're not |
1944 // suspended anymore, resume navigation by sending them. If we were swapped | 1941 // suspended anymore, resume navigation by sending them. If we were swapped |
1945 // out, we should also stop filtering out the IPC messages now. | 1942 // out, we should also stop filtering out the IPC messages now. |
1946 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 1943 SetState(RenderFrameHostImpl::STATE_DEFAULT); |
1947 | 1944 |
1948 DCHECK(!proceed_time.is_null()); | 1945 DCHECK(!proceed_time.is_null()); |
1949 suspended_nav_params_->commit_params.browser_navigation_start = | 1946 suspended_nav_params_->request_params.browser_navigation_start = |
1950 proceed_time; | 1947 proceed_time; |
1951 Send(new FrameMsg_Navigate(routing_id_, | 1948 Send(new FrameMsg_Navigate(routing_id_, |
1952 suspended_nav_params_->common_params, | 1949 suspended_nav_params_->common_params, |
1953 suspended_nav_params_->start_params, | 1950 suspended_nav_params_->start_params, |
1954 suspended_nav_params_->commit_params, | 1951 suspended_nav_params_->request_params)); |
1955 suspended_nav_params_->history_params)); | |
1956 suspended_nav_params_.reset(); | 1952 suspended_nav_params_.reset(); |
1957 } | 1953 } |
1958 } | 1954 } |
1959 | 1955 |
1960 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1956 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
1961 // Clear any state if a pending navigation is canceled or preempted. | 1957 // Clear any state if a pending navigation is canceled or preempted. |
1962 if (suspended_nav_params_) | 1958 if (suspended_nav_params_) |
1963 suspended_nav_params_.reset(); | 1959 suspended_nav_params_.reset(); |
1964 | 1960 |
1965 TRACE_EVENT_ASYNC_END0("navigation", | 1961 TRACE_EVENT_ASYNC_END0("navigation", |
1966 "RenderFrameHostImpl navigation suspended", this); | 1962 "RenderFrameHostImpl navigation suspended", this); |
1967 navigations_suspended_ = false; | 1963 navigations_suspended_ = false; |
1968 } | 1964 } |
1969 | 1965 |
1970 void RenderFrameHostImpl::DidUseGeolocationPermission() { | 1966 void RenderFrameHostImpl::DidUseGeolocationPermission() { |
1971 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); | 1967 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); |
1972 GetContentClient()->browser()->RegisterPermissionUsage( | 1968 GetContentClient()->browser()->RegisterPermissionUsage( |
1973 PERMISSION_GEOLOCATION, | 1969 PERMISSION_GEOLOCATION, |
1974 delegate_->GetAsWebContents(), | 1970 delegate_->GetAsWebContents(), |
1975 GetLastCommittedURL().GetOrigin(), | 1971 GetLastCommittedURL().GetOrigin(), |
1976 top_frame->GetLastCommittedURL().GetOrigin()); | 1972 top_frame->GetLastCommittedURL().GetOrigin()); |
1977 } | 1973 } |
1978 | 1974 |
1979 } // namespace content | 1975 } // namespace content |
OLD | NEW |