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

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

Issue 971653004: Remove the FrameMsg_Navigate_Params (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@history-params
Patch Set: 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 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 1517
1518 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { 1518 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) {
1519 // TODO(creis): We should also check for WebUI pages here. Also, when the 1519 // TODO(creis): We should also check for WebUI pages here. Also, when the
1520 // out-of-process iframes implementation is ready, we should check for 1520 // out-of-process iframes implementation is ready, we should check for
1521 // cross-site URLs that are not allowed to commit in this process. 1521 // cross-site URLs that are not allowed to commit in this process.
1522 1522
1523 // Give the client a chance to disallow URLs from committing. 1523 // Give the client a chance to disallow URLs from committing.
1524 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); 1524 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url);
1525 } 1525 }
1526 1526
1527 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { 1527 void RenderFrameHostImpl::Navigate(
1528 const CommonNavigationParams& common_params,
1529 const StartNavigationParams& start_params,
1530 const CommitNavigationParams& commit_params,
1531 const HistoryNavigationParams& history_params) {
1528 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); 1532 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate");
1529 // Browser plugin guests are not allowed to navigate outside web-safe schemes, 1533 // Browser plugin guests are not allowed to navigate outside web-safe schemes,
1530 // so do not grant them the ability to request additional URLs. 1534 // so do not grant them the ability to request additional URLs.
1531 if (!GetProcess()->IsIsolatedGuest()) { 1535 if (!GetProcess()->IsIsolatedGuest()) {
1532 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( 1536 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
1533 GetProcess()->GetID(), params.common_params.url); 1537 GetProcess()->GetID(), common_params.url);
1534 if (params.common_params.url.SchemeIs(url::kDataScheme) && 1538 if (common_params.url.SchemeIs(url::kDataScheme) &&
1535 params.common_params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { 1539 common_params.base_url_for_data_url.SchemeIs(url::kFileScheme)) {
1536 // If 'data:' is used, and we have a 'file:' base url, grant access to 1540 // If 'data:' is used, and we have a 'file:' base url, grant access to
1537 // local files. 1541 // local files.
1538 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( 1542 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
1539 GetProcess()->GetID(), params.common_params.base_url_for_data_url); 1543 GetProcess()->GetID(), common_params.base_url_for_data_url);
1540 } 1544 }
1541 } 1545 }
1542 1546
1543 // We may be returning to an existing NavigationEntry that had been granted 1547 // We may be returning to an existing NavigationEntry that had been granted
1544 // file access. If this is a different process, we will need to grant the 1548 // file access. If this is a different process, we will need to grant the
1545 // access again. The files listed in the page state are validated when they 1549 // access again. The files listed in the page state are validated when they
1546 // are received from the renderer to prevent abuse. 1550 // are received from the renderer to prevent abuse.
1547 if (params.history_params.page_state.IsValid()) { 1551 if (history_params.page_state.IsValid()) {
1548 render_view_host_->GrantFileAccessFromPageState( 1552 render_view_host_->GrantFileAccessFromPageState(history_params.page_state);
1549 params.history_params.page_state);
1550 } 1553 }
1551 1554
1552 // Only send the message if we aren't suspended at the start of a cross-site 1555 // Only send the message if we aren't suspended at the start of a cross-site
1553 // request. 1556 // request.
1554 if (navigations_suspended_) { 1557 if (navigations_suspended_) {
1555 // Shouldn't be possible to have a second navigation while suspended, since 1558 // Shouldn't be possible to have a second navigation while suspended, since
1556 // navigations will only be suspended during a cross-site request. If a 1559 // navigations will only be suspended during a cross-site request. If a
1557 // second navigation occurs, RenderFrameHostManager will cancel this pending 1560 // second navigation occurs, RenderFrameHostManager will cancel this pending
1558 // RFH and create a new pending RFH. 1561 // RFH and create a new pending RFH.
1559 DCHECK(!suspended_nav_params_.get()); 1562 DCHECK(!suspended_nav_params_.get());
1560 suspended_nav_params_.reset(new FrameMsg_Navigate_Params(params)); 1563 suspended_nav_params_.reset(new NavigateParams(
1564 common_params, start_params, commit_params, history_params));
1561 } else { 1565 } else {
1562 // Get back to a clean state, in case we start a new navigation without 1566 // Get back to a clean state, in case we start a new navigation without
1563 // completing a RFH swap or unload handler. 1567 // completing a RFH swap or unload handler.
1564 SetState(RenderFrameHostImpl::STATE_DEFAULT); 1568 SetState(RenderFrameHostImpl::STATE_DEFAULT);
1565 1569
1566 Send(new FrameMsg_Navigate(routing_id_, params)); 1570 Send(new FrameMsg_Navigate(routing_id_, common_params, start_params,
1571 commit_params, history_params));
1567 } 1572 }
1568 1573
1569 // Force the throbber to start. We do this because Blink's "started 1574 // Force the throbber to start. We do this because Blink's "started
1570 // loading" message will be received asynchronously from the UI of the 1575 // loading" message will be received asynchronously from the UI of the
1571 // browser. But we want to keep the throbber in sync with what's happening 1576 // browser. But we want to keep the throbber in sync with what's happening
1572 // in the UI. For example, we want to start throbbing immediately when the 1577 // in the UI. For example, we want to start throbbing immediately when the
1573 // user navigates even if the renderer is delayed. There is also an issue 1578 // user navigates even if the renderer is delayed. There is also an issue
1574 // with the throbber starting because the WebUI (which controls whether the 1579 // with the throbber starting because the WebUI (which controls whether the
1575 // favicon is displayed) happens synchronously. If the start loading 1580 // favicon is displayed) happens synchronously. If the start loading
1576 // messages was asynchronous, then the default favicon would flash in. 1581 // messages was asynchronous, then the default favicon would flash in.
1577 // 1582 //
1578 // Blink doesn't send throb notifications for JavaScript URLs, so we 1583 // Blink doesn't send throb notifications for JavaScript URLs, so we
1579 // don't want to either. 1584 // don't want to either.
1580 if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme)) 1585 if (!common_params.url.SchemeIs(url::kJavaScriptScheme))
1581 delegate_->DidStartLoading(this, true); 1586 delegate_->DidStartLoading(this, true);
1582 } 1587 }
1583 1588
1584 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { 1589 void RenderFrameHostImpl::NavigateToURL(const GURL& url) {
1585 FrameMsg_Navigate_Params params; 1590 CommonNavigationParams common_params(
1586 params.common_params.url = url; 1591 url, Referrer(), ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::NORMAL,
1587 params.common_params.transition = ui::PAGE_TRANSITION_LINK; 1592 true, base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT,
1588 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1593 GURL(), GURL());
1589 params.commit_params.browser_navigation_start = base::TimeTicks::Now(); 1594 CommitNavigationParams commit_params;
1590 params.history_params.page_id = -1; 1595 commit_params.browser_navigation_start = base::TimeTicks::Now();
1591 params.history_params.pending_history_list_offset = -1; 1596 commit_params.request_time = base::Time::Now();
1592 params.history_params.current_history_list_offset = -1; 1597 Navigate(common_params, StartNavigationParams(), commit_params,
1593 params.history_params.current_history_list_length = 0; 1598 HistoryNavigationParams());
1594 Navigate(params);
1595 } 1599 }
1596 1600
1597 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params, 1601 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params,
1598 SiteInstance* source_site_instance) { 1602 SiteInstance* source_site_instance) {
1599 GURL validated_url(params.url); 1603 GURL validated_url(params.url);
1600 GetProcess()->FilterURL(false, &validated_url); 1604 GetProcess()->FilterURL(false, &validated_url);
1601 1605
1602 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OpenURL", "url", 1606 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OpenURL", "url",
1603 validated_url.possibly_invalid_spec()); 1607 validated_url.possibly_invalid_spec());
1604 frame_tree_node_->navigator()->RequestOpenURL( 1608 frame_tree_node_->navigator()->RequestOpenURL(
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 1931
1928 if (!suspend && suspended_nav_params_) { 1932 if (!suspend && suspended_nav_params_) {
1929 // There's navigation message params waiting to be sent. Now that we're not 1933 // There's navigation message params waiting to be sent. Now that we're not
1930 // suspended anymore, resume navigation by sending them. If we were swapped 1934 // suspended anymore, resume navigation by sending them. If we were swapped
1931 // out, we should also stop filtering out the IPC messages now. 1935 // out, we should also stop filtering out the IPC messages now.
1932 SetState(RenderFrameHostImpl::STATE_DEFAULT); 1936 SetState(RenderFrameHostImpl::STATE_DEFAULT);
1933 1937
1934 DCHECK(!proceed_time.is_null()); 1938 DCHECK(!proceed_time.is_null());
1935 suspended_nav_params_->commit_params.browser_navigation_start = 1939 suspended_nav_params_->commit_params.browser_navigation_start =
1936 proceed_time; 1940 proceed_time;
1937 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); 1941 Send(new FrameMsg_Navigate(routing_id_,
1942 suspended_nav_params_->common_params,
1943 suspended_nav_params_->start_params,
1944 suspended_nav_params_->commit_params,
1945 suspended_nav_params_->history_params));
1938 suspended_nav_params_.reset(); 1946 suspended_nav_params_.reset();
1939 } 1947 }
1940 } 1948 }
1941 1949
1942 void RenderFrameHostImpl::CancelSuspendedNavigations() { 1950 void RenderFrameHostImpl::CancelSuspendedNavigations() {
1943 // Clear any state if a pending navigation is canceled or preempted. 1951 // Clear any state if a pending navigation is canceled or preempted.
1944 if (suspended_nav_params_) 1952 if (suspended_nav_params_)
1945 suspended_nav_params_.reset(); 1953 suspended_nav_params_.reset();
1946 1954
1947 TRACE_EVENT_ASYNC_END0("navigation", 1955 TRACE_EVENT_ASYNC_END0("navigation",
1948 "RenderFrameHostImpl navigation suspended", this); 1956 "RenderFrameHostImpl navigation suspended", this);
1949 navigations_suspended_ = false; 1957 navigations_suspended_ = false;
1950 } 1958 }
1951 1959
1952 void RenderFrameHostImpl::DidUseGeolocationPermission() { 1960 void RenderFrameHostImpl::DidUseGeolocationPermission() {
1953 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); 1961 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame();
1954 GetContentClient()->browser()->RegisterPermissionUsage( 1962 GetContentClient()->browser()->RegisterPermissionUsage(
1955 PERMISSION_GEOLOCATION, 1963 PERMISSION_GEOLOCATION,
1956 delegate_->GetAsWebContents(), 1964 delegate_->GetAsWebContents(),
1957 GetLastCommittedURL().GetOrigin(), 1965 GetLastCommittedURL().GetOrigin(),
1958 top_frame->GetLastCommittedURL().GetOrigin()); 1966 top_frame->GetLastCommittedURL().GetOrigin());
1959 } 1967 }
1960 1968
1969 RenderFrameHostImpl::NavigateParams::NavigateParams(
1970 const CommonNavigationParams& common_params,
1971 const StartNavigationParams& start_params,
1972 const CommitNavigationParams& commit_params,
1973 const HistoryNavigationParams& history_params)
1974 : common_params(common_params),
1975 start_params(start_params),
1976 commit_params(commit_params),
1977 history_params(history_params) {
1978 }
1979
1980 RenderFrameHostImpl::NavigateParams::~NavigateParams() {
1981 }
1961 } // namespace content 1982 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698