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