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