Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
| 15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 16 #include "base/json/json_reader.h" | 16 #include "base/json/json_reader.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "cc/base/switches.h" | 25 #include "cc/base/switches.h" |
| 26 #include "content/browser/accessibility/browser_accessibility_manager.h" | 26 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 27 #include "content/browser/accessibility/frame_tree_accessibility.h" | |
| 27 #include "content/browser/child_process_security_policy_impl.h" | 28 #include "content/browser/child_process_security_policy_impl.h" |
| 28 #include "content/browser/cross_site_request_manager.h" | 29 #include "content/browser/cross_site_request_manager.h" |
| 29 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 30 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 31 #include "content/browser/frame_host/cross_process_frame_connector.h" | |
| 30 #include "content/browser/frame_host/frame_tree.h" | 32 #include "content/browser/frame_host/frame_tree.h" |
| 33 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | |
| 31 #include "content/browser/gpu/compositor_util.h" | 34 #include "content/browser/gpu/compositor_util.h" |
| 32 #include "content/browser/gpu/gpu_data_manager_impl.h" | 35 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 33 #include "content/browser/gpu/gpu_process_host.h" | 36 #include "content/browser/gpu/gpu_process_host.h" |
| 34 #include "content/browser/gpu/gpu_surface_tracker.h" | 37 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 35 #include "content/browser/host_zoom_map_impl.h" | 38 #include "content/browser/host_zoom_map_impl.h" |
| 36 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 39 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 37 #include "content/browser/renderer_host/dip_util.h" | 40 #include "content/browser/renderer_host/dip_util.h" |
| 38 #include "content/browser/renderer_host/input/timeout_monitor.h" | 41 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 39 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 42 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 40 #include "content/browser/renderer_host/render_process_host_impl.h" | 43 #include "content/browser/renderer_host/render_process_host_impl.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 base::Unretained(ResourceDispatcherHostImpl::Get()), | 238 base::Unretained(ResourceDispatcherHostImpl::Get()), |
| 236 GetProcess()->GetID(), GetRoutingID())); | 239 GetProcess()->GetID(), GetRoutingID())); |
| 237 } | 240 } |
| 238 | 241 |
| 239 #if defined(OS_ANDROID) | 242 #if defined(OS_ANDROID) |
| 240 media_player_manager_.reset(BrowserMediaPlayerManager::Create(this)); | 243 media_player_manager_.reset(BrowserMediaPlayerManager::Create(this)); |
| 241 #endif | 244 #endif |
| 242 | 245 |
| 243 unload_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( | 246 unload_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( |
| 244 &RenderViewHostImpl::OnSwappedOut, weak_factory_.GetWeakPtr(), true))); | 247 &RenderViewHostImpl::OnSwappedOut, weak_factory_.GetWeakPtr(), true))); |
| 248 | |
| 249 FrameTreeAccessibility::GetInstance()->OnFrameCreated(this); | |
| 245 } | 250 } |
| 246 | 251 |
| 247 RenderViewHostImpl::~RenderViewHostImpl() { | 252 RenderViewHostImpl::~RenderViewHostImpl() { |
| 248 if (ResourceDispatcherHostImpl::Get()) { | 253 if (ResourceDispatcherHostImpl::Get()) { |
| 249 BrowserThread::PostTask( | 254 BrowserThread::PostTask( |
| 250 BrowserThread::IO, FROM_HERE, | 255 BrowserThread::IO, FROM_HERE, |
| 251 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, | 256 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, |
| 252 base::Unretained(ResourceDispatcherHostImpl::Get()), | 257 base::Unretained(ResourceDispatcherHostImpl::Get()), |
| 253 GetProcess()->GetID(), GetRoutingID())); | 258 GetProcess()->GetID(), GetRoutingID())); |
| 254 } | 259 } |
| 255 | 260 |
| 256 delegate_->RenderViewDeleted(this); | 261 delegate_->RenderViewDeleted(this); |
| 257 | 262 |
| 258 // Be sure to clean up any leftover state from cross-site requests. | 263 // Be sure to clean up any leftover state from cross-site requests. |
| 259 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( | 264 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
| 260 GetProcess()->GetID(), GetRoutingID(), false); | 265 GetProcess()->GetID(), GetRoutingID(), false); |
| 261 | 266 |
| 262 // If this was swapped out, it already decremented the active view | 267 // If this was swapped out, it already decremented the active view |
| 263 // count of the SiteInstance it belongs to. | 268 // count of the SiteInstance it belongs to. |
| 264 if (IsRVHStateActive(rvh_state_)) | 269 if (IsRVHStateActive(rvh_state_)) |
| 265 instance_->decrement_active_view_count(); | 270 instance_->decrement_active_view_count(); |
| 271 | |
| 272 FrameTreeAccessibility::GetInstance()->OnFrameDeleted(this); | |
| 266 } | 273 } |
| 267 | 274 |
| 268 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { | 275 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { |
| 269 return delegate_; | 276 return delegate_; |
| 270 } | 277 } |
| 271 | 278 |
| 272 SiteInstance* RenderViewHostImpl::GetSiteInstance() const { | 279 SiteInstance* RenderViewHostImpl::GetSiteInstance() const { |
| 273 return instance_.get(); | 280 return instance_.get(); |
| 274 } | 281 } |
| 275 | 282 |
| (...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1594 | 1601 |
| 1595 void RenderViewHostImpl::ExecutePluginActionAtLocation( | 1602 void RenderViewHostImpl::ExecutePluginActionAtLocation( |
| 1596 const gfx::Point& location, const blink::WebPluginAction& action) { | 1603 const gfx::Point& location, const blink::WebPluginAction& action) { |
| 1597 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); | 1604 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); |
| 1598 } | 1605 } |
| 1599 | 1606 |
| 1600 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { | 1607 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { |
| 1601 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); | 1608 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); |
| 1602 } | 1609 } |
| 1603 | 1610 |
| 1611 static int GetAccessibleFrameId(int process_id, int frame_routing_id) { | |
| 1612 RenderFrameHostImpl* render_frame_host = RenderFrameHostImpl::FromID( | |
| 1613 process_id, frame_routing_id); | |
| 1614 if (render_frame_host) { | |
| 1615 CrossProcessFrameConnector* connector = | |
| 1616 render_frame_host->cross_process_frame_connector(); | |
| 1617 if (connector) { | |
| 1618 RenderWidgetHostViewChildFrame* view = connector->view(); | |
| 1619 if (view) { | |
| 1620 RenderWidgetHostImpl* rwhi = | |
| 1621 RenderWidgetHostImpl::From(view->GetRenderWidgetHost()); | |
| 1622 return FrameTreeAccessibility::GetInstance()->GetFrameId(rwhi); | |
| 1623 } | |
| 1624 } | |
| 1625 } | |
| 1626 | |
| 1627 return 0; | |
| 1628 } | |
| 1629 | |
| 1604 void RenderViewHostImpl::OnAccessibilityEvents( | 1630 void RenderViewHostImpl::OnAccessibilityEvents( |
| 1605 const std::vector<AccessibilityHostMsg_EventParams>& params) { | 1631 const std::vector<AccessibilityHostMsg_EventParams>& params) { |
| 1632 BrowserAccessibilityManager* manager = NULL; | |
| 1606 if ((accessibility_mode() != AccessibilityModeOff) && view_ && | 1633 if ((accessibility_mode() != AccessibilityModeOff) && view_ && |
| 1607 IsRVHStateActive(rvh_state_)) { | 1634 IsRVHStateActive(rvh_state_)) { |
| 1635 // Send the updates to the BrowserAccessibilityManager to support | |
| 1636 // native accessibility APIs. | |
| 1608 if (accessibility_mode() & AccessibilityModeFlagPlatform) { | 1637 if (accessibility_mode() & AccessibilityModeFlagPlatform) { |
| 1609 view_->CreateBrowserAccessibilityManagerIfNeeded(); | 1638 view_->CreateBrowserAccessibilityManagerIfNeeded(); |
| 1610 BrowserAccessibilityManager* manager = | 1639 manager = view_->GetBrowserAccessibilityManager(); |
| 1611 view_->GetBrowserAccessibilityManager(); | 1640 if (manager) { |
| 1612 if (manager) | |
| 1613 manager->OnAccessibilityEvents(params); | 1641 manager->OnAccessibilityEvents(params); |
| 1642 FrameTreeAccessibility::GetInstance()->SetFrameAccessibilityManager( | |
| 1643 this, manager); | |
| 1644 } | |
| 1614 } | 1645 } |
| 1615 | 1646 |
| 1647 // Map from guest instance ids (for a <webview> plug-in) and | |
| 1648 // frame routing ids (from out-of-process iframes) to accessibility | |
| 1649 // frame ids. | |
| 1650 std::map<int32, int>::const_iterator iter; | |
| 1651 for (unsigned int i = 0; i < params.size(); ++i) { | |
| 1652 const AccessibilityHostMsg_EventParams& param = params[i]; | |
| 1653 for (iter = param.frame_routing_ids.begin(); | |
| 1654 iter != param.frame_routing_ids.end(); | |
|
ncarter (slow)
2014/05/02 19:10:02
Nothing happens with param.guest_instance_ids here
| |
| 1655 ++iter) { | |
| 1656 int32 node_id = iter->first; | |
| 1657 int frame_routing_id = iter->second; | |
| 1658 int accessible_frame_id = GetAccessibleFrameId( | |
| 1659 GetProcess()->GetID(), frame_routing_id); | |
| 1660 if (manager && accessible_frame_id) | |
| 1661 manager->SetChildFrameId(node_id, accessible_frame_id); | |
| 1662 } | |
| 1663 } | |
| 1664 | |
| 1665 // Send the updates to the automation extension API. | |
| 1616 std::vector<AXEventNotificationDetails> details; | 1666 std::vector<AXEventNotificationDetails> details; |
| 1617 for (unsigned int i = 0; i < params.size(); ++i) { | 1667 for (unsigned int i = 0; i < params.size(); ++i) { |
| 1618 const AccessibilityHostMsg_EventParams& param = params[i]; | 1668 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 1619 AXEventNotificationDetails detail(param.update.nodes, | 1669 AXEventNotificationDetails detail(param.update.nodes, |
| 1620 param.event_type, | 1670 param.event_type, |
| 1621 param.id, | 1671 param.id, |
| 1622 GetProcess()->GetID(), | 1672 GetProcess()->GetID(), |
| 1623 GetRoutingID()); | 1673 GetRoutingID()); |
| 1624 details.push_back(detail); | 1674 details.push_back(detail); |
| 1625 } | 1675 } |
| 1626 | |
| 1627 delegate_->AccessibilityEventReceived(details); | 1676 delegate_->AccessibilityEventReceived(details); |
| 1628 } | 1677 } |
| 1629 | 1678 |
| 1630 // Always send an ACK or the renderer can be in a bad state. | 1679 // Always send an ACK or the renderer can be in a bad state. |
| 1631 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); | 1680 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); |
| 1632 | 1681 |
| 1633 // The rest of this code is just for testing; bail out if we're not | 1682 // The rest of this code is just for testing; bail out if we're not |
| 1634 // in that mode. | 1683 // in that mode. |
| 1635 if (accessibility_testing_callback_.is_null()) | 1684 if (accessibility_testing_callback_.is_null()) |
| 1636 return; | 1685 return; |
| 1637 | 1686 |
| 1638 for (unsigned i = 0; i < params.size(); i++) { | 1687 for (unsigned i = 0; i < params.size(); i++) { |
| 1639 const AccessibilityHostMsg_EventParams& param = params[i]; | 1688 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 1640 if (static_cast<int>(param.event_type) < 0) | 1689 if (static_cast<int>(param.event_type) < 0) |
| 1641 continue; | 1690 continue; |
| 1642 if (!ax_tree_) | 1691 if (!ax_tree_) { |
| 1643 ax_tree_.reset(new ui::AXTree(param.update)); | 1692 if (manager) { |
| 1644 else | 1693 ax_tree_.reset(new ui::AXTree(manager->SnapshotAXTreeForTesting())); |
|
ncarter (slow)
2014/05/02 19:10:02
What prevents this ForTesting() path from becoming
| |
| 1694 } else { | |
| 1695 ax_tree_.reset(new ui::AXTree()); | |
| 1696 CHECK(ax_tree_->Unserialize(param.update)) << ax_tree_->error(); | |
| 1697 } | |
| 1698 } else { | |
| 1645 CHECK(ax_tree_->Unserialize(param.update)) << ax_tree_->error(); | 1699 CHECK(ax_tree_->Unserialize(param.update)) << ax_tree_->error(); |
| 1700 } | |
| 1646 accessibility_testing_callback_.Run(param.event_type); | 1701 accessibility_testing_callback_.Run(param.event_type); |
| 1647 } | 1702 } |
| 1648 } | 1703 } |
| 1649 | 1704 |
| 1650 void RenderViewHostImpl::OnAccessibilityLocationChanges( | 1705 void RenderViewHostImpl::OnAccessibilityLocationChanges( |
| 1651 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 1706 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
| 1652 if (view_ && IsRVHStateActive(rvh_state_)) { | 1707 if (view_ && IsRVHStateActive(rvh_state_)) { |
| 1653 if (accessibility_mode() & AccessibilityModeFlagPlatform) { | 1708 if (accessibility_mode() & AccessibilityModeFlagPlatform) { |
| 1654 view_->CreateBrowserAccessibilityManagerIfNeeded(); | 1709 view_->CreateBrowserAccessibilityManagerIfNeeded(); |
| 1655 BrowserAccessibilityManager* manager = | 1710 BrowserAccessibilityManager* manager = |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1747 return true; | 1802 return true; |
| 1748 } | 1803 } |
| 1749 | 1804 |
| 1750 void RenderViewHostImpl::AttachToFrameTree() { | 1805 void RenderViewHostImpl::AttachToFrameTree() { |
| 1751 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1806 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 1752 | 1807 |
| 1753 frame_tree->ResetForMainFrameSwap(); | 1808 frame_tree->ResetForMainFrameSwap(); |
| 1754 } | 1809 } |
| 1755 | 1810 |
| 1756 } // namespace content | 1811 } // namespace content |
| OLD | NEW |