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 17 matching lines...) Loading... |
170 void LostCapture(); | 188 void LostCapture(); |
171 | 189 |
172 // Notifies the RenderWidgetHost that the View was destroyed. | 190 // Notifies the RenderWidgetHost that the View was destroyed. |
173 void ViewDestroyed(); | 191 void ViewDestroyed(); |
174 | 192 |
175 // Indicates if the page has finished loading. | 193 // Indicates if the page has finished loading. |
176 void SetIsLoading(bool is_loading); | 194 void SetIsLoading(bool is_loading); |
177 | 195 |
178 // Get access to the widget's backing store. If a resize is in progress, | 196 // Get access to the widget's backing store. If a resize is in progress, |
179 // then the current size of the backing store may be less than the size of | 197 // then the current size of the backing store may be less than the size of |
180 // the widget's view. This method returns NULL if the backing store could | 198 // the widget's view. If you pass |force_create| as true, then the backing |
181 // not be created. | 199 // store will be created if it doesn't exist. Otherwise, NULL will be returned |
182 BackingStore* GetBackingStore(); | 200 // if the backing store doesn't already exist. It will also return NULL if the |
| 201 // backing store could not be created. |
| 202 BackingStore* GetBackingStore(bool force_create); |
183 | 203 |
184 // Allocate a new backing store of the given size. Returns NULL on failure | 204 // Allocate a new backing store of the given size. Returns NULL on failure |
185 // (for example, if we don't currently have a RenderWidgetHostView.) | 205 // (for example, if we don't currently have a RenderWidgetHostView.) |
186 BackingStore* AllocBackingStore(const gfx::Size& size); | 206 BackingStore* AllocBackingStore(const gfx::Size& size); |
187 | 207 |
188 // Checks to see if we can give up focus to this widget through a JS call. | 208 // Checks to see if we can give up focus to this widget through a JS call. |
189 virtual bool CanBlur() const { return true; } | 209 virtual bool CanBlur() const { return true; } |
190 | 210 |
191 // Starts a hang monitor timeout. If there's already a hang monitor timeout | 211 // Starts a hang monitor timeout. If there's already a hang monitor timeout |
192 // the new one will only fire if it has a shorter delay than the time | 212 // the new one will only fire if it has a shorter delay than the time |
(...skipping 153 matching lines...) Loading... |
346 // crashes, its View is destroyed and this pointer becomes NULL, even though | 366 // crashes, its View is destroyed and this pointer becomes NULL, even though |
347 // render_view_host_ lives on to load another URL (creating a new View while | 367 // render_view_host_ lives on to load another URL (creating a new View while |
348 // doing so). | 368 // doing so). |
349 RenderWidgetHostView* view_; | 369 RenderWidgetHostView* view_; |
350 | 370 |
351 // Created during construction but initialized during Init*(). Therefore, it | 371 // Created during construction but initialized during Init*(). Therefore, it |
352 // is guaranteed never to be NULL, but its channel may be NULL if the | 372 // is guaranteed never to be NULL, but its channel may be NULL if the |
353 // renderer crashed, so you must always check that. | 373 // renderer crashed, so you must always check that. |
354 RenderProcessHost* process_; | 374 RenderProcessHost* process_; |
355 | 375 |
| 376 // Stores random bits of data for others to associate with this object. |
| 377 PropertyBag property_bag_; |
| 378 |
| 379 // Observer that will be called for paint events. This may be NULL. The |
| 380 // pointer is not owned by this class. |
| 381 RenderWidgetHostPaintingObserver* painting_observer_; |
| 382 |
356 // The ID of the corresponding object in the Renderer Instance. | 383 // The ID of the corresponding object in the Renderer Instance. |
357 int routing_id_; | 384 int routing_id_; |
358 | 385 |
359 // Indicates whether a page is loading or not. | 386 // Indicates whether a page is loading or not. |
360 bool is_loading_; | 387 bool is_loading_; |
361 | 388 |
362 // Indicates whether a page is hidden or not. | 389 // Indicates whether a page is hidden or not. |
363 bool is_hidden_; | 390 bool is_hidden_; |
364 | 391 |
365 // Set if we are waiting for a repaint ack for the view. | 392 // Set if we are waiting for a repaint ack for the view. |
(...skipping 59 matching lines...) Loading... |
425 | 452 |
426 // Set when we cancel updating the text direction. | 453 // Set when we cancel updating the text direction. |
427 // This flag also ignores succeeding update requests until we call | 454 // This flag also ignores succeeding update requests until we call |
428 // NotifyTextDirection(). | 455 // NotifyTextDirection(). |
429 bool text_direction_canceled_; | 456 bool text_direction_canceled_; |
430 | 457 |
431 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); | 458 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); |
432 }; | 459 }; |
433 | 460 |
434 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 461 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
OLD | NEW |