| 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 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 | 1594 |
| 1595 // Give the client a chance to disallow URLs from committing. | 1595 // Give the client a chance to disallow URLs from committing. |
| 1596 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); | 1596 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); |
| 1597 } | 1597 } |
| 1598 | 1598 |
| 1599 void RenderFrameHostImpl::Navigate( | 1599 void RenderFrameHostImpl::Navigate( |
| 1600 const CommonNavigationParams& common_params, | 1600 const CommonNavigationParams& common_params, |
| 1601 const StartNavigationParams& start_params, | 1601 const StartNavigationParams& start_params, |
| 1602 const RequestNavigationParams& request_params) { | 1602 const RequestNavigationParams& request_params) { |
| 1603 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); | 1603 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); |
| 1604 // Browser plugin guests are not allowed to navigate outside web-safe schemes, | |
| 1605 // so do not grant them the ability to request additional URLs. | |
| 1606 if (!GetProcess()->IsIsolatedGuest()) { | |
| 1607 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | |
| 1608 GetProcess()->GetID(), common_params.url); | |
| 1609 if (common_params.url.SchemeIs(url::kDataScheme) && | |
| 1610 common_params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { | |
| 1611 // If 'data:' is used, and we have a 'file:' base url, grant access to | |
| 1612 // local files. | |
| 1613 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | |
| 1614 GetProcess()->GetID(), common_params.base_url_for_data_url); | |
| 1615 } | |
| 1616 } | |
| 1617 | 1604 |
| 1618 // We may be returning to an existing NavigationEntry that had been granted | 1605 UpdatePermissionsForNavigation(common_params, request_params); |
| 1619 // file access. If this is a different process, we will need to grant the | |
| 1620 // access again. The files listed in the page state are validated when they | |
| 1621 // are received from the renderer to prevent abuse. | |
| 1622 if (request_params.page_state.IsValid()) { | |
| 1623 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); | |
| 1624 } | |
| 1625 | 1606 |
| 1626 // Only send the message if we aren't suspended at the start of a cross-site | 1607 // Only send the message if we aren't suspended at the start of a cross-site |
| 1627 // request. | 1608 // request. |
| 1628 if (navigations_suspended_) { | 1609 if (navigations_suspended_) { |
| 1629 // Shouldn't be possible to have a second navigation while suspended, since | 1610 // Shouldn't be possible to have a second navigation while suspended, since |
| 1630 // navigations will only be suspended during a cross-site request. If a | 1611 // navigations will only be suspended during a cross-site request. If a |
| 1631 // second navigation occurs, RenderFrameHostManager will cancel this pending | 1612 // second navigation occurs, RenderFrameHostManager will cancel this pending |
| 1632 // RFH and create a new pending RFH. | 1613 // RFH and create a new pending RFH. |
| 1633 DCHECK(!suspended_nav_params_.get()); | 1614 DCHECK(!suspended_nav_params_.get()); |
| 1634 suspended_nav_params_.reset( | 1615 suspended_nav_params_.reset( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 } | 1757 } |
| 1777 | 1758 |
| 1778 // PlzNavigate | 1759 // PlzNavigate |
| 1779 void RenderFrameHostImpl::CommitNavigation( | 1760 void RenderFrameHostImpl::CommitNavigation( |
| 1780 ResourceResponse* response, | 1761 ResourceResponse* response, |
| 1781 scoped_ptr<StreamHandle> body, | 1762 scoped_ptr<StreamHandle> body, |
| 1782 const CommonNavigationParams& common_params, | 1763 const CommonNavigationParams& common_params, |
| 1783 const RequestNavigationParams& request_params) { | 1764 const RequestNavigationParams& request_params) { |
| 1784 DCHECK((response && body.get()) || | 1765 DCHECK((response && body.get()) || |
| 1785 !NavigationRequest::ShouldMakeNetworkRequest(common_params.url)); | 1766 !NavigationRequest::ShouldMakeNetworkRequest(common_params.url)); |
| 1786 // TODO(clamy): Check if we have to add security checks for the browser plugin | 1767 UpdatePermissionsForNavigation(common_params, request_params); |
| 1787 // guests. | |
| 1788 | 1768 |
| 1789 // Get back to a clean state, in case we start a new navigation without | 1769 // Get back to a clean state, in case we start a new navigation without |
| 1790 // completing a RFH swap or unload handler. | 1770 // completing a RFH swap or unload handler. |
| 1791 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 1771 SetState(RenderFrameHostImpl::STATE_DEFAULT); |
| 1792 | 1772 |
| 1793 const GURL body_url = body.get() ? body->GetURL() : GURL(); | 1773 const GURL body_url = body.get() ? body->GetURL() : GURL(); |
| 1794 const ResourceResponseHead head = response ? | 1774 const ResourceResponseHead head = response ? |
| 1795 response->head : ResourceResponseHead(); | 1775 response->head : ResourceResponseHead(); |
| 1796 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, | 1776 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, |
| 1797 request_params)); | 1777 request_params)); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2065 if (!permission_manager) | 2045 if (!permission_manager) |
| 2066 return; | 2046 return; |
| 2067 | 2047 |
| 2068 permission_manager->RegisterPermissionUsage( | 2048 permission_manager->RegisterPermissionUsage( |
| 2069 PermissionType::GEOLOCATION, | 2049 PermissionType::GEOLOCATION, |
| 2070 GetLastCommittedURL().GetOrigin(), | 2050 GetLastCommittedURL().GetOrigin(), |
| 2071 frame_tree_node()->frame_tree()->GetMainFrame() | 2051 frame_tree_node()->frame_tree()->GetMainFrame() |
| 2072 ->GetLastCommittedURL().GetOrigin()); | 2052 ->GetLastCommittedURL().GetOrigin()); |
| 2073 } | 2053 } |
| 2074 | 2054 |
| 2055 void RenderFrameHostImpl::UpdatePermissionsForNavigation( |
| 2056 const CommonNavigationParams& common_params, |
| 2057 const RequestNavigationParams& request_params) { |
| 2058 // Browser plugin guests are not allowed to navigate outside web-safe schemes, |
| 2059 // so do not grant them the ability to request additional URLs. |
| 2060 if (!GetProcess()->IsIsolatedGuest()) { |
| 2061 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
| 2062 GetProcess()->GetID(), common_params.url); |
| 2063 if (common_params.url.SchemeIs(url::kDataScheme) && |
| 2064 common_params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { |
| 2065 // If 'data:' is used, and we have a 'file:' base url, grant access to |
| 2066 // local files. |
| 2067 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
| 2068 GetProcess()->GetID(), common_params.base_url_for_data_url); |
| 2069 } |
| 2070 } |
| 2071 |
| 2072 // We may be returning to an existing NavigationEntry that had been granted |
| 2073 // file access. If this is a different process, we will need to grant the |
| 2074 // access again. The files listed in the page state are validated when they |
| 2075 // are received from the renderer to prevent abuse. |
| 2076 if (request_params.page_state.IsValid()) { |
| 2077 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); |
| 2078 } |
| 2079 } |
| 2080 |
| 2075 } // namespace content | 2081 } // namespace content |
| OLD | NEW |