| 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" | |
| 27 #include "content/browser/child_process_security_policy_impl.h" | 26 #include "content/browser/child_process_security_policy_impl.h" |
| 28 #include "content/browser/cross_site_request_manager.h" | 27 #include "content/browser/cross_site_request_manager.h" |
| 29 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 28 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 30 #include "content/browser/frame_host/frame_tree.h" | 29 #include "content/browser/frame_host/frame_tree.h" |
| 31 #include "content/browser/gpu/compositor_util.h" | 30 #include "content/browser/gpu/compositor_util.h" |
| 32 #include "content/browser/gpu/gpu_data_manager_impl.h" | 31 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 33 #include "content/browser/gpu/gpu_process_host.h" | 32 #include "content/browser/gpu/gpu_process_host.h" |
| 34 #include "content/browser/gpu/gpu_surface_tracker.h" | 33 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 35 #include "content/browser/host_zoom_map_impl.h" | 34 #include "content/browser/host_zoom_map_impl.h" |
| 36 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 35 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 37 #include "content/browser/renderer_host/dip_util.h" | 36 #include "content/browser/renderer_host/dip_util.h" |
| 38 #include "content/browser/renderer_host/input/timeout_monitor.h" | 37 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 39 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 38 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 40 #include "content/browser/renderer_host/render_process_host_impl.h" | 39 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 41 #include "content/browser/renderer_host/render_view_host_delegate.h" | 40 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 42 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 41 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 43 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 42 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 44 #include "content/common/accessibility_messages.h" | |
| 45 #include "content/common/browser_plugin/browser_plugin_messages.h" | 43 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 46 #include "content/common/content_switches_internal.h" | 44 #include "content/common/content_switches_internal.h" |
| 47 #include "content/common/drag_messages.h" | 45 #include "content/common/drag_messages.h" |
| 48 #include "content/common/frame_messages.h" | 46 #include "content/common/frame_messages.h" |
| 49 #include "content/common/input_messages.h" | 47 #include "content/common/input_messages.h" |
| 50 #include "content/common/inter_process_time_ticks_converter.h" | 48 #include "content/common/inter_process_time_ticks_converter.h" |
| 51 #include "content/common/mojo/mojo_service_names.h" | 49 #include "content/common/mojo/mojo_service_names.h" |
| 52 #include "content/common/speech_recognition_messages.h" | 50 #include "content/common/speech_recognition_messages.h" |
| 53 #include "content/common/swapped_out_messages.h" | 51 #include "content/common/swapped_out_messages.h" |
| 54 #include "content/common/view_messages.h" | 52 #include "content/common/view_messages.h" |
| 55 #include "content/common/web_ui_setup.mojom.h" | 53 #include "content/common/web_ui_setup.mojom.h" |
| 56 #include "content/public/browser/ax_event_notification_details.h" | |
| 57 #include "content/public/browser/browser_accessibility_state.h" | |
| 58 #include "content/public/browser/browser_context.h" | 54 #include "content/public/browser/browser_context.h" |
| 59 #include "content/public/browser/browser_message_filter.h" | 55 #include "content/public/browser/browser_message_filter.h" |
| 60 #include "content/public/browser/content_browser_client.h" | 56 #include "content/public/browser/content_browser_client.h" |
| 61 #include "content/public/browser/native_web_keyboard_event.h" | 57 #include "content/public/browser/native_web_keyboard_event.h" |
| 62 #include "content/public/browser/notification_details.h" | 58 #include "content/public/browser/notification_details.h" |
| 63 #include "content/public/browser/notification_service.h" | 59 #include "content/public/browser/notification_service.h" |
| 64 #include "content/public/browser/notification_types.h" | 60 #include "content/public/browser/notification_types.h" |
| 65 #include "content/public/browser/render_frame_host.h" | 61 #include "content/public/browser/render_frame_host.h" |
| 66 #include "content/public/browser/render_widget_host_iterator.h" | 62 #include "content/public/browser/render_widget_host_iterator.h" |
| 67 #include "content/public/browser/storage_partition.h" | 63 #include "content/public/browser/storage_partition.h" |
| 68 #include "content/public/browser/user_metrics.h" | 64 #include "content/public/browser/user_metrics.h" |
| 69 #include "content/public/common/bindings_policy.h" | 65 #include "content/public/common/bindings_policy.h" |
| 70 #include "content/public/common/content_constants.h" | 66 #include "content/public/common/content_constants.h" |
| 71 #include "content/public/common/content_switches.h" | 67 #include "content/public/common/content_switches.h" |
| 72 #include "content/public/common/context_menu_params.h" | 68 #include "content/public/common/context_menu_params.h" |
| 73 #include "content/public/common/drop_data.h" | 69 #include "content/public/common/drop_data.h" |
| 74 #include "content/public/common/result_codes.h" | 70 #include "content/public/common/result_codes.h" |
| 75 #include "content/public/common/url_constants.h" | 71 #include "content/public/common/url_constants.h" |
| 76 #include "content/public/common/url_utils.h" | 72 #include "content/public/common/url_utils.h" |
| 77 #include "net/base/filename_util.h" | 73 #include "net/base/filename_util.h" |
| 78 #include "net/base/net_util.h" | 74 #include "net/base/net_util.h" |
| 79 #include "net/base/network_change_notifier.h" | 75 #include "net/base/network_change_notifier.h" |
| 80 #include "net/url_request/url_request_context_getter.h" | 76 #include "net/url_request/url_request_context_getter.h" |
| 81 #include "third_party/skia/include/core/SkBitmap.h" | 77 #include "third_party/skia/include/core/SkBitmap.h" |
| 82 #include "ui/accessibility/ax_tree.h" | |
| 83 #include "ui/base/touch/touch_device.h" | 78 #include "ui/base/touch/touch_device.h" |
| 84 #include "ui/base/touch/touch_enabled.h" | 79 #include "ui/base/touch/touch_enabled.h" |
| 85 #include "ui/base/ui_base_switches.h" | 80 #include "ui/base/ui_base_switches.h" |
| 86 #include "ui/gfx/image/image_skia.h" | 81 #include "ui/gfx/image/image_skia.h" |
| 87 #include "ui/gfx/native_widget_types.h" | 82 #include "ui/gfx/native_widget_types.h" |
| 88 #include "ui/native_theme/native_theme_switches.h" | 83 #include "ui/native_theme/native_theme_switches.h" |
| 89 #include "ui/shell_dialogs/selected_file_info.h" | 84 #include "ui/shell_dialogs/selected_file_info.h" |
| 90 #include "webkit/browser/fileapi/isolated_context.h" | 85 #include "webkit/browser/fileapi/isolated_context.h" |
| 91 | 86 |
| 92 #if defined(OS_MACOSX) | 87 #if defined(OS_MACOSX) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 delegate_->GetSessionStorageNamespace(instance_)->id(); | 294 delegate_->GetSessionStorageNamespace(instance_)->id(); |
| 300 params.frame_name = frame_name; | 295 params.frame_name = frame_name; |
| 301 // Ensure the RenderView sets its opener correctly. | 296 // Ensure the RenderView sets its opener correctly. |
| 302 params.opener_route_id = opener_route_id; | 297 params.opener_route_id = opener_route_id; |
| 303 params.swapped_out = !IsRVHStateActive(rvh_state_); | 298 params.swapped_out = !IsRVHStateActive(rvh_state_); |
| 304 params.hidden = is_hidden(); | 299 params.hidden = is_hidden(); |
| 305 params.never_visible = delegate_->IsNeverVisible(); | 300 params.never_visible = delegate_->IsNeverVisible(); |
| 306 params.window_was_created_with_opener = window_was_created_with_opener; | 301 params.window_was_created_with_opener = window_was_created_with_opener; |
| 307 params.next_page_id = next_page_id; | 302 params.next_page_id = next_page_id; |
| 308 GetWebScreenInfo(¶ms.screen_info); | 303 GetWebScreenInfo(¶ms.screen_info); |
| 309 params.accessibility_mode = accessibility_mode(); | |
| 310 | 304 |
| 311 Send(new ViewMsg_New(params)); | 305 Send(new ViewMsg_New(params)); |
| 312 | 306 |
| 313 // If it's enabled, tell the renderer to set up the Javascript bindings for | 307 // If it's enabled, tell the renderer to set up the Javascript bindings for |
| 314 // sending messages back to the browser. | 308 // sending messages back to the browser. |
| 315 if (GetProcess()->IsGuest()) | 309 if (GetProcess()->IsGuest()) |
| 316 DCHECK_EQ(0, enabled_bindings_); | 310 DCHECK_EQ(0, enabled_bindings_); |
| 317 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); | 311 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); |
| 318 // Let our delegate know that we created a RenderView. | 312 // Let our delegate know that we created a RenderView. |
| 319 delegate_->RenderViewCreated(this); | 313 delegate_->RenderViewCreated(this); |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 #if defined(OS_ANDROID) | 1003 #if defined(OS_ANDROID) |
| 1010 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionRootBoundsChanged, | 1004 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionRootBoundsChanged, |
| 1011 OnSelectionRootBoundsChanged) | 1005 OnSelectionRootBoundsChanged) |
| 1012 #endif | 1006 #endif |
| 1013 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) | 1007 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
| 1014 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 1008 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 1015 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) | 1009 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) |
| 1016 IPC_MESSAGE_HANDLER(ViewHostMsg_HidePopup, OnHidePopup) | 1010 IPC_MESSAGE_HANDLER(ViewHostMsg_HidePopup, OnHidePopup) |
| 1017 #endif | 1011 #endif |
| 1018 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) | 1012 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) |
| 1019 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) | |
| 1020 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | |
| 1021 OnAccessibilityLocationChanges) | |
| 1022 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) | 1013 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) |
| 1023 // Have the super handle all other messages. | 1014 // Have the super handle all other messages. |
| 1024 IPC_MESSAGE_UNHANDLED( | 1015 IPC_MESSAGE_UNHANDLED( |
| 1025 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) | 1016 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) |
| 1026 IPC_END_MESSAGE_MAP_EX() | 1017 IPC_END_MESSAGE_MAP_EX() |
| 1027 | 1018 |
| 1028 if (!msg_is_ok) { | 1019 if (!msg_is_ok) { |
| 1029 // The message had a handler, but its de-serialization failed. | 1020 // The message had a handler, but its de-serialization failed. |
| 1030 // Kill the renderer. | 1021 // Kill the renderer. |
| 1031 RecordAction(base::UserMetricsAction("BadMessageTerminate_RVH")); | 1022 RecordAction(base::UserMetricsAction("BadMessageTerminate_RVH")); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 return delegate_->GetWebkitPrefs(); | 1461 return delegate_->GetWebkitPrefs(); |
| 1471 } | 1462 } |
| 1472 | 1463 |
| 1473 void RenderViewHostImpl::DisownOpener() { | 1464 void RenderViewHostImpl::DisownOpener() { |
| 1474 // This should only be called when swapped out. | 1465 // This should only be called when swapped out. |
| 1475 DCHECK(IsSwappedOut()); | 1466 DCHECK(IsSwappedOut()); |
| 1476 | 1467 |
| 1477 Send(new ViewMsg_DisownOpener(GetRoutingID())); | 1468 Send(new ViewMsg_DisownOpener(GetRoutingID())); |
| 1478 } | 1469 } |
| 1479 | 1470 |
| 1480 void RenderViewHostImpl::SetAccessibilityCallbackForTesting( | |
| 1481 const base::Callback<void(ui::AXEvent)>& callback) { | |
| 1482 accessibility_testing_callback_ = callback; | |
| 1483 } | |
| 1484 | |
| 1485 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { | 1471 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { |
| 1486 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); | 1472 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); |
| 1487 } | 1473 } |
| 1488 | 1474 |
| 1489 void RenderViewHostImpl::GetAudioOutputControllers( | 1475 void RenderViewHostImpl::GetAudioOutputControllers( |
| 1490 const GetAudioOutputControllersCallback& callback) const { | 1476 const GetAudioOutputControllersCallback& callback) const { |
| 1491 AudioRendererHost* audio_host = | 1477 AudioRendererHost* audio_host = |
| 1492 static_cast<RenderProcessHostImpl*>(GetProcess())->audio_renderer_host(); | 1478 static_cast<RenderProcessHostImpl*>(GetProcess())->audio_renderer_host(); |
| 1493 audio_host->GetOutputControllers(GetRoutingID(), callback); | 1479 audio_host->GetOutputControllers(GetRoutingID(), callback); |
| 1494 } | 1480 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 | 1526 |
| 1541 void RenderViewHostImpl::ExecutePluginActionAtLocation( | 1527 void RenderViewHostImpl::ExecutePluginActionAtLocation( |
| 1542 const gfx::Point& location, const blink::WebPluginAction& action) { | 1528 const gfx::Point& location, const blink::WebPluginAction& action) { |
| 1543 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); | 1529 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); |
| 1544 } | 1530 } |
| 1545 | 1531 |
| 1546 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { | 1532 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { |
| 1547 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); | 1533 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); |
| 1548 } | 1534 } |
| 1549 | 1535 |
| 1550 void RenderViewHostImpl::OnAccessibilityEvents( | |
| 1551 const std::vector<AccessibilityHostMsg_EventParams>& params) { | |
| 1552 if ((accessibility_mode() != AccessibilityModeOff) && view_ && | |
| 1553 IsRVHStateActive(rvh_state_)) { | |
| 1554 if (accessibility_mode() & AccessibilityModeFlagPlatform) { | |
| 1555 view_->CreateBrowserAccessibilityManagerIfNeeded(); | |
| 1556 BrowserAccessibilityManager* manager = | |
| 1557 view_->GetBrowserAccessibilityManager(); | |
| 1558 if (manager) | |
| 1559 manager->OnAccessibilityEvents(params); | |
| 1560 } | |
| 1561 | |
| 1562 std::vector<AXEventNotificationDetails> details; | |
| 1563 for (unsigned int i = 0; i < params.size(); ++i) { | |
| 1564 const AccessibilityHostMsg_EventParams& param = params[i]; | |
| 1565 AXEventNotificationDetails detail(param.update.nodes, | |
| 1566 param.event_type, | |
| 1567 param.id, | |
| 1568 GetProcess()->GetID(), | |
| 1569 GetRoutingID()); | |
| 1570 details.push_back(detail); | |
| 1571 } | |
| 1572 | |
| 1573 delegate_->AccessibilityEventReceived(details); | |
| 1574 } | |
| 1575 | |
| 1576 // Always send an ACK or the renderer can be in a bad state. | |
| 1577 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); | |
| 1578 | |
| 1579 // The rest of this code is just for testing; bail out if we're not | |
| 1580 // in that mode. | |
| 1581 if (accessibility_testing_callback_.is_null()) | |
| 1582 return; | |
| 1583 | |
| 1584 for (unsigned i = 0; i < params.size(); i++) { | |
| 1585 const AccessibilityHostMsg_EventParams& param = params[i]; | |
| 1586 if (static_cast<int>(param.event_type) < 0) | |
| 1587 continue; | |
| 1588 if (!ax_tree_) | |
| 1589 ax_tree_.reset(new ui::AXTree(param.update)); | |
| 1590 else | |
| 1591 CHECK(ax_tree_->Unserialize(param.update)) << ax_tree_->error(); | |
| 1592 accessibility_testing_callback_.Run(param.event_type); | |
| 1593 } | |
| 1594 } | |
| 1595 | |
| 1596 void RenderViewHostImpl::OnAccessibilityLocationChanges( | |
| 1597 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | |
| 1598 if (view_ && IsRVHStateActive(rvh_state_)) { | |
| 1599 if (accessibility_mode() & AccessibilityModeFlagPlatform) { | |
| 1600 view_->CreateBrowserAccessibilityManagerIfNeeded(); | |
| 1601 BrowserAccessibilityManager* manager = | |
| 1602 view_->GetBrowserAccessibilityManager(); | |
| 1603 if (manager) | |
| 1604 manager->OnLocationChanges(params); | |
| 1605 } | |
| 1606 // TODO(aboxhall): send location change events to web contents observers too | |
| 1607 } | |
| 1608 } | |
| 1609 | |
| 1610 void RenderViewHostImpl::OnDidZoomURL(double zoom_level, | 1536 void RenderViewHostImpl::OnDidZoomURL(double zoom_level, |
| 1611 bool remember, | 1537 bool remember, |
| 1612 const GURL& url) { | 1538 const GURL& url) { |
| 1613 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( | 1539 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( |
| 1614 HostZoomMap::GetForBrowserContext(GetProcess()->GetBrowserContext())); | 1540 HostZoomMap::GetForBrowserContext(GetProcess()->GetBrowserContext())); |
| 1615 if (remember) { | 1541 if (remember) { |
| 1616 host_zoom_map-> | 1542 host_zoom_map-> |
| 1617 SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), zoom_level); | 1543 SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), zoom_level); |
| 1618 } else { | 1544 } else { |
| 1619 host_zoom_map->SetTemporaryZoomLevel( | 1545 host_zoom_map->SetTemporaryZoomLevel( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 return true; | 1619 return true; |
| 1694 } | 1620 } |
| 1695 | 1621 |
| 1696 void RenderViewHostImpl::AttachToFrameTree() { | 1622 void RenderViewHostImpl::AttachToFrameTree() { |
| 1697 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1623 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 1698 | 1624 |
| 1699 frame_tree->ResetForMainFrameSwap(); | 1625 frame_tree->ResetForMainFrameSwap(); |
| 1700 } | 1626 } |
| 1701 | 1627 |
| 1702 } // namespace content | 1628 } // namespace content |
| OLD | NEW |