| 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 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // WebContentsObserver implementation. | 94 // WebContentsObserver implementation. |
| 95 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; | 95 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
| 96 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 96 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 97 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 97 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 98 | 98 |
| 99 // NotificationObserver method override. | 99 // NotificationObserver method override. |
| 100 virtual void Observe(int type, | 100 virtual void Observe(int type, |
| 101 const NotificationSource& source, | 101 const NotificationSource& source, |
| 102 const NotificationDetails& details) OVERRIDE; | 102 const NotificationDetails& details) OVERRIDE; |
| 103 | 103 |
| 104 void DragEnteredGuest(BrowserPluginGuest* guest); |
| 105 |
| 106 void DragLeftGuest(BrowserPluginGuest* guest); |
| 107 |
| 108 void StartDrag(BrowserPluginGuest* guest); |
| 109 |
| 104 private: | 110 private: |
| 105 friend class TestBrowserPluginEmbedder; | 111 friend class TestBrowserPluginEmbedder; |
| 106 | 112 |
| 107 BrowserPluginEmbedder(WebContentsImpl* web_contents, | 113 BrowserPluginEmbedder(WebContentsImpl* web_contents, |
| 108 RenderViewHost* render_view_host); | 114 RenderViewHost* render_view_host); |
| 109 | 115 |
| 110 // Adds a new guest web_contents to the embedder (overridable in test). | 116 // Adds a new guest web_contents to the embedder (overridable in test). |
| 111 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); | 117 virtual void AddGuest(int instance_id, WebContents* guest_web_contents); |
| 112 void CleanUp(); | 118 void CleanUp(); |
| 113 | 119 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 124 const BrowserPluginHostMsg_CreateGuest_Params& params); | 130 const BrowserPluginHostMsg_CreateGuest_Params& params); |
| 125 void OnPluginAtPositionResponse(int instance_id, | 131 void OnPluginAtPositionResponse(int instance_id, |
| 126 int request_id, | 132 int request_id, |
| 127 const gfx::Point& position); | 133 const gfx::Point& position); |
| 128 void OnPluginDestroyed(int instance_id); | 134 void OnPluginDestroyed(int instance_id); |
| 129 void OnSwapBuffersACK(int route_id, | 135 void OnSwapBuffersACK(int route_id, |
| 130 int gpu_host_id, | 136 int gpu_host_id, |
| 131 const std::string& mailbox_name, | 137 const std::string& mailbox_name, |
| 132 uint32 sync_point); | 138 uint32 sync_point); |
| 133 | 139 |
| 140 // Returns the guest browser plugin delegate that is currently dragging. |
| 141 BrowserPluginGuest* GetDraggingGuest() const; |
| 142 |
| 143 // Returns true if there is a guest currently being dragged over. |
| 144 bool IsDragOverGuest() const; |
| 145 |
| 134 // Static factory instance (always NULL for non-test). | 146 // Static factory instance (always NULL for non-test). |
| 135 static BrowserPluginHostFactory* factory_; | 147 static BrowserPluginHostFactory* factory_; |
| 136 | 148 |
| 137 // A scoped container for notification registries. | 149 // A scoped container for notification registries. |
| 138 NotificationRegistrar registrar_; | 150 NotificationRegistrar registrar_; |
| 139 | 151 |
| 140 // Contains guests' WebContents, mapping from their instance ids. | 152 // Contains guests' WebContents, mapping from their instance ids. |
| 141 ContainerInstanceMap guest_web_contents_by_instance_id_; | 153 ContainerInstanceMap guest_web_contents_by_instance_id_; |
| 142 RenderViewHost* render_view_host_; | 154 RenderViewHost* render_view_host_; |
| 143 // Tracks the visibility state of the embedder. | 155 // Tracks the visibility state of the embedder. |
| 144 bool visible_; | 156 bool visible_; |
| 145 // Map that contains outstanding queries to |GetBrowserPluginAt|. | 157 // Map that contains outstanding queries to |GetBrowserPluginAt|. |
| 146 // We need a roundtrip to renderer process to know the answer, therefore | 158 // We need a roundtrip to renderer process to know the answer, therefore |
| 147 // storing these callbacks is required. | 159 // storing these callbacks is required. |
| 148 typedef std::map<int, WebContents::GetRenderViewHostCallback> | 160 typedef std::map<int, WebContents::GetRenderViewHostCallback> |
| 149 GetRenderViewHostCallbackMap; | 161 GetRenderViewHostCallbackMap; |
| 150 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; | 162 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; |
| 151 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. | 163 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. |
| 152 int next_get_render_view_request_id_; | 164 int next_get_render_view_request_id_; |
| 153 int next_instance_id_; | 165 int next_instance_id_; |
| 166 BrowserPluginGuest* guest_dragging_over; |
| 167 BrowserPluginGuest* guest_started_drag; |
| 154 | 168 |
| 155 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); | 169 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); |
| 156 }; | 170 }; |
| 157 | 171 |
| 158 } // namespace content | 172 } // namespace content |
| 159 | 173 |
| 160 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 174 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
| OLD | NEW |