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" | |
28 #include "content/browser/renderer_host/event_with_latency_info.h" | 27 #include "content/browser/renderer_host/event_with_latency_info.h" |
29 #include "content/browser/renderer_host/input/input_ack_handler.h" | 28 #include "content/browser/renderer_host/input/input_ack_handler.h" |
30 #include "content/browser/renderer_host/input/input_router_client.h" | 29 #include "content/browser/renderer_host/input/input_router_client.h" |
31 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 30 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
32 #include "content/browser/renderer_host/input/touch_emulator_client.h" | 31 #include "content/browser/renderer_host/input/touch_emulator_client.h" |
33 #include "content/common/input/input_event_ack_state.h" | 32 #include "content/common/input/input_event_ack_state.h" |
34 #include "content/common/input/synthetic_gesture_packet.h" | 33 #include "content/common/input/synthetic_gesture_packet.h" |
35 #include "content/common/view_message_enums.h" | 34 #include "content/common/view_message_enums.h" |
36 #include "content/public/browser/render_widget_host.h" | 35 #include "content/public/browser/render_widget_host.h" |
37 #include "content/public/common/page_zoom.h" | 36 #include "content/public/common/page_zoom.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 class WebCursor; | 89 class WebCursor; |
91 struct EditCommand; | 90 struct EditCommand; |
92 | 91 |
93 // This implements the RenderWidgetHost interface that is exposed to | 92 // This implements the RenderWidgetHost interface that is exposed to |
94 // embedders of content, and adds things only visible to content. | 93 // embedders of content, and adds things only visible to content. |
95 class CONTENT_EXPORT RenderWidgetHostImpl | 94 class CONTENT_EXPORT RenderWidgetHostImpl |
96 : virtual public RenderWidgetHost, | 95 : virtual public RenderWidgetHost, |
97 public InputRouterClient, | 96 public InputRouterClient, |
98 public InputAckHandler, | 97 public InputAckHandler, |
99 public TouchEmulatorClient, | 98 public TouchEmulatorClient, |
100 public IPC::Listener, | 99 public IPC::Listener { |
101 public BrowserAccessibilityDelegate { | |
102 public: | 100 public: |
103 // 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 |
104 // routing id is taken from the RenderProcessHost. | 102 // routing id is taken from the RenderProcessHost. |
105 // If this object outlives |delegate|, DetachDelegate() must be called when | 103 // If this object outlives |delegate|, DetachDelegate() must be called when |
106 // |delegate| goes away. | 104 // |delegate| goes away. |
107 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 105 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
108 RenderProcessHost* process, | 106 RenderProcessHost* process, |
109 int routing_id, | 107 int routing_id, |
110 bool hidden); | 108 bool hidden); |
111 virtual ~RenderWidgetHostImpl(); | 109 virtual ~RenderWidgetHostImpl(); |
(...skipping 24 matching lines...) Expand all Loading... |
136 virtual void CopyFromBackingStore( | 134 virtual void CopyFromBackingStore( |
137 const gfx::Rect& src_rect, | 135 const gfx::Rect& src_rect, |
138 const gfx::Size& accelerated_dst_size, | 136 const gfx::Size& accelerated_dst_size, |
139 const base::Callback<void(bool, const SkBitmap&)>& callback, | 137 const base::Callback<void(bool, const SkBitmap&)>& callback, |
140 const SkBitmap::Config& bitmap_config) OVERRIDE; | 138 const SkBitmap::Config& bitmap_config) OVERRIDE; |
141 virtual bool CanCopyFromBackingStore() OVERRIDE; | 139 virtual bool CanCopyFromBackingStore() OVERRIDE; |
142 #if defined(OS_ANDROID) | 140 #if defined(OS_ANDROID) |
143 virtual void LockBackingStore() OVERRIDE; | 141 virtual void LockBackingStore() OVERRIDE; |
144 virtual void UnlockBackingStore() OVERRIDE; | 142 virtual void UnlockBackingStore() OVERRIDE; |
145 #endif | 143 #endif |
146 virtual void EnableFullAccessibilityMode() OVERRIDE; | |
147 virtual bool IsFullAccessibilityModeForTesting() OVERRIDE; | |
148 virtual void EnableTreeOnlyAccessibilityMode() OVERRIDE; | |
149 virtual bool IsTreeOnlyAccessibilityModeForTesting() OVERRIDE; | |
150 virtual void ForwardMouseEvent( | 144 virtual void ForwardMouseEvent( |
151 const blink::WebMouseEvent& mouse_event) OVERRIDE; | 145 const blink::WebMouseEvent& mouse_event) OVERRIDE; |
152 virtual void ForwardWheelEvent( | 146 virtual void ForwardWheelEvent( |
153 const blink::WebMouseWheelEvent& wheel_event) OVERRIDE; | 147 const blink::WebMouseWheelEvent& wheel_event) OVERRIDE; |
154 virtual void ForwardKeyboardEvent( | 148 virtual void ForwardKeyboardEvent( |
155 const NativeWebKeyboardEvent& key_event) OVERRIDE; | 149 const NativeWebKeyboardEvent& key_event) OVERRIDE; |
156 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE; | 150 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE; |
157 virtual RenderProcessHost* GetProcess() const OVERRIDE; | 151 virtual RenderProcessHost* GetProcess() const OVERRIDE; |
158 virtual int GetRoutingID() const OVERRIDE; | 152 virtual int GetRoutingID() const OVERRIDE; |
159 virtual RenderWidgetHostView* GetView() const OVERRIDE; | 153 virtual RenderWidgetHostView* GetView() const OVERRIDE; |
160 virtual bool IsLoading() const OVERRIDE; | 154 virtual bool IsLoading() const OVERRIDE; |
161 virtual bool IsRenderView() const OVERRIDE; | 155 virtual bool IsRenderView() const OVERRIDE; |
162 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; | 156 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; |
163 virtual void RestartHangMonitorTimeout() OVERRIDE; | 157 virtual void RestartHangMonitorTimeout() OVERRIDE; |
164 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; | 158 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; |
165 virtual void Stop() OVERRIDE; | 159 virtual void Stop() OVERRIDE; |
166 virtual void WasResized() OVERRIDE; | 160 virtual void WasResized() OVERRIDE; |
167 virtual void AddKeyPressEventCallback( | 161 virtual void AddKeyPressEventCallback( |
168 const KeyPressEventCallback& callback) OVERRIDE; | 162 const KeyPressEventCallback& callback) OVERRIDE; |
169 virtual void RemoveKeyPressEventCallback( | 163 virtual void RemoveKeyPressEventCallback( |
170 const KeyPressEventCallback& callback) OVERRIDE; | 164 const KeyPressEventCallback& callback) OVERRIDE; |
171 virtual void AddMouseEventCallback( | 165 virtual void AddMouseEventCallback( |
172 const MouseEventCallback& callback) OVERRIDE; | 166 const MouseEventCallback& callback) OVERRIDE; |
173 virtual void RemoveMouseEventCallback( | 167 virtual void RemoveMouseEventCallback( |
174 const MouseEventCallback& callback) OVERRIDE; | 168 const MouseEventCallback& callback) OVERRIDE; |
175 virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE; | 169 virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE; |
176 | 170 |
177 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE; | 171 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE; |
178 | 172 |
179 // BrowserAccessibilityDelegate | |
180 virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE; | |
181 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; | |
182 virtual void AccessibilityShowMenu(int acc_obj_id) OVERRIDE; | |
183 virtual void AccessibilityScrollToMakeVisible( | |
184 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; | |
185 virtual void AccessibilityScrollToPoint( | |
186 int acc_obj_id, gfx::Point point) OVERRIDE; | |
187 virtual void AccessibilitySetTextSelection( | |
188 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; | |
189 virtual bool AccessibilityViewHasFocus() const OVERRIDE; | |
190 virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE; | |
191 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds) | |
192 const OVERRIDE; | |
193 virtual void AccessibilityFatalError() OVERRIDE; | |
194 | |
195 const NativeWebKeyboardEvent* GetLastKeyboardEvent() const; | 173 const NativeWebKeyboardEvent* GetLastKeyboardEvent() const; |
196 | 174 |
197 // Notification that the screen info has changed. | 175 // Notification that the screen info has changed. |
198 void NotifyScreenInfoChanged(); | 176 void NotifyScreenInfoChanged(); |
199 | 177 |
200 // Invalidates the cached screen info so that next resize request | 178 // Invalidates the cached screen info so that next resize request |
201 // will carry the up to date screen info. Unlike | 179 // will carry the up to date screen info. Unlike |
202 // |NotifyScreenInfoChanged|, this doesn't send a message to the renderer. | 180 // |NotifyScreenInfoChanged|, this doesn't send a message to the renderer. |
203 void InvalidateScreenInfo(); | 181 void InvalidateScreenInfo(); |
204 | 182 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 void StartUserGesture(); | 363 void StartUserGesture(); |
386 | 364 |
387 // Set the RenderView background. | 365 // Set the RenderView background. |
388 void SetBackground(const SkBitmap& background); | 366 void SetBackground(const SkBitmap& background); |
389 | 367 |
390 // Notifies the renderer that the next key event is bound to one or more | 368 // Notifies the renderer that the next key event is bound to one or more |
391 // pre-defined edit commands | 369 // pre-defined edit commands |
392 void SetEditCommandsForNextKeyEvent( | 370 void SetEditCommandsForNextKeyEvent( |
393 const std::vector<EditCommand>& commands); | 371 const std::vector<EditCommand>& commands); |
394 | 372 |
395 // Gets the accessibility mode. | |
396 AccessibilityMode accessibility_mode() const { | |
397 return accessibility_mode_; | |
398 } | |
399 | |
400 // Adds the given accessibility mode to the current accessibility mode bitmap. | |
401 void AddAccessibilityMode(AccessibilityMode mode); | |
402 | |
403 // Removes the given accessibility mode from the current accessibility mode | |
404 // bitmap, managing the bits that are shared with other modes such that a | |
405 // bit will only be turned off when all modes that depend on it have been | |
406 // removed. | |
407 void RemoveAccessibilityMode(AccessibilityMode mode); | |
408 | |
409 // Resets the accessibility mode to the default setting in | |
410 // BrowserStateAccessibilityImpl. | |
411 void ResetAccessibilityMode(); | |
412 | |
413 #if defined(OS_WIN) | |
414 void SetParentNativeViewAccessible( | |
415 gfx::NativeViewAccessible accessible_parent); | |
416 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; | |
417 #endif | |
418 | |
419 // Executes the edit command on the RenderView. | 373 // Executes the edit command on the RenderView. |
420 void ExecuteEditCommand(const std::string& command, | 374 void ExecuteEditCommand(const std::string& command, |
421 const std::string& value); | 375 const std::string& value); |
422 | 376 |
423 // Tells the renderer to scroll the currently focused node into rect only if | 377 // Tells the renderer to scroll the currently focused node into rect only if |
424 // the currently focused node is a Text node (textfield, text area or content | 378 // the currently focused node is a Text node (textfield, text area or content |
425 // editable divs). | 379 // editable divs). |
426 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); | 380 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); |
427 | 381 |
428 // Requests the renderer to move the caret selection towards the point. | 382 // Requests the renderer to move the caret selection towards the point. |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 virtual void OnUnexpectedEventAck(UnexpectedEventAckType type) OVERRIDE; | 659 virtual void OnUnexpectedEventAck(UnexpectedEventAckType type) OVERRIDE; |
706 | 660 |
707 void OnSyntheticGestureCompleted(SyntheticGesture::Result result); | 661 void OnSyntheticGestureCompleted(SyntheticGesture::Result result); |
708 | 662 |
709 // Called when there is a new auto resize (using a post to avoid a stack | 663 // Called when there is a new auto resize (using a post to avoid a stack |
710 // which may get in recursive loops). | 664 // which may get in recursive loops). |
711 void DelayedAutoResized(); | 665 void DelayedAutoResized(); |
712 | 666 |
713 void WindowSnapshotReachedScreen(int snapshot_id); | 667 void WindowSnapshotReachedScreen(int snapshot_id); |
714 | 668 |
715 // Send a message to the renderer process to change the accessibility mode. | |
716 void SetAccessibilityMode(AccessibilityMode AccessibilityMode); | |
717 | |
718 // Our delegate, which wants to know mainly about keyboard events. | 669 // Our delegate, which wants to know mainly about keyboard events. |
719 // It will remain non-NULL until DetachDelegate() is called. | 670 // It will remain non-NULL until DetachDelegate() is called. |
720 RenderWidgetHostDelegate* delegate_; | 671 RenderWidgetHostDelegate* delegate_; |
721 | 672 |
722 // Created during construction but initialized during Init*(). Therefore, it | 673 // Created during construction but initialized during Init*(). Therefore, it |
723 // is guaranteed never to be NULL, but its channel may be NULL if the | 674 // is guaranteed never to be NULL, but its channel may be NULL if the |
724 // renderer crashed, so you must always check that. | 675 // renderer crashed, so you must always check that. |
725 RenderProcessHost* process_; | 676 RenderProcessHost* process_; |
726 | 677 |
727 // The ID of the corresponding object in the Renderer Instance. | 678 // The ID of the corresponding object in the Renderer Instance. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 gfx::Size new_auto_size_; | 733 gfx::Size new_auto_size_; |
783 | 734 |
784 // True if the render widget host should track the render widget's size as | 735 // True if the render widget host should track the render widget's size as |
785 // opposed to visa versa. | 736 // opposed to visa versa. |
786 bool should_auto_resize_; | 737 bool should_auto_resize_; |
787 | 738 |
788 bool waiting_for_screen_rects_ack_; | 739 bool waiting_for_screen_rects_ack_; |
789 gfx::Rect last_view_screen_rect_; | 740 gfx::Rect last_view_screen_rect_; |
790 gfx::Rect last_window_screen_rect_; | 741 gfx::Rect last_window_screen_rect_; |
791 | 742 |
792 AccessibilityMode accessibility_mode_; | |
793 | |
794 // Keyboard event listeners. | 743 // Keyboard event listeners. |
795 std::vector<KeyPressEventCallback> key_press_event_callbacks_; | 744 std::vector<KeyPressEventCallback> key_press_event_callbacks_; |
796 | 745 |
797 // Mouse event callbacks. | 746 // Mouse event callbacks. |
798 std::vector<MouseEventCallback> mouse_event_callbacks_; | 747 std::vector<MouseEventCallback> mouse_event_callbacks_; |
799 | 748 |
800 // If true, then we should repaint when restoring even if we have a | 749 // If true, then we should repaint when restoring even if we have a |
801 // backingstore. This flag is set to true if we receive a paint message | 750 // backingstore. This flag is set to true if we receive a paint message |
802 // while is_hidden_ to true. Even though we tell the render widget to hide | 751 // while is_hidden_ to true. Even though we tell the render widget to hide |
803 // itself, a paint message could already be in flight at that point. | 752 // itself, a paint message could already be in flight at that point. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 #endif | 838 #endif |
890 | 839 |
891 int64 last_input_number_; | 840 int64 last_input_number_; |
892 | 841 |
893 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 842 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
894 }; | 843 }; |
895 | 844 |
896 } // namespace content | 845 } // namespace content |
897 | 846 |
898 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 847 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
OLD | NEW |