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 // A BrowserPluginGuest is the browser side of a browser <--> embedder | 5 // A BrowserPluginGuest is the browser side of a browser <--> embedder |
6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder | 6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder |
7 // renderer side of browser <--> embedder renderer communication. | 7 // renderer side of browser <--> embedder renderer communication. |
8 // | 8 // |
9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a | 9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a |
10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The | 10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The |
11 // helper object intercepts messages (ViewHostMsg_*) directed at the browser | 11 // helper object intercepts messages (ViewHostMsg_*) directed at the browser |
12 // process and redirects them to this class. Any messages about the guest render | 12 // process and redirects them to this class. Any messages about the guest render |
13 // process that the embedder might be interested in receiving should be listened | 13 // process that the embedder might be interested in receiving should be listened |
14 // for here. | 14 // for here. |
15 // | 15 // |
16 // BrowserPluginGuest is a WebContentsDelegate and WebContentsObserver for the | 16 // BrowserPluginGuest is a WebContentsDelegate and WebContentsObserver for the |
17 // guest WebContents. BrowserPluginGuest operates under the assumption that the | 17 // guest WebContents. BrowserPluginGuest operates under the assumption that the |
18 // guest will be accessible through only one RenderViewHost for the lifetime of | 18 // guest will be accessible through only one RenderViewHost for the lifetime of |
19 // the guest WebContents. Thus, cross-process navigation is not supported. | 19 // the guest WebContents. Thus, cross-process navigation is not supported. |
20 | 20 |
21 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 21 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
22 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 22 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
23 | 23 |
24 #include <map> | 24 #include <map> |
25 | 25 |
26 #include "base/compiler_specific.h" | 26 #include "base/compiler_specific.h" |
27 #include "base/id_map.h" | 27 #include "base/id_map.h" |
| 28 #include "base/memory/weak_ptr.h" |
28 #include "base/shared_memory.h" | 29 #include "base/shared_memory.h" |
29 #include "base/time.h" | 30 #include "base/time.h" |
30 #include "content/port/common/input_event_ack_state.h" | 31 #include "content/port/common/input_event_ack_state.h" |
31 #include "content/public/browser/notification_observer.h" | 32 #include "content/public/browser/notification_observer.h" |
32 #include "content/public/browser/notification_registrar.h" | 33 #include "content/public/browser/notification_registrar.h" |
33 #include "content/public/browser/web_contents_delegate.h" | 34 #include "content/public/browser/web_contents_delegate.h" |
34 #include "content/public/browser/web_contents_observer.h" | 35 #include "content/public/browser/web_contents_observer.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
(...skipping 12 matching lines...) Expand all Loading... |
50 struct WebDropData; | 51 struct WebDropData; |
51 | 52 |
52 namespace WebKit { | 53 namespace WebKit { |
53 class WebInputEvent; | 54 class WebInputEvent; |
54 } | 55 } |
55 | 56 |
56 namespace content { | 57 namespace content { |
57 | 58 |
58 class BrowserPluginHostFactory; | 59 class BrowserPluginHostFactory; |
59 class BrowserPluginEmbedder; | 60 class BrowserPluginEmbedder; |
| 61 class DragEventSourceInfo; |
60 class RenderProcessHost; | 62 class RenderProcessHost; |
61 | 63 |
62 // A browser plugin guest provides functionality for WebContents to operate in | 64 // A browser plugin guest provides functionality for WebContents to operate in |
63 // the guest role and implements guest specific overrides for ViewHostMsg_* | 65 // the guest role and implements guest specific overrides for ViewHostMsg_* |
64 // messages. | 66 // messages. |
65 // | 67 // |
66 // BrowserPluginEmbedder is responsible for creating and destroying a guest. | 68 // BrowserPluginEmbedder is responsible for creating and destroying a guest. |
67 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, | 69 class CONTENT_EXPORT BrowserPluginGuest |
68 public WebContentsDelegate, | 70 : public NotificationObserver, |
69 public WebContentsObserver { | 71 public WebContentsDelegate, |
| 72 public WebContentsObserver, |
| 73 public base::SupportsWeakPtr<BrowserPluginGuest> { |
70 public: | 74 public: |
71 virtual ~BrowserPluginGuest(); | 75 virtual ~BrowserPluginGuest(); |
72 | 76 |
73 static BrowserPluginGuest* Create( | 77 static BrowserPluginGuest* Create( |
74 int instance_id, | 78 int instance_id, |
75 WebContentsImpl* web_contents, | 79 WebContentsImpl* web_contents, |
76 const BrowserPluginHostMsg_CreateGuest_Params& params); | 80 const BrowserPluginHostMsg_CreateGuest_Params& params); |
77 | 81 |
78 // Overrides factory for testing. Default (NULL) value indicates regular | 82 // Overrides factory for testing. Default (NULL) value indicates regular |
79 // (non-test) environment. | 83 // (non-test) environment. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, | 257 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, |
254 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params); | 258 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params); |
255 | 259 |
256 | 260 |
257 // Message handlers for messages from guest. | 261 // Message handlers for messages from guest. |
258 | 262 |
259 void OnCreateWindow(const ViewHostMsg_CreateWindow_Params& params, | 263 void OnCreateWindow(const ViewHostMsg_CreateWindow_Params& params, |
260 int* route_id, | 264 int* route_id, |
261 int* surface_id, | 265 int* surface_id, |
262 int64* cloned_session_storage_namespace_id); | 266 int64* cloned_session_storage_namespace_id); |
| 267 void OnDragStopped(); |
263 void OnHandleInputEventAck( | 268 void OnHandleInputEventAck( |
264 WebKit::WebInputEvent::Type event_type, | 269 WebKit::WebInputEvent::Type event_type, |
265 InputEventAckState ack_result); | 270 InputEventAckState ack_result); |
266 void OnHasTouchEventHandlers(bool accept); | 271 void OnHasTouchEventHandlers(bool accept); |
267 void OnSetCursor(const WebCursor& cursor); | 272 void OnSetCursor(const WebCursor& cursor); |
268 // On MacOSX popups are painted by the browser process. We handle them here | 273 // On MacOSX popups are painted by the browser process. We handle them here |
269 // so that they are positioned correctly. | 274 // so that they are positioned correctly. |
270 #if defined(OS_MACOSX) | 275 #if defined(OS_MACOSX) |
271 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); | 276 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); |
272 #endif | 277 #endif |
273 void OnShowWidget(int route_id, const gfx::Rect& initial_pos); | 278 void OnShowWidget(int route_id, const gfx::Rect& initial_pos); |
| 279 void OnStartDragging(bool* handled); |
274 // Overriden in tests. | 280 // Overriden in tests. |
275 virtual void OnTakeFocus(bool reverse); | 281 virtual void OnTakeFocus(bool reverse); |
276 void OnUpdateDragCursor(WebKit::WebDragOperation operation); | |
277 void OnUpdateFrameName(int frame_id, | 282 void OnUpdateFrameName(int frame_id, |
278 bool is_top_level, | 283 bool is_top_level, |
279 const std::string& name); | 284 const std::string& name); |
280 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 285 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
281 | 286 |
282 // Static factory instance (always NULL for non-test). | 287 // Static factory instance (always NULL for non-test). |
283 static content::BrowserPluginHostFactory* factory_; | 288 static content::BrowserPluginHostFactory* factory_; |
284 | 289 |
285 NotificationRegistrar notification_registrar_; | 290 NotificationRegistrar notification_registrar_; |
286 WebContentsImpl* embedder_web_contents_; | 291 WebContentsImpl* embedder_web_contents_; |
(...skipping 15 matching lines...) Expand all Loading... |
302 bool auto_size_enabled_; | 307 bool auto_size_enabled_; |
303 gfx::Size max_auto_size_; | 308 gfx::Size max_auto_size_; |
304 gfx::Size min_auto_size_; | 309 gfx::Size min_auto_size_; |
305 | 310 |
306 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 311 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
307 }; | 312 }; |
308 | 313 |
309 } // namespace content | 314 } // namespace content |
310 | 315 |
311 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 316 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |