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

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

Powered by Google App Engine
This is Rietveld 408576698