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

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

Issue 483773002: PlzNavigate: implement CommitNavigation on the browser side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compilation error Created 6 years, 2 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 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 title_direction)); 1014 title_direction));
1015 } 1015 }
1016 1016
1017 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { 1017 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) {
1018 // This message is only sent for top-level frames. TODO(avi): when frame tree 1018 // This message is only sent for top-level frames. TODO(avi): when frame tree
1019 // mirroring works correctly, add a check here to enforce it. 1019 // mirroring works correctly, add a check here to enforce it.
1020 delegate_->UpdateEncoding(this, encoding_name); 1020 delegate_->UpdateEncoding(this, encoding_name);
1021 } 1021 }
1022 1022
1023 void RenderFrameHostImpl::OnBeginNavigation( 1023 void RenderFrameHostImpl::OnBeginNavigation(
1024 const FrameHostMsg_BeginNavigation_Params& params) { 1024 const FrameHostMsg_BeginNavigation_Params& params,
1025 const CommonNavigationParams& common_params) {
1025 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( 1026 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
1026 switches::kEnableBrowserSideNavigation)); 1027 switches::kEnableBrowserSideNavigation));
1027 frame_tree_node()->render_manager()->OnBeginNavigation(params); 1028 frame_tree_node()->render_manager()->OnBeginNavigation(params, common_params);
1028 } 1029 }
1029 1030
1030 void RenderFrameHostImpl::OnAccessibilityEvents( 1031 void RenderFrameHostImpl::OnAccessibilityEvents(
1031 const std::vector<AccessibilityHostMsg_EventParams>& params) { 1032 const std::vector<AccessibilityHostMsg_EventParams>& params) {
1032 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 1033 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
1033 render_view_host_->GetView()); 1034 render_view_host_->GetView());
1034 1035
1035 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); 1036 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
1036 if ((accessibility_mode != AccessibilityModeOff) && view && 1037 if ((accessibility_mode != AccessibilityModeOff) && view &&
1037 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { 1038 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 // Give the client a chance to disallow URLs from committing. 1158 // Give the client a chance to disallow URLs from committing.
1158 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); 1159 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url);
1159 } 1160 }
1160 1161
1161 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { 1162 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) {
1162 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); 1163 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate");
1163 // Browser plugin guests are not allowed to navigate outside web-safe schemes, 1164 // Browser plugin guests are not allowed to navigate outside web-safe schemes,
1164 // so do not grant them the ability to request additional URLs. 1165 // so do not grant them the ability to request additional URLs.
1165 if (!GetProcess()->IsIsolatedGuest()) { 1166 if (!GetProcess()->IsIsolatedGuest()) {
1166 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( 1167 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
1167 GetProcess()->GetID(), params.url); 1168 GetProcess()->GetID(), params.common_params.url);
1168 if (params.url.SchemeIs(url::kDataScheme) && 1169 if (params.common_params.url.SchemeIs(url::kDataScheme) &&
1169 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { 1170 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) {
1170 // If 'data:' is used, and we have a 'file:' base url, grant access to 1171 // If 'data:' is used, and we have a 'file:' base url, grant access to
1171 // local files. 1172 // local files.
1172 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( 1173 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
1173 GetProcess()->GetID(), params.base_url_for_data_url); 1174 GetProcess()->GetID(), params.base_url_for_data_url);
1174 } 1175 }
1175 } 1176 }
1176 1177
1177 // Only send the message if we aren't suspended at the start of a cross-site 1178 // Only send the message if we aren't suspended at the start of a cross-site
1178 // request. 1179 // request.
(...skipping 16 matching lines...) Expand all
1195 // loading" message will be received asynchronously from the UI of the 1196 // loading" message will be received asynchronously from the UI of the
1196 // browser. But we want to keep the throbber in sync with what's happening 1197 // browser. But we want to keep the throbber in sync with what's happening
1197 // in the UI. For example, we want to start throbbing immediately when the 1198 // in the UI. For example, we want to start throbbing immediately when the
1198 // user naivgates even if the renderer is delayed. There is also an issue 1199 // user naivgates even if the renderer is delayed. There is also an issue
1199 // with the throbber starting because the WebUI (which controls whether the 1200 // with the throbber starting because the WebUI (which controls whether the
1200 // favicon is displayed) happens synchronously. If the start loading 1201 // favicon is displayed) happens synchronously. If the start loading
1201 // messages was asynchronous, then the default favicon would flash in. 1202 // messages was asynchronous, then the default favicon would flash in.
1202 // 1203 //
1203 // Blink doesn't send throb notifications for JavaScript URLs, so we 1204 // Blink doesn't send throb notifications for JavaScript URLs, so we
1204 // don't want to either. 1205 // don't want to either.
1205 if (!params.url.SchemeIs(url::kJavaScriptScheme)) 1206 if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme))
1206 delegate_->DidStartLoading(this, true); 1207 delegate_->DidStartLoading(this, true);
1207 } 1208 }
1208 1209
1209 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { 1210 void RenderFrameHostImpl::NavigateToURL(const GURL& url) {
1210 FrameMsg_Navigate_Params params; 1211 FrameMsg_Navigate_Params params;
1212 params.common_params.url = url;
1213 params.common_params.transition = ui::PAGE_TRANSITION_LINK;
1214 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1215 params.commit_params.browser_navigation_start = base::TimeTicks::Now();
1211 params.page_id = -1; 1216 params.page_id = -1;
1212 params.pending_history_list_offset = -1; 1217 params.pending_history_list_offset = -1;
1213 params.current_history_list_offset = -1; 1218 params.current_history_list_offset = -1;
1214 params.current_history_list_length = 0; 1219 params.current_history_list_length = 0;
1215 params.url = url;
1216 params.transition = ui::PAGE_TRANSITION_LINK;
1217 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1218 params.browser_navigation_start = base::TimeTicks::Now();
1219 Navigate(params); 1220 Navigate(params);
1220 } 1221 }
1221 1222
1222 void RenderFrameHostImpl::Stop() { 1223 void RenderFrameHostImpl::Stop() {
1223 Send(new FrameMsg_Stop(routing_id_)); 1224 Send(new FrameMsg_Stop(routing_id_));
1224 } 1225 }
1225 1226
1226 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { 1227 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) {
1227 TRACE_EVENT_ASYNC_BEGIN0( 1228 TRACE_EVENT_ASYNC_BEGIN0(
1228 "navigation", "RenderFrameHostImpl::BeforeUnload", this); 1229 "navigation", "RenderFrameHostImpl::BeforeUnload", this);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 render_view_host_->delegate_->RendererUnresponsive( 1309 render_view_host_->delegate_->RendererUnresponsive(
1309 render_view_host_, 1310 render_view_host_,
1310 render_view_host_->is_waiting_for_beforeunload_ack(), 1311 render_view_host_->is_waiting_for_beforeunload_ack(),
1311 render_view_host_->IsWaitingForUnloadACK()); 1312 render_view_host_->IsWaitingForUnloadACK());
1312 } 1313 }
1313 1314
1314 void RenderFrameHostImpl::NotificationClosed(int notification_id) { 1315 void RenderFrameHostImpl::NotificationClosed(int notification_id) {
1315 cancel_notification_callbacks_.erase(notification_id); 1316 cancel_notification_callbacks_.erase(notification_id);
1316 } 1317 }
1317 1318
1319 // PlzNavigate
1320 void RenderFrameHostImpl::CommitNavigation(
1321 const GURL& stream_url,
1322 const CommonNavigationParams& common_params,
1323 const CommitNavigationParams& commit_params) {
1324 // TODO(clamy): Check if we have to add security checks for the browser plugin
1325 // guests.
1326
1327 Send(new FrameMsg_CommitNavigation(
1328 routing_id_, stream_url, common_params, commit_params));
1329 // TODO(clamy): Check if we should start the throbber for non javascript urls
1330 // here.
1331 }
1332
1318 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( 1333 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone(
1319 int request_id, blink::WebNotificationPermission permission) { 1334 int request_id, blink::WebNotificationPermission permission) {
1320 Send(new PlatformNotificationMsg_PermissionRequestComplete( 1335 Send(new PlatformNotificationMsg_PermissionRequestComplete(
1321 routing_id_, request_id, permission)); 1336 routing_id_, request_id, permission));
1322 } 1337 }
1323 1338
1324 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( 1339 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility(
1325 const std::map<int32, int> node_to_frame_routing_id_map) { 1340 const std::map<int32, int> node_to_frame_routing_id_map) {
1326 std::map<int32, int>::const_iterator iter; 1341 std::map<int32, int>::const_iterator iter;
1327 for (iter = node_to_frame_routing_id_map.begin(); 1342 for (iter = node_to_frame_routing_id_map.begin();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 "RenderFrameHostImpl navigation suspended", this); 1462 "RenderFrameHostImpl navigation suspended", this);
1448 } 1463 }
1449 1464
1450 if (!suspend && suspended_nav_params_) { 1465 if (!suspend && suspended_nav_params_) {
1451 // There's navigation message params waiting to be sent. Now that we're not 1466 // There's navigation message params waiting to be sent. Now that we're not
1452 // suspended anymore, resume navigation by sending them. If we were swapped 1467 // suspended anymore, resume navigation by sending them. If we were swapped
1453 // out, we should also stop filtering out the IPC messages now. 1468 // out, we should also stop filtering out the IPC messages now.
1454 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); 1469 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT);
1455 1470
1456 DCHECK(!proceed_time.is_null()); 1471 DCHECK(!proceed_time.is_null());
1457 suspended_nav_params_->browser_navigation_start = proceed_time; 1472 suspended_nav_params_->commit_params.browser_navigation_start =
1473 proceed_time;
1458 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); 1474 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_));
1459 suspended_nav_params_.reset(); 1475 suspended_nav_params_.reset();
1460 } 1476 }
1461 } 1477 }
1462 1478
1463 void RenderFrameHostImpl::CancelSuspendedNavigations() { 1479 void RenderFrameHostImpl::CancelSuspendedNavigations() {
1464 // Clear any state if a pending navigation is canceled or preempted. 1480 // Clear any state if a pending navigation is canceled or preempted.
1465 if (suspended_nav_params_) 1481 if (suspended_nav_params_)
1466 suspended_nav_params_.reset(); 1482 suspended_nav_params_.reset();
1467 1483
1468 TRACE_EVENT_ASYNC_END0("navigation", 1484 TRACE_EVENT_ASYNC_END0("navigation",
1469 "RenderFrameHostImpl navigation suspended", this); 1485 "RenderFrameHostImpl navigation suspended", this);
1470 navigations_suspended_ = false; 1486 navigations_suspended_ = false;
1471 } 1487 }
1472 1488
1473 } // namespace content 1489 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698