Chromium Code Reviews| 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_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 6 #define CONTENT_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 14 matching lines...) Expand all Loading... | |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" |
| 27 #include "ui/base/ime/text_input_type.h" | 27 #include "ui/base/ime/text_input_type.h" |
| 28 #include "ui/gfx/native_widget_types.h" | 28 #include "ui/gfx/native_widget_types.h" |
| 29 #include "ui/gfx/size.h" | 29 #include "ui/gfx/size.h" |
| 30 #include "ui/gfx/surface/transport_dib.h" | 30 #include "ui/gfx/surface/transport_dib.h" |
| 31 | 31 |
| 32 class BackingStore; | 32 class BackingStore; |
| 33 struct EditCommand; | 33 struct EditCommand; |
| 34 class RenderViewHost; | 34 class RenderViewHost; |
| 35 class RenderWidgetHostImpl; | |
| 35 class TransportDIB; | 36 class TransportDIB; |
| 36 struct ViewHostMsg_UpdateRect_Params; | 37 struct ViewHostMsg_UpdateRect_Params; |
| 37 class WebCursor; | 38 class WebCursor; |
| 38 | 39 |
| 39 namespace base { | 40 namespace base { |
| 40 class TimeTicks; | 41 class TimeTicks; |
| 41 } | 42 } |
| 42 | 43 |
| 43 namespace content { | 44 namespace content { |
| 44 class RenderProcessHost; | 45 class RenderProcessHost; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 61 struct WebScreenInfo; | 62 struct WebScreenInfo; |
| 62 } | 63 } |
| 63 | 64 |
| 64 // TODO(joi): Extract relevant bit of class documentation from | 65 // TODO(joi): Extract relevant bit of class documentation from |
| 65 // RenderWidgetHostImpl documentation. TODO(joi): Move to | 66 // RenderWidgetHostImpl documentation. TODO(joi): Move to |
| 66 // content/public/browser/render_widget_host.h | 67 // content/public/browser/render_widget_host.h |
| 67 // | 68 // |
| 68 // TODO(joi): Once I finish defining this interface (once | 69 // TODO(joi): Once I finish defining this interface (once |
| 69 // RenderViewHost interface is also in place), group together | 70 // RenderViewHost interface is also in place), group together |
| 70 // implementation functions in subclasses. | 71 // implementation functions in subclasses. |
| 71 class CONTENT_EXPORT RenderWidgetHost { | 72 // |
| 73 // TODO(joi): Move to file render_widget_host_impl.h | |
| 74 class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Sender { | |
| 72 public: | 75 public: |
| 73 explicit RenderWidgetHost(content::RenderProcessHost* process); | |
| 74 virtual ~RenderWidgetHost() {} | 76 virtual ~RenderWidgetHost() {} |
| 75 | 77 |
| 78 // Edit operations. | |
| 79 virtual void Undo() = 0; | |
| 80 virtual void Redo() = 0; | |
| 81 virtual void Cut() = 0; | |
| 82 virtual void Copy() = 0; | |
| 83 virtual void CopyToFindPboard() = 0; | |
| 84 virtual void Paste() = 0; | |
| 85 virtual void PasteAndMatchStyle() = 0; | |
| 86 virtual void Delete() = 0; | |
| 87 virtual void SelectAll() = 0; | |
| 88 | |
| 89 // Update the text direction of the focused input element and notify it to a | |
| 90 // renderer process. | |
| 91 // These functions have two usage scenarios: changing the text direction | |
| 92 // from a menu (as Safari does), and; changing the text direction when a user | |
| 93 // presses a set of keys (as IE and Firefox do). | |
| 94 // 1. Change the text direction from a menu. | |
| 95 // In this scenario, we receive a menu event only once and we should update | |
| 96 // the text direction immediately when a user chooses a menu item. So, we | |
| 97 // should call both functions at once as listed in the following snippet. | |
| 98 // void RenderViewHost::SetTextDirection(WebTextDirection direction) { | |
| 99 // UpdateTextDirection(direction); | |
| 100 // NotifyTextDirection(); | |
| 101 // } | |
| 102 // 2. Change the text direction when pressing a set of keys. | |
| 103 // Because of auto-repeat, we may receive the same key-press event many | |
| 104 // times while we presses the keys and it is nonsense to send the same IPC | |
| 105 // message every time when we receive a key-press event. | |
| 106 // To suppress the number of IPC messages, we just update the text direction | |
| 107 // when receiving a key-press event and send an IPC message when we release | |
| 108 // the keys as listed in the following snippet. | |
| 109 // if (key_event.type == WebKeyboardEvent::KEY_DOWN) { | |
| 110 // if (key_event.windows_key_code == 'A' && | |
| 111 // key_event.modifiers == WebKeyboardEvent::CTRL_KEY) { | |
| 112 // UpdateTextDirection(dir); | |
| 113 // } else { | |
| 114 // CancelUpdateTextDirection(); | |
| 115 // } | |
| 116 // } else if (key_event.type == WebKeyboardEvent::KEY_UP) { | |
| 117 // NotifyTextDirection(); | |
| 118 // } | |
| 119 // Once we cancel updating the text direction, we have to ignore all | |
| 120 // succeeding UpdateTextDirection() requests until calling | |
| 121 // NotifyTextDirection(). (We may receive keydown events even after we | |
| 122 // canceled updating the text direction because of auto-repeat.) | |
| 123 // Note: we cannot undo this change for compatibility with Firefox and IE. | |
| 124 virtual void UpdateTextDirection(WebKit::WebTextDirection direction) = 0; | |
| 125 virtual void NotifyTextDirection() = 0; | |
| 126 | |
| 127 virtual void Blur() = 0; | |
| 128 | |
| 129 // Enable renderer accessibility. This should only be called when a | |
| 130 // screenreader is detected. | |
| 131 virtual void EnableRendererAccessibility() = 0; | |
| 132 | |
| 133 // Forwards the given message to the renderer. These are called by | |
| 134 // the view when it has received a message. | |
| 135 virtual void ForwardMouseEvent( | |
| 136 const WebKit::WebMouseEvent& mouse_event) = 0; | |
| 137 virtual void ForwardWheelEvent( | |
| 138 const WebKit::WebMouseWheelEvent& wheel_event) = 0; | |
| 139 virtual void ForwardKeyboardEvent( | |
| 140 const NativeWebKeyboardEvent& key_event) = 0; | |
| 141 | |
| 142 // Get access to the widget's backing store. If a resize is in progress, | |
| 143 // then the current size of the backing store may be less than the size of | |
| 144 // the widget's view. If you pass |force_create| as true, then the backing | |
| 145 // store will be created if it doesn't exist. Otherwise, NULL will be returned | |
| 146 // if the backing store doesn't already exist. It will also return NULL if the | |
| 147 // backing store could not be created. | |
| 148 virtual BackingStore* GetBackingStore(bool force_create) = 0; | |
|
jam
2012/02/29 01:40:47
sorry my change conflicted with this!
Jói
2012/03/02 10:40:36
Hehe, no worries :)
| |
| 149 | |
| 150 virtual const gfx::Point& GetLastScrollOffset() const = 0; | |
| 151 | |
| 152 virtual content::RenderProcessHost* GetProcess() const = 0; | |
| 153 | |
| 154 virtual int GetRoutingID() const = 0; | |
| 155 | |
| 156 // Gets the View of this RenderWidgetHost. Can be NULL, e.g. if the | |
| 157 // RenderWidget is being destroyed or the render process crashed. You should | |
| 158 // never cache this pointer since it can become NULL if the renderer crashes, | |
| 159 // instead you should always ask for it using the accessor. | |
| 160 virtual content::RenderWidgetHostView* GetView() const = 0; | |
| 161 | |
| 162 // Returns true if this is a RenderViewHost, false if not. | |
| 163 virtual bool IsRenderView() const = 0; | |
| 164 | |
| 76 // Used as the details object for a | 165 // Used as the details object for a |
| 77 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification. | 166 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification. |
| 78 // TODO(joi): Switch out for a std::pair. | 167 // TODO(joi): Switch out for a std::pair. |
| 79 struct PaintAtSizeAckDetails { | 168 struct PaintAtSizeAckDetails { |
| 80 // The tag that was passed to the PaintAtSize() call that triggered this | 169 // The tag that was passed to the PaintAtSize() call that triggered this |
| 81 // ack. | 170 // ack. |
| 82 int tag; | 171 int tag; |
| 83 gfx::Size size; | 172 gfx::Size size; |
| 84 }; | 173 }; |
| 85 | 174 |
| 86 // This tells the renderer to paint into a bitmap and return it, | 175 // This tells the renderer to paint into a bitmap and return it, |
| 87 // regardless of whether the tab is hidden or not. It resizes the | 176 // regardless of whether the tab is hidden or not. It resizes the |
| 88 // web widget to match the |page_size| and then returns the bitmap | 177 // web widget to match the |page_size| and then returns the bitmap |
| 89 // scaled so it matches the |desired_size|, so that the scaling | 178 // scaled so it matches the |desired_size|, so that the scaling |
| 90 // happens on the rendering thread. When the bitmap is ready, the | 179 // happens on the rendering thread. When the bitmap is ready, the |
| 91 // renderer sends a PaintAtSizeACK to this host, and a | 180 // renderer sends a PaintAtSizeACK to this host, and a |
| 92 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification is issued. | 181 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification is issued. |
| 93 // Note that this bypasses most of the update logic that is normally invoked, | 182 // Note that this bypasses most of the update logic that is normally invoked, |
| 94 // and doesn't put the results into the backing store. | 183 // and doesn't put the results into the backing store. |
| 95 virtual void PaintAtSize(TransportDIB::Handle dib_handle, | 184 virtual void PaintAtSize(TransportDIB::Handle dib_handle, |
| 96 int tag, | 185 int tag, |
| 97 const gfx::Size& page_size, | 186 const gfx::Size& page_size, |
| 98 const gfx::Size& desired_size) = 0; | 187 const gfx::Size& desired_size) = 0; |
| 99 | 188 |
| 100 // Get access to the widget's backing store. If a resize is in progress, | 189 // Makes an IPC call to tell webkit to replace the currently selected word |
| 101 // then the current size of the backing store may be less than the size of | 190 // or a word around the cursor. |
| 102 // the widget's view. If you pass |force_create| as true, then the backing | 191 virtual void Replace(const string16& word) = 0; |
| 103 // store will be created if it doesn't exist. Otherwise, NULL will be returned | |
| 104 // if the backing store doesn't already exist. It will also return NULL if the | |
| 105 // backing store could not be created. | |
| 106 virtual BackingStore* GetBackingStore(bool force_create) = 0; | |
| 107 | 192 |
| 108 // Returns true if this is a RenderViewHost, false if not. | 193 // Called to notify the RenderWidget that the resize rect has changed without |
| 109 virtual bool IsRenderView() const = 0; | 194 // the size of the RenderWidget itself changing. |
| 195 virtual void ResizeRectChanged(const gfx::Rect& new_rect) = 0; | |
| 196 | |
| 197 // Restart the active hang monitor timeout. Clears all existing timeouts and | |
| 198 // starts with a new one. This can be because the renderer has become | |
| 199 // active, the tab is being hidden, or the user has chosen to wait some more | |
| 200 // to give the tab a chance to become active and we don't want to display a | |
| 201 // warning too soon. | |
| 202 virtual void RestartHangMonitorTimeout() = 0; | |
| 203 | |
| 204 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; | |
| 205 | |
| 206 // Stops loading the page. | |
| 207 virtual void Stop() = 0; | |
| 110 | 208 |
| 111 // Called to notify the RenderWidget that it has been resized. | 209 // Called to notify the RenderWidget that it has been resized. |
| 112 virtual void WasResized() = 0; | 210 virtual void WasResized() = 0; |
| 113 | 211 |
| 114 // TODO(joi): Get rid of these inline accessors and the associated | 212 // Access to the implementation's |
| 115 // data from the interface, make them into pure virtual GetFoo | 213 // IPC::Channel::Listener::OnMessageReceived. Intended only for |
| 116 // methods instead. | 214 // test code. |
| 117 content::RenderProcessHost* process() const { return process_; } | 215 virtual bool OnMessageReceivedForTesting(const IPC::Message& msg) = 0; |
| 118 | 216 |
| 119 // Gets the View of this RenderWidgetHost. Can be NULL, e.g. if the | 217 // Retrieves the implementation class. Intended only for code |
| 120 // RenderWidget is being destroyed or the render process crashed. You should | 218 // within content/. This method is necessary because |
| 121 // never cache this pointer since it can become NULL if the renderer crashes, | 219 // RenderWidgetHost is the root of a diamond inheritance pattern, so |
| 122 // instead you should always ask for it using the accessor. | 220 // subclasses inherit it virtually, which removes our ability to |
| 123 content::RenderWidgetHostView* view() const; | 221 // static_cast to the subclass. |
| 222 virtual RenderWidgetHostImpl* AsRWHImpl() = 0; | |
| 124 | 223 |
| 125 // Gets a RenderVidgetHost pointer from an IPC::Channel::Listener pointer. | 224 // Gets a RenderVidgetHost pointer from an IPC::Channel::Listener pointer. |
| 126 static RenderWidgetHost* FromIPCChannelListener( | 225 static RenderWidgetHost* FromIPCChannelListener( |
| 127 IPC::Channel::Listener* listener); | 226 IPC::Channel::Listener* listener); |
| 128 static const RenderWidgetHost* FromIPCChannelListener( | 227 static const RenderWidgetHost* FromIPCChannelListener( |
| 129 const IPC::Channel::Listener* listener); | 228 const IPC::Channel::Listener* listener); |
| 130 | |
| 131 protected: | |
| 132 // Created during construction but initialized during Init*(). Therefore, it | |
| 133 // is guaranteed never to be NULL, but its channel may be NULL if the | |
| 134 // renderer crashed, so you must always check that. | |
| 135 content::RenderProcessHost* process_; | |
| 136 | |
| 137 // The View associated with the RenderViewHost. The lifetime of this object | |
| 138 // is associated with the lifetime of the Render process. If the Renderer | |
| 139 // crashes, its View is destroyed and this pointer becomes NULL, even though | |
| 140 // render_view_host_ lives on to load another URL (creating a new View while | |
| 141 // doing so). | |
| 142 content::RenderWidgetHostViewPort* view_; | |
| 143 }; | 229 }; |
| 144 | 230 |
| 145 // This class manages the browser side of a browser<->renderer HWND connection. | 231 // This class manages the browser side of a browser<->renderer HWND connection. |
| 146 // The HWND lives in the browser process, and windows events are sent over | 232 // The HWND lives in the browser process, and windows events are sent over |
| 147 // IPC to the corresponding object in the renderer. The renderer paints into | 233 // IPC to the corresponding object in the renderer. The renderer paints into |
| 148 // shared memory, which we transfer to a backing store and blit to the screen | 234 // shared memory, which we transfer to a backing store and blit to the screen |
| 149 // when Windows sends us a WM_PAINT message. | 235 // when Windows sends us a WM_PAINT message. |
| 150 // | 236 // |
| 151 // How Shutdown Works | 237 // How Shutdown Works |
| 152 // | 238 // |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 // | 296 // |
| 211 // It should be noted that the RenderViewHost, not the RenderWidgetHost, | 297 // It should be noted that the RenderViewHost, not the RenderWidgetHost, |
| 212 // handles IPC messages relating to the render process going away, since the | 298 // handles IPC messages relating to the render process going away, since the |
| 213 // way a RenderViewHost (TabContents) handles the process dying is different to | 299 // way a RenderViewHost (TabContents) handles the process dying is different to |
| 214 // the way a select popup does. As such the RenderWidgetHostView handles these | 300 // the way a select popup does. As such the RenderWidgetHostView handles these |
| 215 // messages for select popups. This placement is more out of convenience than | 301 // messages for select popups. This placement is more out of convenience than |
| 216 // anything else. When the view is live, these messages are forwarded to it by | 302 // anything else. When the view is live, these messages are forwarded to it by |
| 217 // the RenderWidgetHost's IPC message map. | 303 // the RenderWidgetHost's IPC message map. |
| 218 // | 304 // |
| 219 // TODO(joi): Move to content namespace. | 305 // TODO(joi): Move to content namespace. |
| 220 class CONTENT_EXPORT RenderWidgetHostImpl : public RenderWidgetHost, | 306 class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, |
| 221 public IPC::Channel::Listener, | 307 public IPC::Channel::Listener { |
| 222 public IPC::Channel::Sender { | |
| 223 public: | 308 public: |
| 224 // routing_id can be MSG_ROUTING_NONE, in which case the next available | 309 // routing_id can be MSG_ROUTING_NONE, in which case the next available |
| 225 // routing id is taken from the RenderProcessHost. | 310 // routing id is taken from the RenderProcessHost. |
| 226 RenderWidgetHostImpl(content::RenderProcessHost* process, int routing_id); | 311 RenderWidgetHostImpl(content::RenderProcessHost* process, int routing_id); |
| 227 virtual ~RenderWidgetHostImpl(); | 312 virtual ~RenderWidgetHostImpl(); |
| 228 | 313 |
| 229 static RenderWidgetHostImpl* FromRWHV(content::RenderWidgetHostView* rwhv); | 314 static RenderWidgetHostImpl* FromRWHV(content::RenderWidgetHostView* rwhv); |
| 230 | 315 |
| 316 // RenderWidgetHost implementation. | |
| 317 virtual void Undo() OVERRIDE; | |
| 318 virtual void Redo() OVERRIDE; | |
| 319 virtual void Cut() OVERRIDE; | |
| 320 virtual void Copy() OVERRIDE; | |
| 321 virtual void CopyToFindPboard() OVERRIDE; | |
| 322 virtual void Paste() OVERRIDE; | |
| 323 virtual void PasteAndMatchStyle() OVERRIDE; | |
| 324 virtual void Delete() OVERRIDE; | |
| 325 virtual void SelectAll() OVERRIDE; | |
| 326 virtual void UpdateTextDirection(WebKit::WebTextDirection direction) OVERRIDE; | |
| 327 virtual void NotifyTextDirection() OVERRIDE; | |
| 328 virtual void Blur() OVERRIDE; | |
| 329 virtual void EnableRendererAccessibility() OVERRIDE; | |
| 330 virtual void ForwardMouseEvent( | |
| 331 const WebKit::WebMouseEvent& mouse_event) OVERRIDE; | |
| 332 virtual void ForwardWheelEvent( | |
| 333 const WebKit::WebMouseWheelEvent& wheel_event) OVERRIDE; | |
| 334 virtual void ForwardKeyboardEvent( | |
| 335 const NativeWebKeyboardEvent& key_event) OVERRIDE; | |
| 336 virtual BackingStore* GetBackingStore(bool force_create) OVERRIDE; | |
| 337 virtual const gfx::Point& GetLastScrollOffset() const OVERRIDE; | |
| 338 virtual content::RenderProcessHost* GetProcess() const OVERRIDE; | |
| 339 virtual int GetRoutingID() const OVERRIDE; | |
| 340 virtual content::RenderWidgetHostView* GetView() const OVERRIDE; | |
| 341 virtual bool IsRenderView() const OVERRIDE; | |
| 342 virtual void PaintAtSize(TransportDIB::Handle dib_handle, | |
| 343 int tag, | |
| 344 const gfx::Size& page_size, | |
| 345 const gfx::Size& desired_size) OVERRIDE; | |
| 346 virtual void Replace(const string16& word) OVERRIDE; | |
| 347 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; | |
| 348 virtual void RestartHangMonitorTimeout() OVERRIDE; | |
| 349 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; | |
| 350 virtual void Stop() OVERRIDE; | |
| 351 virtual void WasResized() OVERRIDE; | |
| 352 virtual bool OnMessageReceivedForTesting(const IPC::Message& msg) OVERRIDE; | |
| 353 virtual RenderWidgetHostImpl* AsRWHImpl() OVERRIDE; | |
| 354 | |
| 231 // Sets the View of this RenderWidgetHost. | 355 // Sets the View of this RenderWidgetHost. |
| 232 void SetView(content::RenderWidgetHostView* view); | 356 void SetView(content::RenderWidgetHostView* view); |
| 233 | 357 |
| 234 int routing_id() const { return routing_id_; } | |
| 235 int surface_id() const { return surface_id_; } | 358 int surface_id() const { return surface_id_; } |
| 236 bool renderer_accessible() { return renderer_accessible_; } | 359 bool renderer_accessible() { return renderer_accessible_; } |
| 237 | 360 |
| 238 bool empty() const { return current_size_.IsEmpty(); } | 361 bool empty() const { return current_size_.IsEmpty(); } |
| 239 | 362 |
| 240 // Returns the property bag for this widget, where callers can add extra data | 363 // Returns the property bag for this widget, where callers can add extra data |
| 241 // they may wish to associate with it. Returns a pointer rather than a | 364 // they may wish to associate with it. Returns a pointer rather than a |
| 242 // reference since the PropertyAccessors expect this. | 365 // reference since the PropertyAccessors expect this. |
| 243 const base::PropertyBag* property_bag() const { return &property_bag_; } | 366 const base::PropertyBag* property_bag() const { return &property_bag_; } |
| 244 base::PropertyBag* property_bag() { return &property_bag_; } | 367 base::PropertyBag* property_bag() { return &property_bag_; } |
| 245 | 368 |
| 246 // Called when a renderer object already been created for this host, and we | 369 // Called when a renderer object already been created for this host, and we |
| 247 // just need to be attached to it. Used for window.open, <select> dropdown | 370 // just need to be attached to it. Used for window.open, <select> dropdown |
| 248 // menus, and other times when the renderer initiates creating an object. | 371 // menus, and other times when the renderer initiates creating an object. |
| 249 void Init(); | 372 void Init(); |
| 250 | 373 |
| 251 // Tells the renderer to die and then calls Destroy(). | 374 // Tells the renderer to die and then calls Destroy(). |
| 252 virtual void Shutdown(); | 375 virtual void Shutdown(); |
| 253 | 376 |
| 254 // Manual RTTI FTW. We are not hosting a web page. | |
| 255 virtual bool IsRenderView() const OVERRIDE; | |
| 256 | |
| 257 // IPC::Channel::Listener | 377 // IPC::Channel::Listener |
| 258 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 378 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 259 | 379 |
| 260 // Sends a message to the corresponding object in the renderer. | 380 // Sends a message to the corresponding object in the renderer. |
| 261 virtual bool Send(IPC::Message* msg) OVERRIDE; | 381 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 262 | 382 |
| 263 // Called to notify the RenderWidget that it has been hidden or restored from | 383 // Called to notify the RenderWidget that it has been hidden or restored from |
| 264 // having been hidden. | 384 // having been hidden. |
| 265 void WasHidden(); | 385 void WasHidden(); |
| 266 void WasRestored(); | 386 void WasRestored(); |
| 267 | 387 |
| 268 virtual void WasResized() OVERRIDE; | |
| 269 | |
| 270 // Called to notify the RenderWidget that the resize rect has changed without | |
| 271 // the size of the RenderWidget itself changing. | |
| 272 void ResizeRectChanged(const gfx::Rect& new_rect); | |
| 273 | |
| 274 // Called to notify the RenderWidget that its associated native window got | 388 // Called to notify the RenderWidget that its associated native window got |
| 275 // focused. | 389 // focused. |
| 276 virtual void GotFocus(); | 390 virtual void GotFocus(); |
| 277 | 391 |
| 278 // Tells the renderer it got/lost focus. | 392 // Tells the renderer it got/lost focus. |
| 279 void Focus(); | 393 void Focus(); |
| 280 void Blur(); | |
| 281 virtual void LostCapture(); | 394 virtual void LostCapture(); |
| 282 | 395 |
| 283 // Sets whether the renderer should show controls in an active state. On all | 396 // Sets whether the renderer should show controls in an active state. On all |
| 284 // platforms except mac, that's the same as focused. On mac, the frontmost | 397 // platforms except mac, that's the same as focused. On mac, the frontmost |
| 285 // window will show active controls even if the focus is not in the web | 398 // window will show active controls even if the focus is not in the web |
| 286 // contents, but e.g. in the omnibox. | 399 // contents, but e.g. in the omnibox. |
| 287 void SetActive(bool active); | 400 void SetActive(bool active); |
| 288 | 401 |
| 289 // Called to notify the RenderWidget that it has lost the mouse lock. | 402 // Called to notify the RenderWidget that it has lost the mouse lock. |
| 290 virtual void LostMouseLock(); | 403 virtual void LostMouseLock(); |
| 291 | 404 |
| 292 // Tells us whether the page is rendered directly via the GPU process. | 405 // Tells us whether the page is rendered directly via the GPU process. |
| 293 bool is_accelerated_compositing_active() { | 406 bool is_accelerated_compositing_active() { |
| 294 return is_accelerated_compositing_active_; | 407 return is_accelerated_compositing_active_; |
| 295 } | 408 } |
| 296 | 409 |
| 297 // Notifies the RenderWidgetHost that the View was destroyed. | 410 // Notifies the RenderWidgetHost that the View was destroyed. |
| 298 void ViewDestroyed(); | 411 void ViewDestroyed(); |
| 299 | 412 |
| 300 // Indicates if the page has finished loading. | 413 // Indicates if the page has finished loading. |
| 301 void SetIsLoading(bool is_loading); | 414 void SetIsLoading(bool is_loading); |
| 302 | 415 |
| 303 virtual void PaintAtSize(TransportDIB::Handle dib_handle, | |
| 304 int tag, | |
| 305 const gfx::Size& page_size, | |
| 306 const gfx::Size& desired_size) OVERRIDE; | |
| 307 | |
| 308 virtual BackingStore* GetBackingStore(bool force_create) OVERRIDE; | |
| 309 | |
| 310 // Allocate a new backing store of the given size. Returns NULL on failure | 416 // Allocate a new backing store of the given size. Returns NULL on failure |
| 311 // (for example, if we don't currently have a RenderWidgetHostView.) | 417 // (for example, if we don't currently have a RenderWidgetHostView.) |
| 312 BackingStore* AllocBackingStore(const gfx::Size& size); | 418 BackingStore* AllocBackingStore(const gfx::Size& size); |
| 313 | 419 |
| 314 // When a backing store does asynchronous painting, it will call this function | 420 // When a backing store does asynchronous painting, it will call this function |
| 315 // when it is done with the DIB. We will then forward a message to the | 421 // when it is done with the DIB. We will then forward a message to the |
| 316 // renderer to send another paint. | 422 // renderer to send another paint. |
| 317 void DonePaintingToBackingStore(); | 423 void DonePaintingToBackingStore(); |
| 318 | 424 |
| 319 // GPU accelerated version of GetBackingStore function. This will | 425 // GPU accelerated version of GetBackingStore function. This will |
| 320 // trigger a re-composite to the view. If a resize is pending, it will | 426 // trigger a re-composite to the view. If a resize is pending, it will |
| 321 // block briefly waiting for an ack from the renderer. | 427 // block briefly waiting for an ack from the renderer. |
| 322 void ScheduleComposite(); | 428 void ScheduleComposite(); |
| 323 | 429 |
| 324 // Starts a hang monitor timeout. If there's already a hang monitor timeout | 430 // Starts a hang monitor timeout. If there's already a hang monitor timeout |
| 325 // the new one will only fire if it has a shorter delay than the time | 431 // the new one will only fire if it has a shorter delay than the time |
| 326 // left on the existing timeouts. | 432 // left on the existing timeouts. |
| 327 void StartHangMonitorTimeout(base::TimeDelta delay); | 433 void StartHangMonitorTimeout(base::TimeDelta delay); |
| 328 | 434 |
| 329 // Restart the active hang monitor timeout. Clears all existing timeouts and | |
| 330 // starts with a new one. This can be because the renderer has become | |
| 331 // active, the tab is being hidden, or the user has chosen to wait some more | |
| 332 // to give the tab a chance to become active and we don't want to display a | |
| 333 // warning too soon. | |
| 334 void RestartHangMonitorTimeout(); | |
| 335 | |
| 336 // Stops all existing hang monitor timeouts and assumes the renderer is | 435 // Stops all existing hang monitor timeouts and assumes the renderer is |
| 337 // responsive. | 436 // responsive. |
| 338 void StopHangMonitorTimeout(); | 437 void StopHangMonitorTimeout(); |
| 339 | 438 |
| 340 // Forwards the given message to the renderer. These are called by the view | 439 // Forwards the given message to the renderer. These are called by the view |
| 341 // when it has received a message. | 440 // when it has received a message. |
| 342 virtual void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event); | 441 void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event); |
| 442 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event); | |
| 443 | |
| 444 void CancelUpdateTextDirection(); | |
| 445 | |
| 343 // Called when a mouse click activates the renderer. | 446 // Called when a mouse click activates the renderer. |
| 344 virtual void OnMouseActivate(); | 447 virtual void OnMouseActivate(); |
| 345 void ForwardWheelEvent(const WebKit::WebMouseWheelEvent& wheel_event); | |
| 346 void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event); | |
| 347 virtual void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event); | |
| 348 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event); | |
| 349 | |
| 350 // Update the text direction of the focused input element and notify it to a | |
| 351 // renderer process. | |
| 352 // These functions have two usage scenarios: changing the text direction | |
| 353 // from a menu (as Safari does), and; changing the text direction when a user | |
| 354 // presses a set of keys (as IE and Firefox do). | |
| 355 // 1. Change the text direction from a menu. | |
| 356 // In this scenario, we receive a menu event only once and we should update | |
| 357 // the text direction immediately when a user chooses a menu item. So, we | |
| 358 // should call both functions at once as listed in the following snippet. | |
| 359 // void RenderViewHost::SetTextDirection(WebTextDirection direction) { | |
| 360 // UpdateTextDirection(direction); | |
| 361 // NotifyTextDirection(); | |
| 362 // } | |
| 363 // 2. Change the text direction when pressing a set of keys. | |
| 364 // Because of auto-repeat, we may receive the same key-press event many | |
| 365 // times while we presses the keys and it is nonsense to send the same IPC | |
| 366 // message every time when we receive a key-press event. | |
| 367 // To suppress the number of IPC messages, we just update the text direction | |
| 368 // when receiving a key-press event and send an IPC message when we release | |
| 369 // the keys as listed in the following snippet. | |
| 370 // if (key_event.type == WebKeyboardEvent::KEY_DOWN) { | |
| 371 // if (key_event.windows_key_code == 'A' && | |
| 372 // key_event.modifiers == WebKeyboardEvent::CTRL_KEY) { | |
| 373 // UpdateTextDirection(dir); | |
| 374 // } else { | |
| 375 // CancelUpdateTextDirection(); | |
| 376 // } | |
| 377 // } else if (key_event.type == WebKeyboardEvent::KEY_UP) { | |
| 378 // NotifyTextDirection(); | |
| 379 // } | |
| 380 // Once we cancel updating the text direction, we have to ignore all | |
| 381 // succeeding UpdateTextDirection() requests until calling | |
| 382 // NotifyTextDirection(). (We may receive keydown events even after we | |
| 383 // canceled updating the text direction because of auto-repeat.) | |
| 384 // Note: we cannot undo this change for compatibility with Firefox and IE. | |
| 385 void UpdateTextDirection(WebKit::WebTextDirection direction); | |
| 386 void CancelUpdateTextDirection(); | |
| 387 void NotifyTextDirection(); | |
| 388 | 448 |
| 389 // Notifies the renderer whether or not the input method attached to this | 449 // Notifies the renderer whether or not the input method attached to this |
| 390 // process is activated. | 450 // process is activated. |
| 391 // When the input method is activated, a renderer process sends IPC messages | 451 // When the input method is activated, a renderer process sends IPC messages |
| 392 // to notify the status of its composition node. (This message is mainly used | 452 // to notify the status of its composition node. (This message is mainly used |
| 393 // for notifying the position of the input cursor so that the browser can | 453 // for notifying the position of the input cursor so that the browser can |
| 394 // display input method windows under the cursor.) | 454 // display input method windows under the cursor.) |
| 395 void SetInputMethodActive(bool activate); | 455 void SetInputMethodActive(bool activate); |
| 396 | 456 |
| 397 // Update the composition node of the renderer (or WebKit). | 457 // Update the composition node of the renderer (or WebKit). |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 // SetComposition() call. | 489 // SetComposition() call. |
| 430 void ImeConfirmComposition(); | 490 void ImeConfirmComposition(); |
| 431 | 491 |
| 432 // Cancels an ongoing composition. | 492 // Cancels an ongoing composition. |
| 433 void ImeCancelComposition(); | 493 void ImeCancelComposition(); |
| 434 | 494 |
| 435 // This is for derived classes to give us access to the resizer rect. | 495 // This is for derived classes to give us access to the resizer rect. |
| 436 // And to also expose it to the RenderWidgetHostView. | 496 // And to also expose it to the RenderWidgetHostView. |
| 437 virtual gfx::Rect GetRootWindowResizerRect() const; | 497 virtual gfx::Rect GetRootWindowResizerRect() const; |
| 438 | 498 |
| 439 // Makes an IPC call to tell webkit to replace the currently selected word | |
| 440 // or a word around the cursor. | |
| 441 void Replace(const string16& word); | |
| 442 | |
| 443 // Enable renderer accessibility. This should only be called when a | |
| 444 // screenreader is detected. | |
| 445 void EnableRendererAccessibility(); | |
| 446 | |
| 447 void set_ignore_input_events(bool ignore_input_events) { | |
| 448 ignore_input_events_ = ignore_input_events; | |
| 449 } | |
| 450 bool ignore_input_events() const { | 499 bool ignore_input_events() const { |
| 451 return ignore_input_events_; | 500 return ignore_input_events_; |
| 452 } | 501 } |
| 453 | 502 |
| 454 // Activate deferred plugin handles. | 503 // Activate deferred plugin handles. |
| 455 void ActivateDeferredPluginHandles(); | 504 void ActivateDeferredPluginHandles(); |
| 456 | 505 |
| 457 const gfx::Point& last_scroll_offset() const { return last_scroll_offset_; } | |
| 458 | |
| 459 bool has_touch_handler() const { return has_touch_handler_; } | 506 bool has_touch_handler() const { return has_touch_handler_; } |
| 460 | 507 |
| 461 // Notification that the user has made some kind of input that could | 508 // Notification that the user has made some kind of input that could |
| 462 // perform an action. See OnUserGesture for more details. | 509 // perform an action. See OnUserGesture for more details. |
| 463 void StartUserGesture(); | 510 void StartUserGesture(); |
| 464 | 511 |
| 465 // Stops loading the page. | |
| 466 void Stop(); | |
| 467 | |
| 468 // Set the RenderView background. | 512 // Set the RenderView background. |
| 469 void SetBackground(const SkBitmap& background); | 513 void SetBackground(const SkBitmap& background); |
| 470 | 514 |
| 471 // Notifies the renderer that the next key event is bound to one or more | 515 // Notifies the renderer that the next key event is bound to one or more |
| 472 // pre-defined edit commands | 516 // pre-defined edit commands |
| 473 void SetEditCommandsForNextKeyEvent( | 517 void SetEditCommandsForNextKeyEvent( |
| 474 const std::vector<EditCommand>& commands); | 518 const std::vector<EditCommand>& commands); |
| 475 | 519 |
| 476 // Relay a request from assistive technology to perform the default action | 520 // Relay a request from assistive technology to perform the default action |
| 477 // on a given node. | 521 // on a given node. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 502 const std::string& value); | 546 const std::string& value); |
| 503 | 547 |
| 504 // Tells the renderer to scroll the currently focused node into rect only if | 548 // Tells the renderer to scroll the currently focused node into rect only if |
| 505 // the currently focused node is a Text node (textfield, text area or content | 549 // the currently focused node is a Text node (textfield, text area or content |
| 506 // editable divs). | 550 // editable divs). |
| 507 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); | 551 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); |
| 508 | 552 |
| 509 // Requests the renderer to select the region between two points. | 553 // Requests the renderer to select the region between two points. |
| 510 void SelectRange(const gfx::Point& start, const gfx::Point& end); | 554 void SelectRange(const gfx::Point& start, const gfx::Point& end); |
| 511 | 555 |
| 512 // Edit operations. | |
| 513 void Undo(); | |
| 514 void Redo(); | |
| 515 void Cut(); | |
| 516 void Copy(); | |
| 517 void CopyToFindPboard(); | |
| 518 void Paste(); | |
| 519 void PasteAndMatchStyle(); | |
| 520 void Delete(); | |
| 521 void SelectAll(); | |
| 522 | |
| 523 // Called when the reponse to a pending mouse lock request has arrived. | 556 // Called when the reponse to a pending mouse lock request has arrived. |
| 524 // Returns true if |allowed| is true and the mouse has been successfully | 557 // Returns true if |allowed| is true and the mouse has been successfully |
| 525 // locked. | 558 // locked. |
| 526 bool GotResponseToLockMouseRequest(bool allowed); | 559 bool GotResponseToLockMouseRequest(bool allowed); |
| 527 | 560 |
| 528 // Called by the view in response to AcceleratedSurfaceBuffersSwapped. | 561 // Called by the view in response to AcceleratedSurfaceBuffersSwapped. |
| 529 static void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id); | 562 static void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id); |
| 530 static void AcknowledgePostSubBuffer(int32 route_id, int gpu_host_id); | 563 static void AcknowledgePostSubBuffer(int32 route_id, int gpu_host_id); |
| 531 | 564 |
| 532 protected: | 565 protected: |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 bool IsMouseLocked() const; | 625 bool IsMouseLocked() const; |
| 593 | 626 |
| 594 // RenderViewHost overrides this method to report when in fullscreen mode. | 627 // RenderViewHost overrides this method to report when in fullscreen mode. |
| 595 virtual bool IsFullscreen() const; | 628 virtual bool IsFullscreen() const; |
| 596 | 629 |
| 597 // Indicates if the render widget host should track the render widget's size | 630 // Indicates if the render widget host should track the render widget's size |
| 598 // as opposed to visa versa. | 631 // as opposed to visa versa. |
| 599 void SetShouldAutoResize(bool enable); | 632 void SetShouldAutoResize(bool enable); |
| 600 | 633 |
| 601 protected: | 634 protected: |
| 635 // The View associated with the RenderViewHost. The lifetime of this object | |
| 636 // is associated with the lifetime of the Render process. If the Renderer | |
| 637 // crashes, its View is destroyed and this pointer becomes NULL, even though | |
| 638 // render_view_host_ lives on to load another URL (creating a new View while | |
| 639 // doing so). | |
| 640 content::RenderWidgetHostViewPort* view_; | |
| 641 | |
| 602 // true if a renderer has once been valid. We use this flag to display a sad | 642 // true if a renderer has once been valid. We use this flag to display a sad |
| 603 // tab only when we lose our renderer and not if a paint occurs during | 643 // tab only when we lose our renderer and not if a paint occurs during |
| 604 // initialization. | 644 // initialization. |
| 605 bool renderer_initialized_; | 645 bool renderer_initialized_; |
| 606 | 646 |
| 607 // This value indicates how long to wait before we consider a renderer hung. | 647 // This value indicates how long to wait before we consider a renderer hung. |
| 608 int hung_renderer_delay_ms_; | 648 int hung_renderer_delay_ms_; |
| 609 | 649 |
| 610 private: | 650 private: |
| 611 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostTest, Resize); | 651 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostTest, Resize); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 // Called by OnMsgInputEventAck() to process a wheel event ack message. | 749 // Called by OnMsgInputEventAck() to process a wheel event ack message. |
| 710 // This could result in a task being posted to allow additional wheel | 750 // This could result in a task being posted to allow additional wheel |
| 711 // input messages to be coalesced. | 751 // input messages to be coalesced. |
| 712 void ProcessWheelAck(bool processed); | 752 void ProcessWheelAck(bool processed); |
| 713 | 753 |
| 714 // Called on OnMsgInputEventAck() to process a touch event ack message. | 754 // Called on OnMsgInputEventAck() to process a touch event ack message. |
| 715 // This can result in a gesture event being generated and sent back to the | 755 // This can result in a gesture event being generated and sent back to the |
| 716 // renderer. | 756 // renderer. |
| 717 void ProcessTouchAck(bool processed); | 757 void ProcessTouchAck(bool processed); |
| 718 | 758 |
| 759 // Created during construction but initialized during Init*(). Therefore, it | |
| 760 // is guaranteed never to be NULL, but its channel may be NULL if the | |
| 761 // renderer crashed, so you must always check that. | |
| 762 content::RenderProcessHost* process_; | |
| 763 | |
| 764 // The ID of the corresponding object in the Renderer Instance. | |
| 765 int routing_id_; | |
| 766 | |
| 719 // True if renderer accessibility is enabled. This should only be set when a | 767 // True if renderer accessibility is enabled. This should only be set when a |
| 720 // screenreader is detected as it can potentially slow down Chrome. | 768 // screenreader is detected as it can potentially slow down Chrome. |
| 721 bool renderer_accessible_; | 769 bool renderer_accessible_; |
| 722 | 770 |
| 723 // Stores random bits of data for others to associate with this object. | 771 // Stores random bits of data for others to associate with this object. |
| 724 base::PropertyBag property_bag_; | 772 base::PropertyBag property_bag_; |
| 725 | 773 |
| 726 // The ID of the corresponding object in the Renderer Instance. | |
| 727 int routing_id_; | |
| 728 | |
| 729 // The ID of the surface corresponding to this render widget. | 774 // The ID of the surface corresponding to this render widget. |
| 730 int surface_id_; | 775 int surface_id_; |
| 731 | 776 |
| 732 // Indicates whether a page is loading or not. | 777 // Indicates whether a page is loading or not. |
| 733 bool is_loading_; | 778 bool is_loading_; |
| 734 | 779 |
| 735 // Indicates whether a page is hidden or not. | 780 // Indicates whether a page is hidden or not. |
| 736 bool is_hidden_; | 781 bool is_hidden_; |
| 737 | 782 |
| 738 // True when a page is rendered directly via the GPU process. | 783 // True when a page is rendered directly via the GPU process. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 // then touch events are sent to the renderer. Otherwise, the touch events are | 906 // then touch events are sent to the renderer. Otherwise, the touch events are |
| 862 // not sent to the renderer. | 907 // not sent to the renderer. |
| 863 bool has_touch_handler_; | 908 bool has_touch_handler_; |
| 864 | 909 |
| 865 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; | 910 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; |
| 866 | 911 |
| 867 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 912 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
| 868 }; | 913 }; |
| 869 | 914 |
| 870 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 915 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| OLD | NEW |