| 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 BrowserPluginEmbedder handles messages coming from a BrowserPlugin's | 5 // A BrowserPluginEmbedder handles messages coming from a BrowserPlugin's |
| 6 // embedder that are not directed at any particular existing guest process. | 6 // embedder that are not directed at any particular existing guest process. |
| 7 // In the beginning, when a BrowserPlugin instance in the embedder renderer | 7 // In the beginning, when a BrowserPlugin instance in the embedder renderer |
| 8 // process requests an initial navigation, the WebContents for that renderer | 8 // process requests an initial navigation, the WebContents for that renderer |
| 9 // renderer creates a BrowserPluginEmbedder for itself. The | 9 // renderer creates a BrowserPluginEmbedder for itself. The |
| 10 // BrowserPluginEmbedder, in turn, forwards the requests to a | 10 // BrowserPluginEmbedder, in turn, forwards the requests to a |
| 11 // BrowserPluginGuestManager, which creates and manages the lifetime of the new | 11 // BrowserPluginGuestManager, which creates and manages the lifetime of the new |
| 12 // guest. | 12 // guest. |
| 13 | 13 |
| 14 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 14 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
| 15 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 15 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
| 16 | 16 |
| 17 #include <map> | 17 #include <map> |
| 18 | 18 |
| 19 #include "base/memory/weak_ptr.h" |
| 19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
| 21 | 23 |
| 22 struct BrowserPluginHostMsg_CreateGuest_Params; | 24 struct BrowserPluginHostMsg_CreateGuest_Params; |
| 23 struct BrowserPluginHostMsg_ResizeGuest_Params; | 25 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 24 | 26 |
| 25 namespace gfx { | 27 namespace gfx { |
| 26 class Point; | 28 class Point; |
| 27 } | 29 } |
| 28 | 30 |
| 29 namespace content { | 31 namespace content { |
| 30 | 32 |
| 33 class BrowserPluginGuest; |
| 31 class BrowserPluginGuestManager; | 34 class BrowserPluginGuestManager; |
| 32 class BrowserPluginHostFactory; | 35 class BrowserPluginHostFactory; |
| 33 class WebContentsImpl; | 36 class WebContentsImpl; |
| 34 | 37 |
| 35 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver { | 38 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver { |
| 36 public: | 39 public: |
| 37 virtual ~BrowserPluginEmbedder(); | 40 virtual ~BrowserPluginEmbedder(); |
| 38 | 41 |
| 39 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents); | 42 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents); |
| 40 | 43 |
| 41 // Returns the RenderViewHost at a point (|x|, |y|) asynchronously via | 44 // Returns the RenderViewHost at a point (|x|, |y|) asynchronously via |
| 42 // |callback|. We need a roundtrip to renderer process to get this | 45 // |callback|. We need a roundtrip to renderer process to get this |
| 43 // information. | 46 // information. |
| 44 void GetRenderViewHostAtPosition( | 47 void GetRenderViewHostAtPosition( |
| 45 int x, | 48 int x, |
| 46 int y, | 49 int y, |
| 47 const WebContents::GetRenderViewHostCallback& callback); | 50 const WebContents::GetRenderViewHostCallback& callback); |
| 48 | 51 |
| 49 // Overrides factory for testing. Default (NULL) value indicates regular | 52 // Overrides factory for testing. Default (NULL) value indicates regular |
| 50 // (non-test) environment. | 53 // (non-test) environment. |
| 51 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { | 54 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { |
| 52 factory_ = factory; | 55 factory_ = factory; |
| 53 } | 56 } |
| 54 | 57 |
| 55 // WebContentsObserver implementation. | 58 // WebContentsObserver implementation. |
| 56 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 59 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 60 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 61 virtual void SystemDragEnded() OVERRIDE; |
| 62 |
| 63 void DragSourceEndedAt(int client_x, int client_y, int screen_x, |
| 64 int screen_y, WebKit::WebDragOperation operation); |
| 65 |
| 66 void DragSourceMovedTo(int client_x, int client_y, |
| 67 int screen_x, int screen_y); |
| 68 |
| 69 void OnUpdateDragCursor(bool* handled); |
| 70 |
| 71 void DragEnteredGuest(BrowserPluginGuest* guest); |
| 72 |
| 73 void DragLeftGuest(BrowserPluginGuest* guest); |
| 74 |
| 75 void StartDrag(BrowserPluginGuest* guest); |
| 76 |
| 77 void StopDrag(BrowserPluginGuest* guest); |
| 58 | 78 |
| 59 private: | 79 private: |
| 60 friend class TestBrowserPluginEmbedder; | 80 friend class TestBrowserPluginEmbedder; |
| 61 | 81 |
| 62 BrowserPluginEmbedder(WebContentsImpl* web_contents); | 82 BrowserPluginEmbedder(WebContentsImpl* web_contents); |
| 63 | 83 |
| 64 void CleanUp(); | 84 void CleanUp(); |
| 65 | 85 |
| 66 BrowserPluginGuestManager* GetBrowserPluginGuestManager(); | 86 BrowserPluginGuestManager* GetBrowserPluginGuestManager(); |
| 67 | 87 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 81 | 101 |
| 82 // Map that contains outstanding queries to |GetRenderViewHostAtPosition|. | 102 // Map that contains outstanding queries to |GetRenderViewHostAtPosition|. |
| 83 // We need a roundtrip to the renderer process to retrieve the answer, | 103 // We need a roundtrip to the renderer process to retrieve the answer, |
| 84 // so we store these callbacks until we hear back from the renderer. | 104 // so we store these callbacks until we hear back from the renderer. |
| 85 typedef std::map<int, WebContents::GetRenderViewHostCallback> | 105 typedef std::map<int, WebContents::GetRenderViewHostCallback> |
| 86 GetRenderViewHostCallbackMap; | 106 GetRenderViewHostCallbackMap; |
| 87 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; | 107 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; |
| 88 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. | 108 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. |
| 89 int next_get_render_view_request_id_; | 109 int next_get_render_view_request_id_; |
| 90 | 110 |
| 111 // Used to correctly update the cursor when dragging over a guest, and to |
| 112 // handle a race condition when dropping onto the guest that started the drag |
| 113 // (the race is that the dragend message arrives before the drop message so |
| 114 // the drop never takes place). |
| 115 // crbug.com/233571 |
| 116 base::WeakPtr<BrowserPluginGuest> guest_dragging_over_; |
| 117 |
| 118 // Pointer to the guest that started the drag, used to forward necessary drag |
| 119 // status messages to the correct guest. |
| 120 base::WeakPtr<BrowserPluginGuest> guest_started_drag_; |
| 121 |
| 91 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); | 122 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); |
| 92 }; | 123 }; |
| 93 | 124 |
| 94 } // namespace content | 125 } // namespace content |
| 95 | 126 |
| 96 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 127 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
| OLD | NEW |