OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 24 matching lines...) Expand all Loading... | |
35 class WebInputEvent; | 35 class WebInputEvent; |
36 class WebMouseEvent; | 36 class WebMouseEvent; |
37 struct WebCompositionUnderline; | 37 struct WebCompositionUnderline; |
38 struct WebScreenInfo; | 38 struct WebScreenInfo; |
39 } | 39 } |
40 | 40 |
41 class BackingStore; | 41 class BackingStore; |
42 class PaintObserver; | 42 class PaintObserver; |
43 class RenderProcessHost; | 43 class RenderProcessHost; |
44 class RenderWidgetHostView; | 44 class RenderWidgetHostView; |
45 class RenderWidgetHostPaintingObserver; | |
46 class TransportDIB; | 45 class TransportDIB; |
47 class WebCursor; | 46 class WebCursor; |
48 struct ViewHostMsg_UpdateRect_Params; | 47 struct ViewHostMsg_UpdateRect_Params; |
49 | 48 |
50 // This class manages the browser side of a browser<->renderer HWND connection. | 49 // This class manages the browser side of a browser<->renderer HWND connection. |
51 // The HWND lives in the browser process, and windows events are sent over | 50 // The HWND lives in the browser process, and windows events are sent over |
52 // IPC to the corresponding object in the renderer. The renderer paints into | 51 // IPC to the corresponding object in the renderer. The renderer paints into |
53 // shared memory, which we transfer to a backing store and blit to the screen | 52 // shared memory, which we transfer to a backing store and blit to the screen |
54 // when Windows sends us a WM_PAINT message. | 53 // when Windows sends us a WM_PAINT message. |
55 // | 54 // |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 // handles IPC messages relating to the render process going away, since the | 116 // handles IPC messages relating to the render process going away, since the |
118 // way a RenderViewHost (TabContents) handles the process dying is different to | 117 // way a RenderViewHost (TabContents) handles the process dying is different to |
119 // the way a select popup does. As such the RenderWidgetHostView handles these | 118 // the way a select popup does. As such the RenderWidgetHostView handles these |
120 // messages for select popups. This placement is more out of convenience than | 119 // messages for select popups. This placement is more out of convenience than |
121 // anything else. When the view is live, these messages are forwarded to it by | 120 // anything else. When the view is live, these messages are forwarded to it by |
122 // the RenderWidgetHost's IPC message map. | 121 // the RenderWidgetHost's IPC message map. |
123 // | 122 // |
124 class RenderWidgetHost : public IPC::Channel::Listener, | 123 class RenderWidgetHost : public IPC::Channel::Listener, |
125 public IPC::Channel::Sender { | 124 public IPC::Channel::Sender { |
126 public: | 125 public: |
127 // An interface that gets called before and after a paint. | |
128 class PaintObserver { | |
129 public: | |
130 virtual ~PaintObserver() {} | |
131 virtual void RenderWidgetHostWillPaint(RenderWidgetHost* rhw) = 0; | |
132 virtual void RenderWidgetHostDidPaint(RenderWidgetHost* rwh) = 0; | |
133 }; | |
134 | |
135 // routing_id can be MSG_ROUTING_NONE, in which case the next available | 126 // routing_id can be MSG_ROUTING_NONE, in which case the next available |
136 // routing id is taken from the RenderProcessHost. | 127 // routing id is taken from the RenderProcessHost. |
137 RenderWidgetHost(RenderProcessHost* process, int routing_id); | 128 RenderWidgetHost(RenderProcessHost* process, int routing_id); |
138 virtual ~RenderWidgetHost(); | 129 virtual ~RenderWidgetHost(); |
139 | 130 |
140 // Gets/Sets the View of this RenderWidgetHost. Can be NULL, e.g. if the | 131 // Gets/Sets the View of this RenderWidgetHost. Can be NULL, e.g. if the |
141 // RenderWidget is being destroyed or the render process crashed. You should | 132 // RenderWidget is being destroyed or the render process crashed. You should |
142 // never cache this pointer since it can become NULL if the renderer crashes, | 133 // never cache this pointer since it can become NULL if the renderer crashes, |
143 // instead you should always ask for it using the accessor. | 134 // instead you should always ask for it using the accessor. |
144 void set_view(RenderWidgetHostView* view) { view_ = view; } | 135 void set_view(RenderWidgetHostView* view) { view_ = view; } |
145 RenderWidgetHostView* view() const { return view_; } | 136 RenderWidgetHostView* view() const { return view_; } |
146 | 137 |
147 RenderProcessHost* process() const { return process_; } | 138 RenderProcessHost* process() const { return process_; } |
148 int routing_id() const { return routing_id_; } | 139 int routing_id() const { return routing_id_; } |
149 bool renderer_accessible() { return renderer_accessible_; } | 140 bool renderer_accessible() { return renderer_accessible_; } |
150 | 141 |
151 // Set the PaintObserver on this object. Takes ownership. | |
152 void set_paint_observer(PaintObserver* paint_observer) { | |
153 paint_observer_.reset(paint_observer); | |
154 } | |
155 | |
156 // Returns the property bag for this widget, where callers can add extra data | 142 // Returns the property bag for this widget, where callers can add extra data |
157 // they may wish to associate with it. Returns a pointer rather than a | 143 // they may wish to associate with it. Returns a pointer rather than a |
158 // reference since the PropertyAccessors expect this. | 144 // reference since the PropertyAccessors expect this. |
159 const PropertyBag* property_bag() const { return &property_bag_; } | 145 const PropertyBag* property_bag() const { return &property_bag_; } |
160 PropertyBag* property_bag() { return &property_bag_; } | 146 PropertyBag* property_bag() { return &property_bag_; } |
161 | 147 |
162 // The painting observer that will be called for paint events. This | |
163 // pointer's ownership will remain with the caller and must remain valid | |
164 // until this class is destroyed or the observer is replaced. | |
165 RenderWidgetHostPaintingObserver* painting_observer() const { | |
166 return painting_observer_; | |
167 } | |
168 void set_painting_observer(RenderWidgetHostPaintingObserver* observer) { | |
169 painting_observer_ = observer; | |
170 } | |
171 | |
172 // Called when a renderer object already been created for this host, and we | 148 // Called when a renderer object already been created for this host, and we |
173 // just need to be attached to it. Used for window.open, <select> dropdown | 149 // just need to be attached to it. Used for window.open, <select> dropdown |
174 // menus, and other times when the renderer initiates creating an object. | 150 // menus, and other times when the renderer initiates creating an object. |
175 void Init(); | 151 void Init(); |
176 | 152 |
177 // Tells the renderer to die and then calls Destroy(). | 153 // Tells the renderer to die and then calls Destroy(). |
178 virtual void Shutdown(); | 154 virtual void Shutdown(); |
179 | 155 |
180 // Manual RTTI FTW. We are not hosting a web page. | 156 // Manual RTTI FTW. We are not hosting a web page. |
181 virtual bool IsRenderView() const; | 157 virtual bool IsRenderView() const; |
(...skipping 30 matching lines...) Expand all Loading... | |
212 void ViewDestroyed(); | 188 void ViewDestroyed(); |
213 | 189 |
214 // Indicates if the page has finished loading. | 190 // Indicates if the page has finished loading. |
215 void SetIsLoading(bool is_loading); | 191 void SetIsLoading(bool is_loading); |
216 | 192 |
217 // This tells the renderer to paint into a bitmap and return it, | 193 // This tells the renderer to paint into a bitmap and return it, |
218 // regardless of whether the tab is hidden or not. It resizes the | 194 // regardless of whether the tab is hidden or not. It resizes the |
219 // web widget to match the |page_size| and then returns the bitmap | 195 // web widget to match the |page_size| and then returns the bitmap |
220 // scaled so it matches the |desired_size|, so that the scaling | 196 // scaled so it matches the |desired_size|, so that the scaling |
221 // happens on the rendering thread. When the bitmap is ready, the | 197 // happens on the rendering thread. When the bitmap is ready, the |
222 // renderer sends a PaintAtSizeACK to this host, and the painting | 198 // renderer sends a PaintAtSizeACK to this host, and a |
223 // observer is notified. Note that this bypasses most of the update | 199 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification is issued. |
224 // logic that is normally invoked, and doesn't put the results into | 200 // Note that this bypasses most of the update logic that is normally invoked, |
225 // the backing store. | 201 // and doesn't put the results into the backing store. |
226 void PaintAtSize(TransportDIB::Handle dib_handle, | 202 void PaintAtSize(TransportDIB::Handle dib_handle, |
227 int tag, | 203 int tag, |
228 const gfx::Size& page_size, | 204 const gfx::Size& page_size, |
229 const gfx::Size& desired_size); | 205 const gfx::Size& desired_size); |
230 | 206 |
231 // Get access to the widget's backing store. If a resize is in progress, | 207 // Get access to the widget's backing store. If a resize is in progress, |
232 // then the current size of the backing store may be less than the size of | 208 // then the current size of the backing store may be less than the size of |
233 // the widget's view. If you pass |force_create| as true, then the backing | 209 // the widget's view. If you pass |force_create| as true, then the backing |
234 // store will be created if it doesn't exist. Otherwise, NULL will be returned | 210 // store will be created if it doesn't exist. Otherwise, NULL will be returned |
235 // if the backing store doesn't already exist. It will also return NULL if the | 211 // if the backing store doesn't already exist. It will also return NULL if the |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 void set_ignore_input_events(bool ignore_input_events) { | 377 void set_ignore_input_events(bool ignore_input_events) { |
402 ignore_input_events_ = ignore_input_events; | 378 ignore_input_events_ = ignore_input_events; |
403 } | 379 } |
404 bool ignore_input_events() const { | 380 bool ignore_input_events() const { |
405 return ignore_input_events_; | 381 return ignore_input_events_; |
406 } | 382 } |
407 | 383 |
408 // Activate deferred plugin handles. | 384 // Activate deferred plugin handles. |
409 void ActivateDeferredPluginHandles(); | 385 void ActivateDeferredPluginHandles(); |
410 | 386 |
387 // Used as the details object for a | |
388 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification. | |
389 struct PaintAtSizeAckDetails { | |
390 int tag; | |
sky
2011/01/04 17:06:54
Document what tag is.
DaveMoore
2011/01/07 19:04:05
Done.
| |
391 gfx::Size size; | |
392 }; | |
393 | |
411 protected: | 394 protected: |
412 // Internal implementation of the public Forward*Event() methods. | 395 // Internal implementation of the public Forward*Event() methods. |
413 void ForwardInputEvent(const WebKit::WebInputEvent& input_event, | 396 void ForwardInputEvent(const WebKit::WebInputEvent& input_event, |
414 int event_size, bool is_keyboard_shortcut); | 397 int event_size, bool is_keyboard_shortcut); |
415 | 398 |
416 // Called when we receive a notification indicating that the renderer | 399 // Called when we receive a notification indicating that the renderer |
417 // process has gone. This will reset our state so that our state will be | 400 // process has gone. This will reset our state so that our state will be |
418 // consistent if a new renderer is created. | 401 // consistent if a new renderer is created. |
419 void RendererExited(base::TerminationStatus status, int exit_code); | 402 void RendererExited(base::TerminationStatus status, int exit_code); |
420 | 403 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 RenderWidgetHostView* view_; | 530 RenderWidgetHostView* view_; |
548 | 531 |
549 // Created during construction but initialized during Init*(). Therefore, it | 532 // Created during construction but initialized during Init*(). Therefore, it |
550 // is guaranteed never to be NULL, but its channel may be NULL if the | 533 // is guaranteed never to be NULL, but its channel may be NULL if the |
551 // renderer crashed, so you must always check that. | 534 // renderer crashed, so you must always check that. |
552 RenderProcessHost* process_; | 535 RenderProcessHost* process_; |
553 | 536 |
554 // Stores random bits of data for others to associate with this object. | 537 // Stores random bits of data for others to associate with this object. |
555 PropertyBag property_bag_; | 538 PropertyBag property_bag_; |
556 | 539 |
557 // Observer that will be called for paint events. This may be NULL. The | |
558 // pointer is not owned by this class. | |
559 RenderWidgetHostPaintingObserver* painting_observer_; | |
560 | |
561 // The ID of the corresponding object in the Renderer Instance. | 540 // The ID of the corresponding object in the Renderer Instance. |
562 int routing_id_; | 541 int routing_id_; |
563 | 542 |
564 // Indicates whether a page is loading or not. | 543 // Indicates whether a page is loading or not. |
565 bool is_loading_; | 544 bool is_loading_; |
566 | 545 |
567 // Indicates whether a page is hidden or not. | 546 // Indicates whether a page is hidden or not. |
568 bool is_hidden_; | 547 bool is_hidden_; |
569 | 548 |
570 // True when a page is rendered directly via the GPU process. | 549 // True when a page is rendered directly via the GPU process. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 // This is true if the renderer is currently unresponsive. | 609 // This is true if the renderer is currently unresponsive. |
631 bool is_unresponsive_; | 610 bool is_unresponsive_; |
632 | 611 |
633 // The following value indicates a time in the future when we would consider | 612 // The following value indicates a time in the future when we would consider |
634 // the renderer hung if it does not generate an appropriate response message. | 613 // the renderer hung if it does not generate an appropriate response message. |
635 base::Time time_when_considered_hung_; | 614 base::Time time_when_considered_hung_; |
636 | 615 |
637 // This timer runs to check if time_when_considered_hung_ has past. | 616 // This timer runs to check if time_when_considered_hung_ has past. |
638 base::OneShotTimer<RenderWidgetHost> hung_renderer_timer_; | 617 base::OneShotTimer<RenderWidgetHost> hung_renderer_timer_; |
639 | 618 |
640 // Optional observer that listens for notifications of painting. | |
641 scoped_ptr<PaintObserver> paint_observer_; | |
642 | |
643 // Flag to detect recursive calls to GetBackingStore(). | 619 // Flag to detect recursive calls to GetBackingStore(). |
644 bool in_get_backing_store_; | 620 bool in_get_backing_store_; |
645 | 621 |
646 // Set when we call DidPaintRect/DidScrollRect on the view. | 622 // Set when we call DidPaintRect/DidScrollRect on the view. |
647 bool view_being_painted_; | 623 bool view_being_painted_; |
648 | 624 |
649 // Used for UMA histogram logging to measure the time for a repaint view | 625 // Used for UMA histogram logging to measure the time for a repaint view |
650 // operation to finish. | 626 // operation to finish. |
651 base::TimeTicks repaint_start_time_; | 627 base::TimeTicks repaint_start_time_; |
652 | 628 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 // switching back to the original tab, because the content may already be | 660 // switching back to the original tab, because the content may already be |
685 // changed. | 661 // changed. |
686 bool suppress_next_char_events_; | 662 bool suppress_next_char_events_; |
687 | 663 |
688 std::vector<gfx::PluginWindowHandle> deferred_plugin_handles_; | 664 std::vector<gfx::PluginWindowHandle> deferred_plugin_handles_; |
689 | 665 |
690 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); | 666 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); |
691 }; | 667 }; |
692 | 668 |
693 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 669 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
OLD | NEW |