| 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/speech_recognition_messages.h" | 49 #include "content/common/speech_recognition_messages.h" |
| 52 #include "content/common/swapped_out_messages.h" | 50 #include "content/common/swapped_out_messages.h" |
| 53 #include "content/common/view_messages.h" | 51 #include "content/common/view_messages.h" |
| 54 #include "content/public/browser/ax_event_notification_details.h" | 52 #include "content/public/browser/ax_event_notification_details.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 #include "content/public/common/content_switches.h" | 67 #include "content/public/common/content_switches.h" |
| 70 #include "content/public/common/context_menu_params.h" | 68 #include "content/public/common/context_menu_params.h" |
| 71 #include "content/public/common/drop_data.h" | 69 #include "content/public/common/drop_data.h" |
| 72 #include "content/public/common/result_codes.h" | 70 #include "content/public/common/result_codes.h" |
| 73 #include "content/public/common/url_utils.h" | 71 #include "content/public/common/url_utils.h" |
| 74 #include "net/base/filename_util.h" | 72 #include "net/base/filename_util.h" |
| 75 #include "net/base/net_util.h" | 73 #include "net/base/net_util.h" |
| 76 #include "net/base/network_change_notifier.h" | 74 #include "net/base/network_change_notifier.h" |
| 77 #include "net/url_request/url_request_context_getter.h" | 75 #include "net/url_request/url_request_context_getter.h" |
| 78 #include "third_party/skia/include/core/SkBitmap.h" | 76 #include "third_party/skia/include/core/SkBitmap.h" |
| 79 #include "ui/accessibility/ax_tree.h" | |
| 80 #include "ui/base/touch/touch_device.h" | 77 #include "ui/base/touch/touch_device.h" |
| 81 #include "ui/base/touch/touch_enabled.h" | 78 #include "ui/base/touch/touch_enabled.h" |
| 82 #include "ui/base/ui_base_switches.h" | 79 #include "ui/base/ui_base_switches.h" |
| 83 #include "ui/gfx/image/image_skia.h" | 80 #include "ui/gfx/image/image_skia.h" |
| 84 #include "ui/gfx/native_widget_types.h" | 81 #include "ui/gfx/native_widget_types.h" |
| 85 #include "ui/native_theme/native_theme_switches.h" | 82 #include "ui/native_theme/native_theme_switches.h" |
| 86 #include "ui/shell_dialogs/selected_file_info.h" | 83 #include "ui/shell_dialogs/selected_file_info.h" |
| 87 #include "url/url_constants.h" | 84 #include "url/url_constants.h" |
| 88 #include "webkit/browser/fileapi/isolated_context.h" | 85 #include "webkit/browser/fileapi/isolated_context.h" |
| 89 | 86 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 params.frame_name = frame_name; | 298 params.frame_name = frame_name; |
| 302 // Ensure the RenderView sets its opener correctly. | 299 // Ensure the RenderView sets its opener correctly. |
| 303 params.opener_route_id = opener_route_id; | 300 params.opener_route_id = opener_route_id; |
| 304 params.swapped_out = !IsRVHStateActive(rvh_state_); | 301 params.swapped_out = !IsRVHStateActive(rvh_state_); |
| 305 params.proxy_routing_id = proxy_route_id; | 302 params.proxy_routing_id = proxy_route_id; |
| 306 params.hidden = is_hidden(); | 303 params.hidden = is_hidden(); |
| 307 params.never_visible = delegate_->IsNeverVisible(); | 304 params.never_visible = delegate_->IsNeverVisible(); |
| 308 params.window_was_created_with_opener = window_was_created_with_opener; | 305 params.window_was_created_with_opener = window_was_created_with_opener; |
| 309 params.next_page_id = next_page_id; | 306 params.next_page_id = next_page_id; |
| 310 GetWebScreenInfo(¶ms.screen_info); | 307 GetWebScreenInfo(¶ms.screen_info); |
| 311 params.accessibility_mode = accessibility_mode(); | |
| 312 | 308 |
| 313 Send(new ViewMsg_New(params)); | 309 Send(new ViewMsg_New(params)); |
| 314 | 310 |
| 315 // If it's enabled, tell the renderer to set up the Javascript bindings for | 311 // If it's enabled, tell the renderer to set up the Javascript bindings for |
| 316 // sending messages back to the browser. | 312 // sending messages back to the browser. |
| 317 if (GetProcess()->IsIsolatedGuest()) | 313 if (GetProcess()->IsIsolatedGuest()) |
| 318 DCHECK_EQ(0, enabled_bindings_); | 314 DCHECK_EQ(0, enabled_bindings_); |
| 319 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); | 315 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); |
| 320 // Let our delegate know that we created a RenderView. | 316 // Let our delegate know that we created a RenderView. |
| 321 delegate_->RenderViewCreated(this); | 317 delegate_->RenderViewCreated(this); |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) | 964 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) |
| 969 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 965 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| 970 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | 966 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) |
| 971 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 967 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) |
| 972 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) | 968 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
| 973 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 969 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 974 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) | 970 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) |
| 975 IPC_MESSAGE_HANDLER(ViewHostMsg_HidePopup, OnHidePopup) | 971 IPC_MESSAGE_HANDLER(ViewHostMsg_HidePopup, OnHidePopup) |
| 976 #endif | 972 #endif |
| 977 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) | 973 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) |
| 978 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) | |
| 979 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | |
| 980 OnAccessibilityLocationChanges) | |
| 981 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) | 974 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) |
| 982 // Have the super handle all other messages. | 975 // Have the super handle all other messages. |
| 983 IPC_MESSAGE_UNHANDLED( | 976 IPC_MESSAGE_UNHANDLED( |
| 984 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) | 977 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) |
| 985 IPC_END_MESSAGE_MAP() | 978 IPC_END_MESSAGE_MAP() |
| 986 | 979 |
| 987 return handled; | 980 return handled; |
| 988 } | 981 } |
| 989 | 982 |
| 990 void RenderViewHostImpl::Init() { | 983 void RenderViewHostImpl::Init() { |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 return *web_preferences_; | 1424 return *web_preferences_; |
| 1432 } | 1425 } |
| 1433 | 1426 |
| 1434 void RenderViewHostImpl::DisownOpener() { | 1427 void RenderViewHostImpl::DisownOpener() { |
| 1435 // This should only be called when swapped out. | 1428 // This should only be called when swapped out. |
| 1436 DCHECK(IsSwappedOut()); | 1429 DCHECK(IsSwappedOut()); |
| 1437 | 1430 |
| 1438 Send(new ViewMsg_DisownOpener(GetRoutingID())); | 1431 Send(new ViewMsg_DisownOpener(GetRoutingID())); |
| 1439 } | 1432 } |
| 1440 | 1433 |
| 1441 void RenderViewHostImpl::SetAccessibilityCallbackForTesting( | |
| 1442 const base::Callback<void(ui::AXEvent, int)>& callback) { | |
| 1443 accessibility_testing_callback_ = callback; | |
| 1444 } | |
| 1445 | |
| 1446 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { | 1434 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { |
| 1447 web_preferences_.reset(new WebPreferences(prefs)); | 1435 web_preferences_.reset(new WebPreferences(prefs)); |
| 1448 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); | 1436 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); |
| 1449 } | 1437 } |
| 1450 | 1438 |
| 1451 void RenderViewHostImpl::OnWebkitPreferencesChanged() { | 1439 void RenderViewHostImpl::OnWebkitPreferencesChanged() { |
| 1452 UpdateWebkitPreferences(delegate_->ComputeWebkitPrefs()); | 1440 UpdateWebkitPreferences(delegate_->ComputeWebkitPrefs()); |
| 1453 } | 1441 } |
| 1454 | 1442 |
| 1455 void RenderViewHostImpl::GetAudioOutputControllers( | 1443 void RenderViewHostImpl::GetAudioOutputControllers( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 | 1494 |
| 1507 void RenderViewHostImpl::ExecutePluginActionAtLocation( | 1495 void RenderViewHostImpl::ExecutePluginActionAtLocation( |
| 1508 const gfx::Point& location, const blink::WebPluginAction& action) { | 1496 const gfx::Point& location, const blink::WebPluginAction& action) { |
| 1509 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); | 1497 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); |
| 1510 } | 1498 } |
| 1511 | 1499 |
| 1512 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { | 1500 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { |
| 1513 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); | 1501 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); |
| 1514 } | 1502 } |
| 1515 | 1503 |
| 1516 void RenderViewHostImpl::OnAccessibilityEvents( | |
| 1517 const std::vector<AccessibilityHostMsg_EventParams>& params) { | |
| 1518 if ((accessibility_mode() != AccessibilityModeOff) && view_ && | |
| 1519 IsRVHStateActive(rvh_state_)) { | |
| 1520 if (accessibility_mode() & AccessibilityModeFlagPlatform) { | |
| 1521 view_->CreateBrowserAccessibilityManagerIfNeeded(); | |
| 1522 BrowserAccessibilityManager* manager = | |
| 1523 view_->GetBrowserAccessibilityManager(); | |
| 1524 if (manager) | |
| 1525 manager->OnAccessibilityEvents(params); | |
| 1526 } | |
| 1527 | |
| 1528 std::vector<AXEventNotificationDetails> details; | |
| 1529 for (unsigned int i = 0; i < params.size(); ++i) { | |
| 1530 const AccessibilityHostMsg_EventParams& param = params[i]; | |
| 1531 AXEventNotificationDetails detail(param.update.node_id_to_clear, | |
| 1532 param.update.nodes, | |
| 1533 param.event_type, | |
| 1534 param.id, | |
| 1535 GetProcess()->GetID(), | |
| 1536 GetRoutingID()); | |
| 1537 details.push_back(detail); | |
| 1538 } | |
| 1539 | |
| 1540 delegate_->AccessibilityEventReceived(details); | |
| 1541 } | |
| 1542 | |
| 1543 // Always send an ACK or the renderer can be in a bad state. | |
| 1544 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); | |
| 1545 | |
| 1546 // The rest of this code is just for testing; bail out if we're not | |
| 1547 // in that mode. | |
| 1548 if (accessibility_testing_callback_.is_null()) | |
| 1549 return; | |
| 1550 | |
| 1551 for (unsigned i = 0; i < params.size(); i++) { | |
| 1552 const AccessibilityHostMsg_EventParams& param = params[i]; | |
| 1553 if (static_cast<int>(param.event_type) < 0) | |
| 1554 continue; | |
| 1555 if (!ax_tree_) | |
| 1556 ax_tree_.reset(new ui::AXTree(param.update)); | |
| 1557 else | |
| 1558 CHECK(ax_tree_->Unserialize(param.update)) << ax_tree_->error(); | |
| 1559 accessibility_testing_callback_.Run(param.event_type, param.id); | |
| 1560 } | |
| 1561 } | |
| 1562 | |
| 1563 void RenderViewHostImpl::OnAccessibilityLocationChanges( | |
| 1564 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | |
| 1565 if (view_ && IsRVHStateActive(rvh_state_)) { | |
| 1566 if (accessibility_mode() & AccessibilityModeFlagPlatform) { | |
| 1567 view_->CreateBrowserAccessibilityManagerIfNeeded(); | |
| 1568 BrowserAccessibilityManager* manager = | |
| 1569 view_->GetBrowserAccessibilityManager(); | |
| 1570 if (manager) | |
| 1571 manager->OnLocationChanges(params); | |
| 1572 } | |
| 1573 // TODO(aboxhall): send location change events to web contents observers too | |
| 1574 } | |
| 1575 } | |
| 1576 | |
| 1577 void RenderViewHostImpl::OnDidZoomURL(double zoom_level, | 1504 void RenderViewHostImpl::OnDidZoomURL(double zoom_level, |
| 1578 const GURL& url) { | 1505 const GURL& url) { |
| 1579 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( | 1506 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( |
| 1580 HostZoomMap::GetForBrowserContext(GetProcess()->GetBrowserContext())); | 1507 HostZoomMap::GetForBrowserContext(GetProcess()->GetBrowserContext())); |
| 1581 | 1508 |
| 1582 host_zoom_map->SetZoomLevelForView(GetProcess()->GetID(), | 1509 host_zoom_map->SetZoomLevelForView(GetProcess()->GetID(), |
| 1583 GetRoutingID(), | 1510 GetRoutingID(), |
| 1584 zoom_level, | 1511 zoom_level, |
| 1585 net::GetHostOrSpecFromURL(url)); | 1512 net::GetHostOrSpecFromURL(url)); |
| 1586 } | 1513 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1661 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1588 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 1662 | 1589 |
| 1663 frame_tree->ResetForMainFrameSwap(); | 1590 frame_tree->ResetForMainFrameSwap(); |
| 1664 } | 1591 } |
| 1665 | 1592 |
| 1666 void RenderViewHostImpl::SelectWordAroundCaret() { | 1593 void RenderViewHostImpl::SelectWordAroundCaret() { |
| 1667 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1594 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
| 1668 } | 1595 } |
| 1669 | 1596 |
| 1670 } // namespace content | 1597 } // namespace content |
| OLD | NEW |