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 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/gfx/native_widget_types.h" | 11 #include "base/gfx/native_widget_types.h" |
12 #include "base/gfx/size.h" | 12 #include "base/gfx/size.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/timer.h" | 14 #include "base/timer.h" |
15 #include "chrome/common/ipc_channel.h" | 15 #include "chrome/common/ipc_channel.h" |
16 #include "chrome/common/native_web_keyboard_event.h" | 16 #include "chrome/common/native_web_keyboard_event.h" |
| 17 #include "chrome/common/property_bag.h" |
17 #include "testing/gtest/include/gtest/gtest_prod.h" | 18 #include "testing/gtest/include/gtest/gtest_prod.h" |
18 #include "webkit/glue/webtextdirection.h" | 19 #include "webkit/glue/webtextdirection.h" |
19 | 20 |
20 namespace gfx { | 21 namespace gfx { |
21 class Rect; | 22 class Rect; |
22 } | 23 } |
23 | 24 |
24 namespace WebKit { | 25 namespace WebKit { |
25 class WebInputEvent; | 26 class WebInputEvent; |
26 class WebMouseEvent; | 27 class WebMouseEvent; |
27 class WebMouseWheelEvent; | 28 class WebMouseWheelEvent; |
28 } | 29 } |
29 | 30 |
30 class BackingStore; | 31 class BackingStore; |
31 class PaintObserver; | 32 class PaintObserver; |
32 class RenderProcessHost; | 33 class RenderProcessHost; |
33 class RenderWidgetHostView; | 34 class RenderWidgetHostView; |
| 35 class RenderWidgetHostPaintingObserver; |
34 class TransportDIB; | 36 class TransportDIB; |
35 class WebCursor; | 37 class WebCursor; |
36 struct ViewHostMsg_PaintRect_Params; | 38 struct ViewHostMsg_PaintRect_Params; |
37 struct ViewHostMsg_ScrollRect_Params; | 39 struct ViewHostMsg_ScrollRect_Params; |
38 | 40 |
39 // This class manages the browser side of a browser<->renderer HWND connection. | 41 // This class manages the browser side of a browser<->renderer HWND connection. |
40 // The HWND lives in the browser process, and windows events are sent over | 42 // The HWND lives in the browser process, and windows events are sent over |
41 // IPC to the corresponding object in the renderer. The renderer paints into | 43 // IPC to the corresponding object in the renderer. The renderer paints into |
42 // shared memory, which we transfer to a backing store and blit to the screen | 44 // shared memory, which we transfer to a backing store and blit to the screen |
43 // when Windows sends us a WM_PAINT message. | 45 // when Windows sends us a WM_PAINT message. |
(...skipping 89 matching lines...) Loading... |
133 RenderWidgetHostView* view() const { return view_; } | 135 RenderWidgetHostView* view() const { return view_; } |
134 | 136 |
135 RenderProcessHost* process() const { return process_; } | 137 RenderProcessHost* process() const { return process_; } |
136 int routing_id() const { return routing_id_; } | 138 int routing_id() const { return routing_id_; } |
137 | 139 |
138 // Set the PaintObserver on this object. Takes ownership. | 140 // Set the PaintObserver on this object. Takes ownership. |
139 void set_paint_observer(PaintObserver* paint_observer) { | 141 void set_paint_observer(PaintObserver* paint_observer) { |
140 paint_observer_.reset(paint_observer); | 142 paint_observer_.reset(paint_observer); |
141 } | 143 } |
142 | 144 |
| 145 // Returns the property bag for this widget, where callers can add extra data |
| 146 // they may wish to associate with it. Returns a pointer rather than a |
| 147 // reference since the PropertyAccessors expect this. |
| 148 const PropertyBag* property_bag() const { return &property_bag_; } |
| 149 PropertyBag* property_bag() { return &property_bag_; } |
| 150 |
| 151 // The painting observer that will be called for paint events. This |
| 152 // pointer's ownership will remain with the caller and must remain valid |
| 153 // until this class is destroyed or the observer is replaced. |
| 154 RenderWidgetHostPaintingObserver* painting_observer() const { |
| 155 return painting_observer_; |
| 156 } |
| 157 void set_painting_observer(RenderWidgetHostPaintingObserver* observer) { |
| 158 painting_observer_ = observer; |
| 159 } |
| 160 |
143 // Called when a renderer object already been created for this host, and we | 161 // Called when a renderer object already been created for this host, and we |
144 // just need to be attached to it. Used for window.open, <select> dropdown | 162 // just need to be attached to it. Used for window.open, <select> dropdown |
145 // menus, and other times when the renderer initiates creating an object. | 163 // menus, and other times when the renderer initiates creating an object. |
146 void Init(); | 164 void Init(); |
147 | 165 |
148 // Tells the renderer to die and then calls Destroy(). | 166 // Tells the renderer to die and then calls Destroy(). |
149 virtual void Shutdown(); | 167 virtual void Shutdown(); |
150 | 168 |
151 // Manual RTTI FTW. We are not hosting a web page. | 169 // Manual RTTI FTW. We are not hosting a web page. |
152 virtual bool IsRenderView() { return false; } | 170 virtual bool IsRenderView() { return false; } |
(...skipping 22 matching lines...) Loading... |
175 void LostCapture(); | 193 void LostCapture(); |
176 | 194 |
177 // Notifies the RenderWidgetHost that the View was destroyed. | 195 // Notifies the RenderWidgetHost that the View was destroyed. |
178 void ViewDestroyed(); | 196 void ViewDestroyed(); |
179 | 197 |
180 // Indicates if the page has finished loading. | 198 // Indicates if the page has finished loading. |
181 void SetIsLoading(bool is_loading); | 199 void SetIsLoading(bool is_loading); |
182 | 200 |
183 // Get access to the widget's backing store. If a resize is in progress, | 201 // Get access to the widget's backing store. If a resize is in progress, |
184 // then the current size of the backing store may be less than the size of | 202 // then the current size of the backing store may be less than the size of |
185 // the widget's view. This method returns NULL if the backing store could | 203 // the widget's view. If you pass |force_create| as true, then the backing |
186 // not be created. | 204 // store will be created if it doesn't exist. Otherwise, NULL will be returned |
187 BackingStore* GetBackingStore(); | 205 // if the backing store doesn't already exist. It will also return NULL if the |
| 206 // backing store could not be created. |
| 207 BackingStore* GetBackingStore(bool force_create); |
188 | 208 |
189 // Allocate a new backing store of the given size. Returns NULL on failure | 209 // Allocate a new backing store of the given size. Returns NULL on failure |
190 // (for example, if we don't currently have a RenderWidgetHostView.) | 210 // (for example, if we don't currently have a RenderWidgetHostView.) |
191 BackingStore* AllocBackingStore(const gfx::Size& size); | 211 BackingStore* AllocBackingStore(const gfx::Size& size); |
192 | 212 |
193 // Checks to see if we can give up focus to this widget through a JS call. | 213 // Checks to see if we can give up focus to this widget through a JS call. |
194 virtual bool CanBlur() const { return true; } | 214 virtual bool CanBlur() const { return true; } |
195 | 215 |
196 // Starts a hang monitor timeout. If there's already a hang monitor timeout | 216 // Starts a hang monitor timeout. If there's already a hang monitor timeout |
197 // the new one will only fire if it has a shorter delay than the time | 217 // the new one will only fire if it has a shorter delay than the time |
(...skipping 153 matching lines...) Loading... |
351 // crashes, its View is destroyed and this pointer becomes NULL, even though | 371 // crashes, its View is destroyed and this pointer becomes NULL, even though |
352 // render_view_host_ lives on to load another URL (creating a new View while | 372 // render_view_host_ lives on to load another URL (creating a new View while |
353 // doing so). | 373 // doing so). |
354 RenderWidgetHostView* view_; | 374 RenderWidgetHostView* view_; |
355 | 375 |
356 // Created during construction but initialized during Init*(). Therefore, it | 376 // Created during construction but initialized during Init*(). Therefore, it |
357 // is guaranteed never to be NULL, but its channel may be NULL if the | 377 // is guaranteed never to be NULL, but its channel may be NULL if the |
358 // renderer crashed, so you must always check that. | 378 // renderer crashed, so you must always check that. |
359 RenderProcessHost* process_; | 379 RenderProcessHost* process_; |
360 | 380 |
| 381 // Stores random bits of data for others to associate with this object. |
| 382 PropertyBag property_bag_; |
| 383 |
| 384 // Observer that will be called for paint events. This may be NULL. The |
| 385 // pointer is not owned by this class. |
| 386 RenderWidgetHostPaintingObserver* painting_observer_; |
| 387 |
361 // The ID of the corresponding object in the Renderer Instance. | 388 // The ID of the corresponding object in the Renderer Instance. |
362 int routing_id_; | 389 int routing_id_; |
363 | 390 |
364 // Indicates whether a page is loading or not. | 391 // Indicates whether a page is loading or not. |
365 bool is_loading_; | 392 bool is_loading_; |
366 | 393 |
367 // Indicates whether a page is hidden or not. | 394 // Indicates whether a page is hidden or not. |
368 bool is_hidden_; | 395 bool is_hidden_; |
369 | 396 |
370 // Set if we are waiting for a repaint ack for the view. | 397 // Set if we are waiting for a repaint ack for the view. |
(...skipping 59 matching lines...) Loading... |
430 | 457 |
431 // Set when we cancel updating the text direction. | 458 // Set when we cancel updating the text direction. |
432 // This flag also ignores succeeding update requests until we call | 459 // This flag also ignores succeeding update requests until we call |
433 // NotifyTextDirection(). | 460 // NotifyTextDirection(). |
434 bool text_direction_canceled_; | 461 bool text_direction_canceled_; |
435 | 462 |
436 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); | 463 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); |
437 }; | 464 }; |
438 | 465 |
439 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 466 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
OLD | NEW |