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