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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 #include <queue> | 11 #include <queue> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
21 #include "base/process/kill.h" | 21 #include "base/process/kill.h" |
22 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "base/timer/timer.h" | 24 #include "base/timer/timer.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "cc/resources/shared_bitmap.h" | 26 #include "cc/resources/shared_bitmap.h" |
| 27 #include "content/browser/accessibility/browser_accessibility_manager.h" |
27 #include "content/browser/renderer_host/event_with_latency_info.h" | 28 #include "content/browser/renderer_host/event_with_latency_info.h" |
28 #include "content/browser/renderer_host/input/input_ack_handler.h" | 29 #include "content/browser/renderer_host/input/input_ack_handler.h" |
29 #include "content/browser/renderer_host/input/input_router_client.h" | 30 #include "content/browser/renderer_host/input/input_router_client.h" |
30 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 31 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
31 #include "content/browser/renderer_host/input/touch_emulator_client.h" | 32 #include "content/browser/renderer_host/input/touch_emulator_client.h" |
32 #include "content/common/input/input_event_ack_state.h" | 33 #include "content/common/input/input_event_ack_state.h" |
33 #include "content/common/input/synthetic_gesture_packet.h" | 34 #include "content/common/input/synthetic_gesture_packet.h" |
34 #include "content/common/view_message_enums.h" | 35 #include "content/common/view_message_enums.h" |
35 #include "content/public/browser/render_widget_host.h" | 36 #include "content/public/browser/render_widget_host.h" |
36 #include "content/public/common/page_zoom.h" | 37 #include "content/public/common/page_zoom.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 struct WebScreenInfo; | 71 struct WebScreenInfo; |
71 } | 72 } |
72 | 73 |
73 #if defined(OS_ANDROID) | 74 #if defined(OS_ANDROID) |
74 namespace blink { | 75 namespace blink { |
75 class WebLayer; | 76 class WebLayer; |
76 } | 77 } |
77 #endif | 78 #endif |
78 | 79 |
79 namespace content { | 80 namespace content { |
80 class BrowserAccessibilityManager; | |
81 class InputRouter; | 81 class InputRouter; |
82 class MockRenderWidgetHost; | 82 class MockRenderWidgetHost; |
83 class RenderWidgetHostDelegate; | 83 class RenderWidgetHostDelegate; |
84 class RenderWidgetHostViewBase; | 84 class RenderWidgetHostViewBase; |
85 class SyntheticGestureController; | 85 class SyntheticGestureController; |
86 class TimeoutMonitor; | 86 class TimeoutMonitor; |
87 class TouchEmulator; | 87 class TouchEmulator; |
88 class WebCursor; | 88 class WebCursor; |
89 struct EditCommand; | 89 struct EditCommand; |
90 | 90 |
91 // This implements the RenderWidgetHost interface that is exposed to | 91 // This implements the RenderWidgetHost interface that is exposed to |
92 // embedders of content, and adds things only visible to content. | 92 // embedders of content, and adds things only visible to content. |
93 class CONTENT_EXPORT RenderWidgetHostImpl | 93 class CONTENT_EXPORT RenderWidgetHostImpl |
94 : virtual public RenderWidgetHost, | 94 : virtual public RenderWidgetHost, |
95 public InputRouterClient, | 95 public InputRouterClient, |
96 public InputAckHandler, | 96 public InputAckHandler, |
97 public TouchEmulatorClient, | 97 public TouchEmulatorClient, |
98 public IPC::Listener { | 98 public IPC::Listener, |
| 99 public BrowserAccessibilityDelegate { |
99 public: | 100 public: |
100 // routing_id can be MSG_ROUTING_NONE, in which case the next available | 101 // routing_id can be MSG_ROUTING_NONE, in which case the next available |
101 // routing id is taken from the RenderProcessHost. | 102 // routing id is taken from the RenderProcessHost. |
102 // If this object outlives |delegate|, DetachDelegate() must be called when | 103 // If this object outlives |delegate|, DetachDelegate() must be called when |
103 // |delegate| goes away. | 104 // |delegate| goes away. |
104 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 105 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
105 RenderProcessHost* process, | 106 RenderProcessHost* process, |
106 int routing_id, | 107 int routing_id, |
107 bool hidden); | 108 bool hidden); |
108 virtual ~RenderWidgetHostImpl(); | 109 virtual ~RenderWidgetHostImpl(); |
(...skipping 24 matching lines...) Expand all Loading... |
133 virtual void CopyFromBackingStore( | 134 virtual void CopyFromBackingStore( |
134 const gfx::Rect& src_rect, | 135 const gfx::Rect& src_rect, |
135 const gfx::Size& accelerated_dst_size, | 136 const gfx::Size& accelerated_dst_size, |
136 const base::Callback<void(bool, const SkBitmap&)>& callback, | 137 const base::Callback<void(bool, const SkBitmap&)>& callback, |
137 const SkColorType color_type) OVERRIDE; | 138 const SkColorType color_type) OVERRIDE; |
138 virtual bool CanCopyFromBackingStore() OVERRIDE; | 139 virtual bool CanCopyFromBackingStore() OVERRIDE; |
139 #if defined(OS_ANDROID) | 140 #if defined(OS_ANDROID) |
140 virtual void LockBackingStore() OVERRIDE; | 141 virtual void LockBackingStore() OVERRIDE; |
141 virtual void UnlockBackingStore() OVERRIDE; | 142 virtual void UnlockBackingStore() OVERRIDE; |
142 #endif | 143 #endif |
| 144 virtual void EnableFullAccessibilityMode() OVERRIDE; |
| 145 virtual bool IsFullAccessibilityModeForTesting() OVERRIDE; |
| 146 virtual void EnableTreeOnlyAccessibilityMode() OVERRIDE; |
| 147 virtual bool IsTreeOnlyAccessibilityModeForTesting() OVERRIDE; |
143 virtual void ForwardMouseEvent( | 148 virtual void ForwardMouseEvent( |
144 const blink::WebMouseEvent& mouse_event) OVERRIDE; | 149 const blink::WebMouseEvent& mouse_event) OVERRIDE; |
145 virtual void ForwardWheelEvent( | 150 virtual void ForwardWheelEvent( |
146 const blink::WebMouseWheelEvent& wheel_event) OVERRIDE; | 151 const blink::WebMouseWheelEvent& wheel_event) OVERRIDE; |
147 virtual void ForwardKeyboardEvent( | 152 virtual void ForwardKeyboardEvent( |
148 const NativeWebKeyboardEvent& key_event) OVERRIDE; | 153 const NativeWebKeyboardEvent& key_event) OVERRIDE; |
149 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE; | 154 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE; |
150 virtual RenderProcessHost* GetProcess() const OVERRIDE; | 155 virtual RenderProcessHost* GetProcess() const OVERRIDE; |
151 virtual int GetRoutingID() const OVERRIDE; | 156 virtual int GetRoutingID() const OVERRIDE; |
152 virtual RenderWidgetHostView* GetView() const OVERRIDE; | 157 virtual RenderWidgetHostView* GetView() const OVERRIDE; |
153 virtual bool IsLoading() const OVERRIDE; | 158 virtual bool IsLoading() const OVERRIDE; |
154 virtual bool IsRenderView() const OVERRIDE; | 159 virtual bool IsRenderView() const OVERRIDE; |
155 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; | 160 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; |
156 virtual void RestartHangMonitorTimeout() OVERRIDE; | 161 virtual void RestartHangMonitorTimeout() OVERRIDE; |
157 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; | 162 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; |
158 virtual void Stop() OVERRIDE; | 163 virtual void Stop() OVERRIDE; |
159 virtual void WasResized() OVERRIDE; | 164 virtual void WasResized() OVERRIDE; |
160 virtual void AddKeyPressEventCallback( | 165 virtual void AddKeyPressEventCallback( |
161 const KeyPressEventCallback& callback) OVERRIDE; | 166 const KeyPressEventCallback& callback) OVERRIDE; |
162 virtual void RemoveKeyPressEventCallback( | 167 virtual void RemoveKeyPressEventCallback( |
163 const KeyPressEventCallback& callback) OVERRIDE; | 168 const KeyPressEventCallback& callback) OVERRIDE; |
164 virtual void AddMouseEventCallback( | 169 virtual void AddMouseEventCallback( |
165 const MouseEventCallback& callback) OVERRIDE; | 170 const MouseEventCallback& callback) OVERRIDE; |
166 virtual void RemoveMouseEventCallback( | 171 virtual void RemoveMouseEventCallback( |
167 const MouseEventCallback& callback) OVERRIDE; | 172 const MouseEventCallback& callback) OVERRIDE; |
168 virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE; | 173 virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE; |
169 | 174 |
170 virtual SkColorType PreferredReadbackFormat() OVERRIDE; | 175 virtual SkColorType PreferredReadbackFormat() OVERRIDE; |
171 | 176 |
| 177 // BrowserAccessibilityDelegate |
| 178 virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE; |
| 179 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; |
| 180 virtual void AccessibilityShowMenu(int acc_obj_id) OVERRIDE; |
| 181 virtual void AccessibilityScrollToMakeVisible( |
| 182 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; |
| 183 virtual void AccessibilityScrollToPoint( |
| 184 int acc_obj_id, gfx::Point point) OVERRIDE; |
| 185 virtual void AccessibilitySetTextSelection( |
| 186 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; |
| 187 virtual bool AccessibilityViewHasFocus() const OVERRIDE; |
| 188 virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE; |
| 189 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds) |
| 190 const OVERRIDE; |
| 191 virtual void AccessibilityHitTest(const gfx::Point& point) OVERRIDE; |
| 192 virtual void AccessibilityFatalError() OVERRIDE; |
| 193 |
172 // Forces redraw in the renderer and when the update reaches the browser | 194 // Forces redraw in the renderer and when the update reaches the browser |
173 // grabs snapshot from the compositor. Returns PNG-encoded snapshot. | 195 // grabs snapshot from the compositor. Returns PNG-encoded snapshot. |
174 void GetSnapshotFromBrowser( | 196 void GetSnapshotFromBrowser( |
175 const base::Callback<void(const unsigned char*,size_t)> callback); | 197 const base::Callback<void(const unsigned char*,size_t)> callback); |
176 | 198 |
177 const NativeWebKeyboardEvent* GetLastKeyboardEvent() const; | 199 const NativeWebKeyboardEvent* GetLastKeyboardEvent() const; |
178 | 200 |
179 // Notification that the screen info has changed. | 201 // Notification that the screen info has changed. |
180 void NotifyScreenInfoChanged(); | 202 void NotifyScreenInfoChanged(); |
181 | 203 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 void StartUserGesture(); | 388 void StartUserGesture(); |
367 | 389 |
368 // Set the RenderView background transparency. | 390 // Set the RenderView background transparency. |
369 void SetBackgroundOpaque(bool opaque); | 391 void SetBackgroundOpaque(bool opaque); |
370 | 392 |
371 // Notifies the renderer that the next key event is bound to one or more | 393 // Notifies the renderer that the next key event is bound to one or more |
372 // pre-defined edit commands | 394 // pre-defined edit commands |
373 void SetEditCommandsForNextKeyEvent( | 395 void SetEditCommandsForNextKeyEvent( |
374 const std::vector<EditCommand>& commands); | 396 const std::vector<EditCommand>& commands); |
375 | 397 |
| 398 // Gets the accessibility mode. |
| 399 AccessibilityMode accessibility_mode() const { |
| 400 return accessibility_mode_; |
| 401 } |
| 402 |
| 403 // Adds the given accessibility mode to the current accessibility mode bitmap. |
| 404 void AddAccessibilityMode(AccessibilityMode mode); |
| 405 |
| 406 // Removes the given accessibility mode from the current accessibility mode |
| 407 // bitmap, managing the bits that are shared with other modes such that a |
| 408 // bit will only be turned off when all modes that depend on it have been |
| 409 // removed. |
| 410 void RemoveAccessibilityMode(AccessibilityMode mode); |
| 411 |
| 412 // Resets the accessibility mode to the default setting in |
| 413 // BrowserStateAccessibilityImpl. |
| 414 void ResetAccessibilityMode(); |
| 415 |
| 416 #if defined(OS_WIN) |
| 417 void SetParentNativeViewAccessible( |
| 418 gfx::NativeViewAccessible accessible_parent); |
| 419 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; |
| 420 #endif |
| 421 |
376 // Executes the edit command on the RenderView. | 422 // Executes the edit command on the RenderView. |
377 void ExecuteEditCommand(const std::string& command, | 423 void ExecuteEditCommand(const std::string& command, |
378 const std::string& value); | 424 const std::string& value); |
379 | 425 |
380 // Tells the renderer to scroll the currently focused node into rect only if | 426 // Tells the renderer to scroll the currently focused node into rect only if |
381 // the currently focused node is a Text node (textfield, text area or content | 427 // the currently focused node is a Text node (textfield, text area or content |
382 // editable divs). | 428 // editable divs). |
383 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); | 429 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); |
384 | 430 |
385 // Requests the renderer to move the caret selection towards the point. | 431 // Requests the renderer to move the caret selection towards the point. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 gfx::Size snapshot_size, | 513 gfx::Size snapshot_size, |
468 scoped_refptr<base::RefCountedBytes> png_data); | 514 scoped_refptr<base::RefCountedBytes> png_data); |
469 | 515 |
470 // LatencyComponents generated in the renderer must have component IDs | 516 // LatencyComponents generated in the renderer must have component IDs |
471 // provided to them by the browser process. This function adds the correct | 517 // provided to them by the browser process. This function adds the correct |
472 // component ID where necessary. | 518 // component ID where necessary. |
473 void AddLatencyInfoComponentIds(ui::LatencyInfo* latency_info); | 519 void AddLatencyInfoComponentIds(ui::LatencyInfo* latency_info); |
474 | 520 |
475 InputRouter* input_router() { return input_router_.get(); } | 521 InputRouter* input_router() { return input_router_.get(); } |
476 | 522 |
477 // Get the BrowserAccessibilityManager for the root of the frame tree, | |
478 BrowserAccessibilityManager* GetRootBrowserAccessibilityManager(); | |
479 | |
480 // Get the BrowserAccessibilityManager for the root of the frame tree, | |
481 // or create it if it doesn't already exist. | |
482 BrowserAccessibilityManager* GetOrCreateRootBrowserAccessibilityManager(); | |
483 | |
484 #if defined(OS_WIN) | |
485 gfx::NativeViewAccessible GetParentNativeViewAccessible(); | |
486 #endif | |
487 | |
488 protected: | 523 protected: |
489 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE; | 524 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE; |
490 | 525 |
491 // Create a LatencyInfo struct with INPUT_EVENT_LATENCY_RWH_COMPONENT | 526 // Create a LatencyInfo struct with INPUT_EVENT_LATENCY_RWH_COMPONENT |
492 // component if it is not already in |original|. And if |original| is | 527 // component if it is not already in |original|. And if |original| is |
493 // not NULL, it is also merged into the resulting LatencyInfo. | 528 // not NULL, it is also merged into the resulting LatencyInfo. |
494 ui::LatencyInfo CreateRWHLatencyInfoIfNotExist( | 529 ui::LatencyInfo CreateRWHLatencyInfoIfNotExist( |
495 const ui::LatencyInfo* original, blink::WebInputEvent::Type type); | 530 const ui::LatencyInfo* original, blink::WebInputEvent::Type type); |
496 | 531 |
497 // Called when we receive a notification indicating that the renderer | 532 // Called when we receive a notification indicating that the renderer |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 void WindowSnapshotReachedScreen(int snapshot_id); | 702 void WindowSnapshotReachedScreen(int snapshot_id); |
668 | 703 |
669 void OnSnapshotDataReceived(int snapshot_id, | 704 void OnSnapshotDataReceived(int snapshot_id, |
670 const unsigned char* png, | 705 const unsigned char* png, |
671 size_t size); | 706 size_t size); |
672 | 707 |
673 void OnSnapshotDataReceivedAsync( | 708 void OnSnapshotDataReceivedAsync( |
674 int snapshot_id, | 709 int snapshot_id, |
675 scoped_refptr<base::RefCountedBytes> png_data); | 710 scoped_refptr<base::RefCountedBytes> png_data); |
676 | 711 |
| 712 // Send a message to the renderer process to change the accessibility mode. |
| 713 void SetAccessibilityMode(AccessibilityMode AccessibilityMode); |
| 714 |
677 // Our delegate, which wants to know mainly about keyboard events. | 715 // Our delegate, which wants to know mainly about keyboard events. |
678 // It will remain non-NULL until DetachDelegate() is called. | 716 // It will remain non-NULL until DetachDelegate() is called. |
679 RenderWidgetHostDelegate* delegate_; | 717 RenderWidgetHostDelegate* delegate_; |
680 | 718 |
681 // Created during construction but initialized during Init*(). Therefore, it | 719 // Created during construction but initialized during Init*(). Therefore, it |
682 // is guaranteed never to be NULL, but its channel may be NULL if the | 720 // is guaranteed never to be NULL, but its channel may be NULL if the |
683 // renderer crashed, so you must always check that. | 721 // renderer crashed, so you must always check that. |
684 RenderProcessHost* process_; | 722 RenderProcessHost* process_; |
685 | 723 |
686 // The ID of the corresponding object in the Renderer Instance. | 724 // The ID of the corresponding object in the Renderer Instance. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 gfx::Size new_auto_size_; | 776 gfx::Size new_auto_size_; |
739 | 777 |
740 // True if the render widget host should track the render widget's size as | 778 // True if the render widget host should track the render widget's size as |
741 // opposed to visa versa. | 779 // opposed to visa versa. |
742 bool should_auto_resize_; | 780 bool should_auto_resize_; |
743 | 781 |
744 bool waiting_for_screen_rects_ack_; | 782 bool waiting_for_screen_rects_ack_; |
745 gfx::Rect last_view_screen_rect_; | 783 gfx::Rect last_view_screen_rect_; |
746 gfx::Rect last_window_screen_rect_; | 784 gfx::Rect last_window_screen_rect_; |
747 | 785 |
| 786 AccessibilityMode accessibility_mode_; |
| 787 |
748 // Keyboard event listeners. | 788 // Keyboard event listeners. |
749 std::vector<KeyPressEventCallback> key_press_event_callbacks_; | 789 std::vector<KeyPressEventCallback> key_press_event_callbacks_; |
750 | 790 |
751 // Mouse event callbacks. | 791 // Mouse event callbacks. |
752 std::vector<MouseEventCallback> mouse_event_callbacks_; | 792 std::vector<MouseEventCallback> mouse_event_callbacks_; |
753 | 793 |
754 // If true, then we should repaint when restoring even if we have a | 794 // If true, then we should repaint when restoring even if we have a |
755 // backingstore. This flag is set to true if we receive a paint message | 795 // backingstore. This flag is set to true if we receive a paint message |
756 // while is_hidden_ to true. Even though we tell the render widget to hide | 796 // while is_hidden_ to true. Even though we tell the render widget to hide |
757 // itself, a paint message could already be in flight at that point. | 797 // itself, a paint message could already be in flight at that point. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 typedef std::map<int, | 880 typedef std::map<int, |
841 base::Callback<void(const unsigned char*, size_t)> > PendingSnapshotMap; | 881 base::Callback<void(const unsigned char*, size_t)> > PendingSnapshotMap; |
842 PendingSnapshotMap pending_browser_snapshots_; | 882 PendingSnapshotMap pending_browser_snapshots_; |
843 | 883 |
844 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 884 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
845 }; | 885 }; |
846 | 886 |
847 } // namespace content | 887 } // namespace content |
848 | 888 |
849 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 889 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
OLD | NEW |