Chromium Code Reviews| 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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 title_direction)); | 1023 title_direction)); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | 1026 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { |
| 1027 // This message is only sent for top-level frames. TODO(avi): when frame tree | 1027 // This message is only sent for top-level frames. TODO(avi): when frame tree |
| 1028 // mirroring works correctly, add a check here to enforce it. | 1028 // mirroring works correctly, add a check here to enforce it. |
| 1029 delegate_->UpdateEncoding(this, encoding_name); | 1029 delegate_->UpdateEncoding(this, encoding_name); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 void RenderFrameHostImpl::OnBeginNavigation( | 1032 void RenderFrameHostImpl::OnBeginNavigation( |
| 1033 const FrameHostMsg_BeginNavigation_Params& params) { | 1033 const FrameHostMsg_BeginNavigation_Params& params, |
| 1034 const CoreNavigationParams& core_params) { | |
| 1034 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 1035 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
| 1035 switches::kEnableBrowserSideNavigation)); | 1036 switches::kEnableBrowserSideNavigation)); |
| 1036 frame_tree_node()->render_manager()->OnBeginNavigation(params); | 1037 frame_tree_node()->render_manager()->OnBeginNavigation(params, core_params); |
| 1037 } | 1038 } |
| 1038 | 1039 |
| 1039 void RenderFrameHostImpl::OnAccessibilityEvents( | 1040 void RenderFrameHostImpl::OnAccessibilityEvents( |
| 1040 const std::vector<AccessibilityHostMsg_EventParams>& params) { | 1041 const std::vector<AccessibilityHostMsg_EventParams>& params) { |
| 1041 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 1042 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
| 1042 render_view_host_->GetView()); | 1043 render_view_host_->GetView()); |
| 1043 | 1044 |
| 1044 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 1045 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
| 1045 if ((accessibility_mode != AccessibilityModeOff) && view && | 1046 if ((accessibility_mode != AccessibilityModeOff) && view && |
| 1046 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { | 1047 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1166 // Give the client a chance to disallow URLs from committing. | 1167 // Give the client a chance to disallow URLs from committing. |
| 1167 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); | 1168 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); |
| 1168 } | 1169 } |
| 1169 | 1170 |
| 1170 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { | 1171 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { |
| 1171 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); | 1172 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); |
| 1172 // Browser plugin guests are not allowed to navigate outside web-safe schemes, | 1173 // Browser plugin guests are not allowed to navigate outside web-safe schemes, |
| 1173 // so do not grant them the ability to request additional URLs. | 1174 // so do not grant them the ability to request additional URLs. |
| 1174 if (!GetProcess()->IsIsolatedGuest()) { | 1175 if (!GetProcess()->IsIsolatedGuest()) { |
| 1175 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1176 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
| 1176 GetProcess()->GetID(), params.url); | 1177 GetProcess()->GetID(), params.core_params.url); |
| 1177 if (params.url.SchemeIs(url::kDataScheme) && | 1178 if (params.core_params.url.SchemeIs(url::kDataScheme) && |
| 1178 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { | 1179 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { |
| 1179 // If 'data:' is used, and we have a 'file:' base url, grant access to | 1180 // If 'data:' is used, and we have a 'file:' base url, grant access to |
| 1180 // local files. | 1181 // local files. |
| 1181 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1182 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
| 1182 GetProcess()->GetID(), params.base_url_for_data_url); | 1183 GetProcess()->GetID(), params.base_url_for_data_url); |
| 1183 } | 1184 } |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 // Only send the message if we aren't suspended at the start of a cross-site | 1187 // Only send the message if we aren't suspended at the start of a cross-site |
| 1187 // request. | 1188 // request. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1204 // loading" message will be received asynchronously from the UI of the | 1205 // loading" message will be received asynchronously from the UI of the |
| 1205 // browser. But we want to keep the throbber in sync with what's happening | 1206 // browser. But we want to keep the throbber in sync with what's happening |
| 1206 // in the UI. For example, we want to start throbbing immediately when the | 1207 // in the UI. For example, we want to start throbbing immediately when the |
| 1207 // user naivgates even if the renderer is delayed. There is also an issue | 1208 // user naivgates even if the renderer is delayed. There is also an issue |
| 1208 // with the throbber starting because the WebUI (which controls whether the | 1209 // with the throbber starting because the WebUI (which controls whether the |
| 1209 // favicon is displayed) happens synchronously. If the start loading | 1210 // favicon is displayed) happens synchronously. If the start loading |
| 1210 // messages was asynchronous, then the default favicon would flash in. | 1211 // messages was asynchronous, then the default favicon would flash in. |
| 1211 // | 1212 // |
| 1212 // Blink doesn't send throb notifications for JavaScript URLs, so we | 1213 // Blink doesn't send throb notifications for JavaScript URLs, so we |
| 1213 // don't want to either. | 1214 // don't want to either. |
| 1214 if (!params.url.SchemeIs(url::kJavaScriptScheme)) | 1215 if (!params.core_params.url.SchemeIs(url::kJavaScriptScheme)) |
| 1215 delegate_->DidStartLoading(this, true); | 1216 delegate_->DidStartLoading(this, true); |
| 1216 } | 1217 } |
| 1217 | 1218 |
| 1218 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { | 1219 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { |
| 1219 FrameMsg_Navigate_Params params; | 1220 FrameMsg_Navigate_Params params; |
| 1220 params.page_id = -1; | 1221 params.commit_params.page_id = -1; |
| 1221 params.pending_history_list_offset = -1; | 1222 params.commit_params.pending_history_list_offset = -1; |
| 1222 params.current_history_list_offset = -1; | 1223 params.commit_params.current_history_list_offset = -1; |
| 1223 params.current_history_list_length = 0; | 1224 params.commit_params.current_history_list_length = 0; |
| 1224 params.url = url; | 1225 params.core_params.url = url; |
|
nasko
2014/09/22 23:13:03
nit: I'd put the core params before the commit one
clamy
2014/09/23 21:13:25
Done.
| |
| 1225 params.transition = PAGE_TRANSITION_LINK; | 1226 params.core_params.transition = PAGE_TRANSITION_LINK; |
| 1226 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1227 params.core_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1227 params.browser_navigation_start = base::TimeTicks::Now(); | 1228 params.commit_params.browser_navigation_start = base::TimeTicks::Now(); |
|
nasko
2014/09/22 23:13:03
nit: move this up to the group of commit_* members
clamy
2014/09/23 21:13:25
Moved it above the history parameters as history p
| |
| 1228 Navigate(params); | 1229 Navigate(params); |
| 1229 } | 1230 } |
| 1230 | 1231 |
| 1231 void RenderFrameHostImpl::Stop() { | 1232 void RenderFrameHostImpl::Stop() { |
| 1232 Send(new FrameMsg_Stop(routing_id_)); | 1233 Send(new FrameMsg_Stop(routing_id_)); |
| 1233 } | 1234 } |
| 1234 | 1235 |
| 1235 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 1236 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
| 1236 TRACE_EVENT_ASYNC_BEGIN0( | 1237 TRACE_EVENT_ASYNC_BEGIN0( |
| 1237 "navigation", "RenderFrameHostImpl::BeforeUnload", this); | 1238 "navigation", "RenderFrameHostImpl::BeforeUnload", this); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1317 render_view_host_->delegate_->RendererUnresponsive( | 1318 render_view_host_->delegate_->RendererUnresponsive( |
| 1318 render_view_host_, | 1319 render_view_host_, |
| 1319 render_view_host_->is_waiting_for_beforeunload_ack(), | 1320 render_view_host_->is_waiting_for_beforeunload_ack(), |
| 1320 render_view_host_->IsWaitingForUnloadACK()); | 1321 render_view_host_->IsWaitingForUnloadACK()); |
| 1321 } | 1322 } |
| 1322 | 1323 |
| 1323 void RenderFrameHostImpl::NotificationClosed(int notification_id) { | 1324 void RenderFrameHostImpl::NotificationClosed(int notification_id) { |
| 1324 cancel_notification_callbacks_.erase(notification_id); | 1325 cancel_notification_callbacks_.erase(notification_id); |
| 1325 } | 1326 } |
| 1326 | 1327 |
| 1328 // PlzNavigate | |
| 1329 void RenderFrameHostImpl::CommitNavigation( | |
| 1330 const GURL& stream_url, | |
| 1331 const CoreNavigationParams& core_params, | |
| 1332 const CommitNavigationParams& commit_params) { | |
| 1333 // TODO(clamy): Check if we have to add security checks for the browser plugin | |
| 1334 // guests. | |
| 1335 | |
| 1336 DCHECK(render_view_host_->rvh_state() == RenderViewHostImpl::STATE_DEFAULT); | |
| 1337 // Get back to a clean state, in case we start a new navigation without | |
| 1338 // completing a RVH swap or unload handler. | |
| 1339 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); | |
|
Charlie Reis
2014/09/19 23:12:31
As mentioned, please either remove this or add a T
clamy
2014/09/23 21:13:25
Done.
| |
| 1340 Send(new FrameMsg_CommitNavigation( | |
| 1341 routing_id_, stream_url, core_params, commit_params)); | |
| 1342 // TODO(clamy): Check if we should start the throbber for non javascript urls | |
| 1343 // here. | |
| 1344 } | |
| 1345 | |
| 1327 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( | 1346 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( |
| 1328 int request_id, blink::WebNotificationPermission permission) { | 1347 int request_id, blink::WebNotificationPermission permission) { |
| 1329 Send(new PlatformNotificationMsg_PermissionRequestComplete( | 1348 Send(new PlatformNotificationMsg_PermissionRequestComplete( |
| 1330 routing_id_, request_id, permission)); | 1349 routing_id_, request_id, permission)); |
| 1331 } | 1350 } |
| 1332 | 1351 |
| 1333 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( | 1352 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( |
| 1334 const std::map<int32, int> node_to_frame_routing_id_map) { | 1353 const std::map<int32, int> node_to_frame_routing_id_map) { |
| 1335 std::map<int32, int>::const_iterator iter; | 1354 std::map<int32, int>::const_iterator iter; |
| 1336 for (iter = node_to_frame_routing_id_map.begin(); | 1355 for (iter = node_to_frame_routing_id_map.begin(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1456 "RenderFrameHostImpl navigation suspended", this); | 1475 "RenderFrameHostImpl navigation suspended", this); |
| 1457 } | 1476 } |
| 1458 | 1477 |
| 1459 if (!suspend && suspended_nav_params_) { | 1478 if (!suspend && suspended_nav_params_) { |
| 1460 // There's navigation message params waiting to be sent. Now that we're not | 1479 // There's navigation message params waiting to be sent. Now that we're not |
| 1461 // suspended anymore, resume navigation by sending them. If we were swapped | 1480 // suspended anymore, resume navigation by sending them. If we were swapped |
| 1462 // out, we should also stop filtering out the IPC messages now. | 1481 // out, we should also stop filtering out the IPC messages now. |
| 1463 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); | 1482 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); |
| 1464 | 1483 |
| 1465 DCHECK(!proceed_time.is_null()); | 1484 DCHECK(!proceed_time.is_null()); |
| 1466 suspended_nav_params_->browser_navigation_start = proceed_time; | 1485 suspended_nav_params_->commit_params.browser_navigation_start = |
| 1486 proceed_time; | |
| 1467 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); | 1487 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); |
| 1468 suspended_nav_params_.reset(); | 1488 suspended_nav_params_.reset(); |
| 1469 } | 1489 } |
| 1470 } | 1490 } |
| 1471 | 1491 |
| 1472 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1492 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
| 1473 // Clear any state if a pending navigation is canceled or preempted. | 1493 // Clear any state if a pending navigation is canceled or preempted. |
| 1474 if (suspended_nav_params_) | 1494 if (suspended_nav_params_) |
| 1475 suspended_nav_params_.reset(); | 1495 suspended_nav_params_.reset(); |
| 1476 | 1496 |
| 1477 TRACE_EVENT_ASYNC_END0("navigation", | 1497 TRACE_EVENT_ASYNC_END0("navigation", |
| 1478 "RenderFrameHostImpl navigation suspended", this); | 1498 "RenderFrameHostImpl navigation suspended", this); |
| 1479 navigations_suspended_ = false; | 1499 navigations_suspended_ = false; |
| 1480 } | 1500 } |
| 1481 | 1501 |
| 1482 } // namespace content | 1502 } // namespace content |
| OLD | NEW |