Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698