| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_widget_host.h" | 5 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" |
| 8 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 9 #include "base/keyboard_codes.h" | 10 #include "base/keyboard_codes.h" |
| 10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 11 #include "chrome/browser/chrome_thread.h" | 12 #include "chrome/browser/chrome_thread.h" |
| 12 #include "chrome/browser/renderer_host/backing_store.h" | 13 #include "chrome/browser/renderer_host/backing_store.h" |
| 13 #include "chrome/browser/renderer_host/backing_store_manager.h" | 14 #include "chrome/browser/renderer_host/backing_store_manager.h" |
| 14 #include "chrome/browser/renderer_host/render_process_host.h" | 15 #include "chrome/browser/renderer_host/render_process_host.h" |
| 15 #include "chrome/browser/renderer_host/render_widget_helper.h" | 16 #include "chrome/browser/renderer_host/render_widget_helper.h" |
| 16 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" | 17 #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" |
| 17 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 18 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 18 #include "chrome/browser/renderer_host/video_layer.h" | 19 #include "chrome/browser/renderer_host/video_layer.h" |
| 20 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/notification_service.h" | 21 #include "chrome/common/notification_service.h" |
| 20 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
| 21 #include "webkit/glue/webcursor.h" | 23 #include "webkit/glue/webcursor.h" |
| 22 | 24 |
| 23 #if defined(TOOLKIT_VIEWS) | 25 #if defined(TOOLKIT_VIEWS) |
| 24 #include "views/view.h" | 26 #include "views/view.h" |
| 25 #endif | 27 #endif |
| 26 | 28 |
| 27 #if defined (OS_MACOSX) | 29 #if defined (OS_MACOSX) |
| 28 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" | 30 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 51 static const int kPaintMsgTimeoutMS = 40; | 53 static const int kPaintMsgTimeoutMS = 40; |
| 52 | 54 |
| 53 // How long to wait before we consider a renderer hung. | 55 // How long to wait before we consider a renderer hung. |
| 54 static const int kHungRendererDelayMs = 20000; | 56 static const int kHungRendererDelayMs = 20000; |
| 55 | 57 |
| 56 // The maximum time between wheel messages while coalescing. This trades off | 58 // The maximum time between wheel messages while coalescing. This trades off |
| 57 // smoothness of scrolling with a risk of falling behind the events, resulting | 59 // smoothness of scrolling with a risk of falling behind the events, resulting |
| 58 // in trailing scrolls after the user ends their input. | 60 // in trailing scrolls after the user ends their input. |
| 59 static const int kMaxTimeBetweenWheelMessagesMs = 250; | 61 static const int kMaxTimeBetweenWheelMessagesMs = 250; |
| 60 | 62 |
| 63 // static |
| 64 bool RenderWidgetHost::renderer_accessible_ = false; |
| 65 |
| 61 /////////////////////////////////////////////////////////////////////////////// | 66 /////////////////////////////////////////////////////////////////////////////// |
| 62 // RenderWidgetHost | 67 // RenderWidgetHost |
| 63 | 68 |
| 64 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, | 69 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, |
| 65 int routing_id) | 70 int routing_id) |
| 66 : renderer_initialized_(false), | 71 : renderer_initialized_(false), |
| 67 view_(NULL), | 72 view_(NULL), |
| 68 process_(process), | 73 process_(process), |
| 69 painting_observer_(NULL), | 74 painting_observer_(NULL), |
| 70 routing_id_(routing_id), | 75 routing_id_(routing_id), |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 } | 1109 } |
| 1105 | 1110 |
| 1106 void RenderWidgetHost::AdvanceToNextMisspelling() { | 1111 void RenderWidgetHost::AdvanceToNextMisspelling() { |
| 1107 Send(new ViewMsg_AdvanceToNextMisspelling(routing_id_)); | 1112 Send(new ViewMsg_AdvanceToNextMisspelling(routing_id_)); |
| 1108 } | 1113 } |
| 1109 | 1114 |
| 1110 void RenderWidgetHost::RequestAccessibilityTree() { | 1115 void RenderWidgetHost::RequestAccessibilityTree() { |
| 1111 Send(new ViewMsg_GetAccessibilityTree(routing_id())); | 1116 Send(new ViewMsg_GetAccessibilityTree(routing_id())); |
| 1112 } | 1117 } |
| 1113 | 1118 |
| 1119 void RenderWidgetHost::SetDocumentLoaded(bool document_loaded) { |
| 1120 document_loaded_ = document_loaded; |
| 1121 |
| 1122 if (!document_loaded_) |
| 1123 requested_accessibility_tree_ = false; |
| 1124 |
| 1125 if (renderer_accessible_ && document_loaded_) { |
| 1126 RequestAccessibilityTree(); |
| 1127 requested_accessibility_tree_ = true; |
| 1128 } |
| 1129 } |
| 1130 |
| 1131 void RenderWidgetHost::EnableRendererAccessibility() { |
| 1132 if (renderer_accessible_) |
| 1133 return; |
| 1134 |
| 1135 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1136 switches::kDisableRendererAccessibility)) { |
| 1137 return; |
| 1138 } |
| 1139 |
| 1140 renderer_accessible_ = true; |
| 1141 |
| 1142 if (document_loaded_ && !requested_accessibility_tree_) { |
| 1143 RequestAccessibilityTree(); |
| 1144 requested_accessibility_tree_ = true; |
| 1145 } |
| 1146 } |
| 1147 |
| 1114 void RenderWidgetHost::SetAccessibilityFocus(int acc_obj_id) { | 1148 void RenderWidgetHost::SetAccessibilityFocus(int acc_obj_id) { |
| 1115 Send(new ViewMsg_SetAccessibilityFocus(routing_id(), acc_obj_id)); | 1149 Send(new ViewMsg_SetAccessibilityFocus(routing_id(), acc_obj_id)); |
| 1116 } | 1150 } |
| 1117 | 1151 |
| 1118 void RenderWidgetHost::AccessibilityDoDefaultAction(int acc_obj_id) { | 1152 void RenderWidgetHost::AccessibilityDoDefaultAction(int acc_obj_id) { |
| 1119 Send(new ViewMsg_AccessibilityDoDefaultAction(routing_id(), acc_obj_id)); | 1153 Send(new ViewMsg_AccessibilityDoDefaultAction(routing_id(), acc_obj_id)); |
| 1120 } | 1154 } |
| 1121 | 1155 |
| 1122 void RenderWidgetHost::ProcessKeyboardEventAck(int type, bool processed) { | 1156 void RenderWidgetHost::ProcessKeyboardEventAck(int type, bool processed) { |
| 1123 if (key_queue_.size() == 0) { | 1157 if (key_queue_.size() == 0) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1141 // of this key event. | 1175 // of this key event. |
| 1142 if (!processed && !is_hidden_ && !front_item.skip_in_browser) { | 1176 if (!processed && !is_hidden_ && !front_item.skip_in_browser) { |
| 1143 UnhandledKeyboardEvent(front_item); | 1177 UnhandledKeyboardEvent(front_item); |
| 1144 | 1178 |
| 1145 // WARNING: This RenderWidgetHost can be deallocated at this point | 1179 // WARNING: This RenderWidgetHost can be deallocated at this point |
| 1146 // (i.e. in the case of Ctrl+W, where the call to | 1180 // (i.e. in the case of Ctrl+W, where the call to |
| 1147 // UnhandledKeyboardEvent destroys this RenderWidgetHost). | 1181 // UnhandledKeyboardEvent destroys this RenderWidgetHost). |
| 1148 } | 1182 } |
| 1149 } | 1183 } |
| 1150 } | 1184 } |
| OLD | NEW |