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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 title_direction)); | 1047 title_direction)); |
1048 } | 1048 } |
1049 | 1049 |
1050 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | 1050 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { |
1051 // This message is only sent for top-level frames. TODO(avi): when frame tree | 1051 // This message is only sent for top-level frames. TODO(avi): when frame tree |
1052 // mirroring works correctly, add a check here to enforce it. | 1052 // mirroring works correctly, add a check here to enforce it. |
1053 delegate_->UpdateEncoding(this, encoding_name); | 1053 delegate_->UpdateEncoding(this, encoding_name); |
1054 } | 1054 } |
1055 | 1055 |
1056 void RenderFrameHostImpl::OnBeginNavigation( | 1056 void RenderFrameHostImpl::OnBeginNavigation( |
1057 const FrameHostMsg_BeginNavigation_Params& params) { | 1057 const FrameHostMsg_BeginNavigation_Params& params, |
| 1058 const CommonNavigationParams& common_params) { |
1058 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 1059 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
1059 switches::kEnableBrowserSideNavigation)); | 1060 switches::kEnableBrowserSideNavigation)); |
1060 frame_tree_node()->render_manager()->OnBeginNavigation(params); | 1061 frame_tree_node()->render_manager()->OnBeginNavigation(params, common_params); |
1061 } | 1062 } |
1062 | 1063 |
1063 void RenderFrameHostImpl::OnAccessibilityEvents( | 1064 void RenderFrameHostImpl::OnAccessibilityEvents( |
1064 const std::vector<AccessibilityHostMsg_EventParams>& params) { | 1065 const std::vector<AccessibilityHostMsg_EventParams>& params) { |
1065 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 1066 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
1066 render_view_host_->GetView()); | 1067 render_view_host_->GetView()); |
1067 | 1068 |
1068 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); | 1069 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); |
1069 if ((accessibility_mode != AccessibilityModeOff) && view && | 1070 if ((accessibility_mode != AccessibilityModeOff) && view && |
1070 RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { | 1071 RenderFrameHostImpl::IsRFHStateActive(rfh_state())) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 // Give the client a chance to disallow URLs from committing. | 1221 // Give the client a chance to disallow URLs from committing. |
1221 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); | 1222 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); |
1222 } | 1223 } |
1223 | 1224 |
1224 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { | 1225 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { |
1225 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); | 1226 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); |
1226 // Browser plugin guests are not allowed to navigate outside web-safe schemes, | 1227 // Browser plugin guests are not allowed to navigate outside web-safe schemes, |
1227 // so do not grant them the ability to request additional URLs. | 1228 // so do not grant them the ability to request additional URLs. |
1228 if (!GetProcess()->IsIsolatedGuest()) { | 1229 if (!GetProcess()->IsIsolatedGuest()) { |
1229 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1230 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
1230 GetProcess()->GetID(), params.url); | 1231 GetProcess()->GetID(), params.common_params.url); |
1231 if (params.url.SchemeIs(url::kDataScheme) && | 1232 if (params.common_params.url.SchemeIs(url::kDataScheme) && |
1232 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { | 1233 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { |
1233 // If 'data:' is used, and we have a 'file:' base url, grant access to | 1234 // If 'data:' is used, and we have a 'file:' base url, grant access to |
1234 // local files. | 1235 // local files. |
1235 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1236 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
1236 GetProcess()->GetID(), params.base_url_for_data_url); | 1237 GetProcess()->GetID(), params.base_url_for_data_url); |
1237 } | 1238 } |
1238 } | 1239 } |
1239 | 1240 |
1240 // Only send the message if we aren't suspended at the start of a cross-site | 1241 // Only send the message if we aren't suspended at the start of a cross-site |
1241 // request. | 1242 // request. |
(...skipping 16 matching lines...) Expand all Loading... |
1258 // loading" message will be received asynchronously from the UI of the | 1259 // loading" message will be received asynchronously from the UI of the |
1259 // browser. But we want to keep the throbber in sync with what's happening | 1260 // browser. But we want to keep the throbber in sync with what's happening |
1260 // in the UI. For example, we want to start throbbing immediately when the | 1261 // in the UI. For example, we want to start throbbing immediately when the |
1261 // user naivgates even if the renderer is delayed. There is also an issue | 1262 // user naivgates even if the renderer is delayed. There is also an issue |
1262 // with the throbber starting because the WebUI (which controls whether the | 1263 // with the throbber starting because the WebUI (which controls whether the |
1263 // favicon is displayed) happens synchronously. If the start loading | 1264 // favicon is displayed) happens synchronously. If the start loading |
1264 // messages was asynchronous, then the default favicon would flash in. | 1265 // messages was asynchronous, then the default favicon would flash in. |
1265 // | 1266 // |
1266 // Blink doesn't send throb notifications for JavaScript URLs, so we | 1267 // Blink doesn't send throb notifications for JavaScript URLs, so we |
1267 // don't want to either. | 1268 // don't want to either. |
1268 if (!params.url.SchemeIs(url::kJavaScriptScheme)) | 1269 if (!params.common_params.url.SchemeIs(url::kJavaScriptScheme)) |
1269 delegate_->DidStartLoading(this, true); | 1270 delegate_->DidStartLoading(this, true); |
1270 } | 1271 } |
1271 | 1272 |
1272 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { | 1273 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { |
1273 FrameMsg_Navigate_Params params; | 1274 FrameMsg_Navigate_Params params; |
| 1275 params.common_params.url = url; |
| 1276 params.common_params.transition = ui::PAGE_TRANSITION_LINK; |
| 1277 params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1278 params.commit_params.browser_navigation_start = base::TimeTicks::Now(); |
1274 params.page_id = -1; | 1279 params.page_id = -1; |
1275 params.pending_history_list_offset = -1; | 1280 params.pending_history_list_offset = -1; |
1276 params.current_history_list_offset = -1; | 1281 params.current_history_list_offset = -1; |
1277 params.current_history_list_length = 0; | 1282 params.current_history_list_length = 0; |
1278 params.url = url; | |
1279 params.transition = ui::PAGE_TRANSITION_LINK; | |
1280 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | |
1281 params.browser_navigation_start = base::TimeTicks::Now(); | |
1282 Navigate(params); | 1283 Navigate(params); |
1283 } | 1284 } |
1284 | 1285 |
1285 void RenderFrameHostImpl::Stop() { | 1286 void RenderFrameHostImpl::Stop() { |
1286 Send(new FrameMsg_Stop(routing_id_)); | 1287 Send(new FrameMsg_Stop(routing_id_)); |
1287 } | 1288 } |
1288 | 1289 |
1289 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 1290 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
1290 TRACE_EVENT_ASYNC_BEGIN0( | 1291 TRACE_EVENT_ASYNC_BEGIN0( |
1291 "navigation", "RenderFrameHostImpl::BeforeUnload", this); | 1292 "navigation", "RenderFrameHostImpl::BeforeUnload", this); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 // This must be done after sending the reply since RenderView can't close | 1365 // This must be done after sending the reply since RenderView can't close |
1365 // correctly while waiting for a response. | 1366 // correctly while waiting for a response. |
1366 if (is_waiting && dialog_was_suppressed) | 1367 if (is_waiting && dialog_was_suppressed) |
1367 render_view_host_->delegate_->RendererUnresponsive(render_view_host_); | 1368 render_view_host_->delegate_->RendererUnresponsive(render_view_host_); |
1368 } | 1369 } |
1369 | 1370 |
1370 void RenderFrameHostImpl::NotificationClosed(int notification_id) { | 1371 void RenderFrameHostImpl::NotificationClosed(int notification_id) { |
1371 cancel_notification_callbacks_.erase(notification_id); | 1372 cancel_notification_callbacks_.erase(notification_id); |
1372 } | 1373 } |
1373 | 1374 |
| 1375 // PlzNavigate |
| 1376 void RenderFrameHostImpl::CommitNavigation( |
| 1377 const GURL& stream_url, |
| 1378 const CommonNavigationParams& common_params, |
| 1379 const CommitNavigationParams& commit_params) { |
| 1380 // TODO(clamy): Check if we have to add security checks for the browser plugin |
| 1381 // guests. |
| 1382 |
| 1383 Send(new FrameMsg_CommitNavigation( |
| 1384 routing_id_, stream_url, common_params, commit_params)); |
| 1385 // TODO(clamy): Check if we should start the throbber for non javascript urls |
| 1386 // here. |
| 1387 } |
| 1388 |
1374 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( | 1389 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( |
1375 int request_id, blink::WebNotificationPermission permission) { | 1390 int request_id, blink::WebNotificationPermission permission) { |
1376 Send(new PlatformNotificationMsg_PermissionRequestComplete( | 1391 Send(new PlatformNotificationMsg_PermissionRequestComplete( |
1377 routing_id_, request_id, permission)); | 1392 routing_id_, request_id, permission)); |
1378 } | 1393 } |
1379 | 1394 |
1380 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( | 1395 void RenderFrameHostImpl::UpdateCrossProcessIframeAccessibility( |
1381 const std::map<int32, int> node_to_frame_routing_id_map) { | 1396 const std::map<int32, int> node_to_frame_routing_id_map) { |
1382 std::map<int32, int>::const_iterator iter; | 1397 std::map<int32, int>::const_iterator iter; |
1383 for (iter = node_to_frame_routing_id_map.begin(); | 1398 for (iter = node_to_frame_routing_id_map.begin(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 "RenderFrameHostImpl navigation suspended", this); | 1518 "RenderFrameHostImpl navigation suspended", this); |
1504 } | 1519 } |
1505 | 1520 |
1506 if (!suspend && suspended_nav_params_) { | 1521 if (!suspend && suspended_nav_params_) { |
1507 // There's navigation message params waiting to be sent. Now that we're not | 1522 // There's navigation message params waiting to be sent. Now that we're not |
1508 // suspended anymore, resume navigation by sending them. If we were swapped | 1523 // suspended anymore, resume navigation by sending them. If we were swapped |
1509 // out, we should also stop filtering out the IPC messages now. | 1524 // out, we should also stop filtering out the IPC messages now. |
1510 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 1525 SetState(RenderFrameHostImpl::STATE_DEFAULT); |
1511 | 1526 |
1512 DCHECK(!proceed_time.is_null()); | 1527 DCHECK(!proceed_time.is_null()); |
1513 suspended_nav_params_->browser_navigation_start = proceed_time; | 1528 suspended_nav_params_->commit_params.browser_navigation_start = |
| 1529 proceed_time; |
1514 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); | 1530 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); |
1515 suspended_nav_params_.reset(); | 1531 suspended_nav_params_.reset(); |
1516 } | 1532 } |
1517 } | 1533 } |
1518 | 1534 |
1519 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1535 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
1520 // Clear any state if a pending navigation is canceled or preempted. | 1536 // Clear any state if a pending navigation is canceled or preempted. |
1521 if (suspended_nav_params_) | 1537 if (suspended_nav_params_) |
1522 suspended_nav_params_.reset(); | 1538 suspended_nav_params_.reset(); |
1523 | 1539 |
1524 TRACE_EVENT_ASYNC_END0("navigation", | 1540 TRACE_EVENT_ASYNC_END0("navigation", |
1525 "RenderFrameHostImpl navigation suspended", this); | 1541 "RenderFrameHostImpl navigation suspended", this); |
1526 navigations_suspended_ = false; | 1542 navigations_suspended_ = false; |
1527 } | 1543 } |
1528 | 1544 |
1529 } // namespace content | 1545 } // namespace content |
OLD | NEW |