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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 #include "content/public/common/file_chooser_params.h" | 80 #include "content/public/common/file_chooser_params.h" |
81 #include "content/public/common/isolated_world_ids.h" | 81 #include "content/public/common/isolated_world_ids.h" |
82 #include "content/public/common/mojo_shell_connection.h" | 82 #include "content/public/common/mojo_shell_connection.h" |
83 #include "content/public/common/url_constants.h" | 83 #include "content/public/common/url_constants.h" |
84 #include "content/public/common/url_utils.h" | 84 #include "content/public/common/url_utils.h" |
85 #include "device/generic_sensor/sensor_provider_impl.h" | 85 #include "device/generic_sensor/sensor_provider_impl.h" |
86 #include "device/geolocation/geolocation_service_context.h" | 86 #include "device/geolocation/geolocation_service_context.h" |
87 #include "device/vibration/vibration_manager_impl.h" | 87 #include "device/vibration/vibration_manager_impl.h" |
88 #include "media/mojo/interfaces/media_service.mojom.h" | 88 #include "media/mojo/interfaces/media_service.mojom.h" |
89 #include "media/mojo/interfaces/service_factory.mojom.h" | 89 #include "media/mojo/interfaces/service_factory.mojom.h" |
| 90 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| 91 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
90 #include "services/shell/public/cpp/connector.h" | 92 #include "services/shell/public/cpp/connector.h" |
91 #include "services/shell/public/cpp/interface_provider.h" | 93 #include "services/shell/public/cpp/interface_provider.h" |
92 #include "ui/accessibility/ax_tree.h" | 94 #include "ui/accessibility/ax_tree.h" |
93 #include "ui/accessibility/ax_tree_update.h" | 95 #include "ui/accessibility/ax_tree_update.h" |
94 #include "ui/gfx/geometry/quad_f.h" | 96 #include "ui/gfx/geometry/quad_f.h" |
95 #include "url/gurl.h" | 97 #include "url/gurl.h" |
96 | 98 |
97 #if defined(OS_ANDROID) | 99 #if defined(OS_ANDROID) |
98 #include "content/browser/mojo/interface_registrar_android.h" | 100 #include "content/browser/mojo/interface_registrar_android.h" |
99 #if defined(ENABLE_MOJO_CDM) | 101 #if defined(ENABLE_MOJO_CDM) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 browser_plugin_embedder_ax_tree_id_(AXTreeIDRegistry::kNoAXTreeID), | 262 browser_plugin_embedder_ax_tree_id_(AXTreeIDRegistry::kNoAXTreeID), |
261 no_create_browser_accessibility_manager_for_testing_(false), | 263 no_create_browser_accessibility_manager_for_testing_(false), |
262 web_ui_type_(WebUI::kNoWebUI), | 264 web_ui_type_(WebUI::kNoWebUI), |
263 pending_web_ui_type_(WebUI::kNoWebUI), | 265 pending_web_ui_type_(WebUI::kNoWebUI), |
264 should_reuse_web_ui_(false), | 266 should_reuse_web_ui_(false), |
265 last_navigation_lofi_state_(LOFI_UNSPECIFIED), | 267 last_navigation_lofi_state_(LOFI_UNSPECIFIED), |
266 frame_host_binding_(this), | 268 frame_host_binding_(this), |
267 weak_ptr_factory_(this) { | 269 weak_ptr_factory_(this) { |
268 frame_tree_->AddRenderViewHostRef(render_view_host_); | 270 frame_tree_->AddRenderViewHostRef(render_view_host_); |
269 GetProcess()->AddRoute(routing_id_, this); | 271 GetProcess()->AddRoute(routing_id_, this); |
| 272 GetProcess()->AddRoutedInterfaces(routing_id_, this); |
270 g_routing_id_frame_map.Get().insert(std::make_pair( | 273 g_routing_id_frame_map.Get().insert(std::make_pair( |
271 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 274 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
272 this)); | 275 this)); |
273 site_instance_->AddObserver(this); | 276 site_instance_->AddObserver(this); |
274 GetSiteInstance()->IncrementActiveFrameCount(); | 277 GetSiteInstance()->IncrementActiveFrameCount(); |
275 | 278 |
276 if (frame_tree_node_->parent()) { | 279 if (frame_tree_node_->parent()) { |
277 // Keep track of the parent RenderFrameHost, which shouldn't change even if | 280 // Keep track of the parent RenderFrameHost, which shouldn't change even if |
278 // this RenderFrameHost is on the pending deletion list and the parent | 281 // this RenderFrameHost is on the pending deletion list and the parent |
279 // FrameTreeNode has changed its current RenderFrameHost. | 282 // FrameTreeNode has changed its current RenderFrameHost. |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 496 } |
494 | 497 |
495 shell::InterfaceRegistry* RenderFrameHostImpl::GetInterfaceRegistry() { | 498 shell::InterfaceRegistry* RenderFrameHostImpl::GetInterfaceRegistry() { |
496 return interface_registry_.get(); | 499 return interface_registry_.get(); |
497 } | 500 } |
498 | 501 |
499 shell::InterfaceProvider* RenderFrameHostImpl::GetRemoteInterfaces() { | 502 shell::InterfaceProvider* RenderFrameHostImpl::GetRemoteInterfaces() { |
500 return remote_interfaces_.get(); | 503 return remote_interfaces_.get(); |
501 } | 504 } |
502 | 505 |
| 506 void RenderFrameHostImpl::AddRoutedInterface( |
| 507 const base::StringPiece& name, |
| 508 const RoutedInterfaceFactory& factory) { |
| 509 auto result = |
| 510 routed_interfaces_.insert(std::make_pair(name.as_string(), factory)); |
| 511 DCHECK(result.second); |
| 512 } |
| 513 |
| 514 void RenderFrameHostImpl::RemoveRoutedInterface(const base::StringPiece& name) { |
| 515 auto it = routed_interfaces_.find(name.as_string()); |
| 516 DCHECK(it != routed_interfaces_.end()); |
| 517 routed_interfaces_.erase(it); |
| 518 } |
| 519 |
| 520 void RenderFrameHostImpl::GetRemoteRoutedInterface( |
| 521 const base::StringPiece& name, |
| 522 mojo::ScopedInterfaceEndpointHandle handle) { |
| 523 mojom::RoutedInterfaceAssociatedRequest request; |
| 524 request.Bind(std::move(handle)); |
| 525 GetRemoteRoutedInterfaces()->GetRoutedInterface(name.as_string(), |
| 526 std::move(request)); |
| 527 } |
| 528 |
503 blink::WebPageVisibilityState RenderFrameHostImpl::GetVisibilityState() { | 529 blink::WebPageVisibilityState RenderFrameHostImpl::GetVisibilityState() { |
504 // Works around the crashes seen in https://crbug.com/501863, where the | 530 // Works around the crashes seen in https://crbug.com/501863, where the |
505 // active WebContents from a browser iterator may contain a render frame | 531 // active WebContents from a browser iterator may contain a render frame |
506 // detached from the frame tree. This tries to find a RenderWidgetHost | 532 // detached from the frame tree. This tries to find a RenderWidgetHost |
507 // attached to an ancestor frame, and defaults to visibility hidden if | 533 // attached to an ancestor frame, and defaults to visibility hidden if |
508 // it fails. | 534 // it fails. |
509 // TODO(yfriedman, peter): Ideally this would never be called on an | 535 // TODO(yfriedman, peter): Ideally this would never be called on an |
510 // unattached frame and we could omit this check. See | 536 // unattached frame and we could omit this check. See |
511 // https://crbug.com/615867. | 537 // https://crbug.com/615867. |
512 RenderFrameHostImpl* frame = this; | 538 RenderFrameHostImpl* frame = this; |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 // reset. | 1482 // reset. |
1457 SetRenderFrameCreated(false); | 1483 SetRenderFrameCreated(false); |
1458 InvalidateMojoConnection(); | 1484 InvalidateMojoConnection(); |
1459 | 1485 |
1460 // Execute any pending AX tree snapshot callbacks with an empty response, | 1486 // Execute any pending AX tree snapshot callbacks with an empty response, |
1461 // since we're never going to get a response from this renderer. | 1487 // since we're never going to get a response from this renderer. |
1462 for (const auto& iter : ax_tree_snapshot_callbacks_) | 1488 for (const auto& iter : ax_tree_snapshot_callbacks_) |
1463 iter.second.Run(ui::AXTreeUpdate()); | 1489 iter.second.Run(ui::AXTreeUpdate()); |
1464 ax_tree_snapshot_callbacks_.clear(); | 1490 ax_tree_snapshot_callbacks_.clear(); |
1465 | 1491 |
| 1492 // Ensure that future remote interface requests are associated with the new |
| 1493 // process's channel. |
| 1494 remote_routed_interfaces_.reset(); |
| 1495 |
1466 if (!is_active()) { | 1496 if (!is_active()) { |
1467 // If the process has died, we don't need to wait for the swap out ack from | 1497 // If the process has died, we don't need to wait for the swap out ack from |
1468 // this RenderFrame if it is pending deletion. Complete the swap out to | 1498 // this RenderFrame if it is pending deletion. Complete the swap out to |
1469 // destroy it. | 1499 // destroy it. |
1470 OnSwappedOut(); | 1500 OnSwappedOut(); |
1471 } else { | 1501 } else { |
1472 // If this was the current pending or speculative RFH dying, cancel and | 1502 // If this was the current pending or speculative RFH dying, cancel and |
1473 // destroy it. | 1503 // destroy it. |
1474 frame_tree_node_->render_manager()->CancelPendingIfNecessary(this); | 1504 frame_tree_node_->render_manager()->CancelPendingIfNecessary(this); |
1475 } | 1505 } |
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3054 // handler after it's destroyed so it can't run after the RFHI is destroyed. | 3084 // handler after it's destroyed so it can't run after the RFHI is destroyed. |
3055 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( | 3085 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( |
3056 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); | 3086 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); |
3057 return web_bluetooth_service_.get(); | 3087 return web_bluetooth_service_.get(); |
3058 } | 3088 } |
3059 | 3089 |
3060 void RenderFrameHostImpl::DeleteWebBluetoothService() { | 3090 void RenderFrameHostImpl::DeleteWebBluetoothService() { |
3061 web_bluetooth_service_.reset(); | 3091 web_bluetooth_service_.reset(); |
3062 } | 3092 } |
3063 | 3093 |
| 3094 mojom::RoutedInterfaceProvider* |
| 3095 RenderFrameHostImpl::GetRemoteRoutedInterfaces() { |
| 3096 if (!remote_routed_interfaces_) { |
| 3097 GetProcess()->GetRemoteRouteProvider()->GetRoutedInterfaces( |
| 3098 GetRoutingID(), |
| 3099 mojo::GetProxy(&remote_routed_interfaces_, |
| 3100 GetProcess()->GetChannel()->GetAssociatedGroup())); |
| 3101 } |
| 3102 return remote_routed_interfaces_.get(); |
| 3103 } |
| 3104 |
| 3105 void RenderFrameHostImpl::GetRoutedInterface( |
| 3106 const std::string& name, |
| 3107 mojom::RoutedInterfaceAssociatedRequest request) { |
| 3108 auto it = routed_interfaces_.find(name); |
| 3109 if (it != routed_interfaces_.end()) |
| 3110 it->second.Run(request.PassHandle()); |
| 3111 } |
| 3112 |
3064 } // namespace content | 3113 } // namespace content |
OLD | NEW |