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 has a list of guests it manages. | 5 // A BrowserPluginEmbedder has a list of guests it manages. |
6 // In the beginning when a renderer sees one or more guests (BrowserPlugin | 6 // In the beginning when a renderer sees one or more guests (BrowserPlugin |
7 // instance(s)) and there is a request to navigate to them, the WebContents for | 7 // instance(s)) and there is a request to navigate to them, the WebContents for |
8 // that renderer creates a BrowserPluginEmbedder for itself. The | 8 // that renderer creates a BrowserPluginEmbedder for itself. The |
9 // BrowserPluginEmbedder, in turn, manages a set of BrowserPluginGuests -- one | 9 // BrowserPluginEmbedder, in turn, manages a set of BrowserPluginGuests -- one |
10 // BrowserPluginGuest for each guest in the embedding WebContents. Note that | 10 // BrowserPluginGuest for each guest in the embedding WebContents. Note that |
11 // each of these BrowserPluginGuest objects has its own WebContents. | 11 // each of these BrowserPluginGuest objects has its own WebContents. |
12 // BrowserPluginEmbedder routes any messages directed to a guest from the | 12 // BrowserPluginEmbedder routes any messages directed to a guest from the |
13 // renderer (BrowserPlugin) to the appropriate guest (identified by the guest's | 13 // renderer (BrowserPlugin) to the appropriate guest (identified by the guest's |
14 // |instance_id|). | 14 // |instance_id|). |
15 // | 15 // |
16 // BrowserPluginEmbedder is responsible for cleaning up the guests when the | 16 // BrowserPluginEmbedder is responsible for cleaning up the guests when the |
17 // embedder frame navigates away to a different page or deletes the guests from | 17 // embedder frame navigates away to a different page or deletes the guests from |
18 // the existing page. | 18 // the existing page. |
19 | 19 |
20 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 20 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
21 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 21 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
22 | 22 |
23 #include <map> | 23 #include <map> |
24 | 24 |
| 25 #include "base/memory/weak_ptr.h" |
25 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
26 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
29 | 30 |
30 struct BrowserPluginHostMsg_CreateGuest_Params; | 31 struct BrowserPluginHostMsg_CreateGuest_Params; |
31 struct BrowserPluginHostMsg_ResizeGuest_Params; | 32 struct BrowserPluginHostMsg_ResizeGuest_Params; |
32 | 33 |
33 namespace gfx { | 34 namespace gfx { |
34 class Point; | 35 class Point; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void GetRenderViewHostAtPosition( | 90 void GetRenderViewHostAtPosition( |
90 int x, | 91 int x, |
91 int y, | 92 int y, |
92 const WebContents::GetRenderViewHostCallback& callback); | 93 const WebContents::GetRenderViewHostCallback& callback); |
93 | 94 |
94 // WebContentsObserver implementation. | 95 // WebContentsObserver implementation. |
95 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; | 96 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
96 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 97 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
97 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 98 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
98 | 99 |
| 100 void OnDragStopped(const IPC::Message& message, bool* handled); |
| 101 void OnUpdateDragCursor(bool* handled); |
| 102 |
99 // NotificationObserver method override. | 103 // NotificationObserver method override. |
100 virtual void Observe(int type, | 104 virtual void Observe(int type, |
101 const NotificationSource& source, | 105 const NotificationSource& source, |
102 const NotificationDetails& details) OVERRIDE; | 106 const NotificationDetails& details) OVERRIDE; |
103 | 107 |
| 108 void DragEnteredGuest(BrowserPluginGuest* guest); |
| 109 |
| 110 void DragLeftGuest(BrowserPluginGuest* guest); |
| 111 |
| 112 void StartDrag(BrowserPluginGuest* guest); |
| 113 |
104 private: | 114 private: |
105 friend class TestBrowserPluginEmbedder; | 115 friend class TestBrowserPluginEmbedder; |
106 | 116 |
107 BrowserPluginEmbedder(WebContentsImpl* web_contents, | 117 BrowserPluginEmbedder(WebContentsImpl* web_contents, |
108 RenderViewHost* render_view_host); | 118 RenderViewHost* render_view_host); |
109 | 119 |
110 // Adds a new guest web_contents to the embedder (overridable in test). | 120 // Adds a new guest web_contents to the embedder (overridable in test). |
111 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); | 121 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); |
112 void CleanUp(); | 122 void CleanUp(); |
113 | 123 |
(...skipping 30 matching lines...) Expand all Loading... |
144 bool visible_; | 154 bool visible_; |
145 // Map that contains outstanding queries to |GetBrowserPluginAt|. | 155 // Map that contains outstanding queries to |GetBrowserPluginAt|. |
146 // We need a roundtrip to renderer process to know the answer, therefore | 156 // We need a roundtrip to renderer process to know the answer, therefore |
147 // storing these callbacks is required. | 157 // storing these callbacks is required. |
148 typedef std::map<int, WebContents::GetRenderViewHostCallback> | 158 typedef std::map<int, WebContents::GetRenderViewHostCallback> |
149 GetRenderViewHostCallbackMap; | 159 GetRenderViewHostCallbackMap; |
150 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; | 160 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; |
151 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. | 161 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. |
152 int next_get_render_view_request_id_; | 162 int next_get_render_view_request_id_; |
153 int next_instance_id_; | 163 int next_instance_id_; |
| 164 base::WeakPtr<BrowserPluginGuest> guest_dragging_over_; |
| 165 base::WeakPtr<BrowserPluginGuest> guest_started_drag_; |
154 | 166 |
155 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); | 167 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); |
156 }; | 168 }; |
157 | 169 |
158 } // namespace content | 170 } // namespace content |
159 | 171 |
160 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 172 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
OLD | NEW |