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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver, | 50 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver, |
51 public NotificationObserver { | 51 public NotificationObserver { |
52 public: | 52 public: |
53 typedef std::map<int, WebContents*> ContainerInstanceMap; | 53 typedef std::map<int, WebContents*> ContainerInstanceMap; |
54 | 54 |
55 virtual ~BrowserPluginEmbedder(); | 55 virtual ~BrowserPluginEmbedder(); |
56 | 56 |
57 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents, | 57 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents, |
58 RenderViewHost* render_view_host); | 58 RenderViewHost* render_view_host); |
59 | 59 |
60 // Create a guest WebContents with the provided |instance_id| and |params| and | 60 // Creates a guest WebContents with the provided |instance_id| and |params| |
61 // add it to this BrowserPluginEmbedder. Optionally, the new guest may be | 61 // and adds it to this BrowserPluginEmbedder. If params.src is present, the |
62 // attached to a |guest_opener|, and may be attached to a pre-selected | 62 // new guest will also be navigated to the provided URL. Optionally, the new |
63 // |routing_id|. | 63 // guest may be attached to a |guest_opener|, and may be attached to a pre- |
| 64 // selected |routing_id|. |
64 void CreateGuest(int instance_id, | 65 void CreateGuest(int instance_id, |
65 int routing_id, | 66 int routing_id, |
66 BrowserPluginGuest* guest_opener, | 67 BrowserPluginGuest* guest_opener, |
67 const BrowserPluginHostMsg_CreateGuest_Params& params); | 68 const BrowserPluginHostMsg_CreateGuest_Params& params); |
68 | 69 |
69 // Returns a guest browser plugin delegate by its container ID specified | 70 // Returns a guest browser plugin delegate by its container ID specified |
70 // in BrowserPlugin. | 71 // in BrowserPlugin. |
71 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const; | 72 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const; |
72 | 73 |
73 // Destroy the guest with the provided |instance_id|. Remove references to the | 74 // Destroys the guest with the provided |instance_id|. Removes references to |
74 // guest in this BrowserPluginEmbedder. | 75 // the guest in this BrowserPluginEmbedder. |
75 void DestroyGuestByInstanceID(int instance_id); | 76 void DestroyGuestByInstanceID(int instance_id); |
76 | 77 |
77 // Overrides factory for testing. Default (NULL) value indicates regular | 78 // Overrides factory for testing. Default (NULL) value indicates regular |
78 // (non-test) environment. | 79 // (non-test) environment. |
79 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { | 80 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { |
80 factory_ = factory; | 81 factory_ = factory; |
81 } | 82 } |
82 | 83 |
83 bool visible() const { return visible_; } | 84 bool visible() const { return visible_; } |
84 | 85 |
(...skipping 26 matching lines...) Expand all Loading... |
111 void CleanUp(); | 112 void CleanUp(); |
112 | 113 |
113 // Called when visiblity of web_contents changes, so the embedder will | 114 // Called when visiblity of web_contents changes, so the embedder will |
114 // show/hide its guest. | 115 // show/hide its guest. |
115 void WebContentsVisibilityChanged(bool visible); | 116 void WebContentsVisibilityChanged(bool visible); |
116 | 117 |
117 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 118 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); |
118 | 119 |
119 // Message handlers. | 120 // Message handlers. |
120 | 121 |
| 122 void OnAllocateInstanceID(int request_id); |
121 void OnCreateGuest(int instance_id, | 123 void OnCreateGuest(int instance_id, |
122 const BrowserPluginHostMsg_CreateGuest_Params& params); | 124 const BrowserPluginHostMsg_CreateGuest_Params& params); |
123 void OnPluginAtPositionResponse(int instance_id, | 125 void OnPluginAtPositionResponse(int instance_id, |
124 int request_id, | 126 int request_id, |
125 const gfx::Point& position); | 127 const gfx::Point& position); |
126 void OnPluginDestroyed(int instance_id); | 128 void OnPluginDestroyed(int instance_id); |
127 void OnSwapBuffersACK(int route_id, | 129 void OnSwapBuffersACK(int route_id, |
128 int gpu_host_id, | 130 int gpu_host_id, |
129 const std::string& mailbox_name, | 131 const std::string& mailbox_name, |
130 uint32 sync_point); | 132 uint32 sync_point); |
(...skipping 10 matching lines...) Expand all Loading... |
141 // Tracks the visibility state of the embedder. | 143 // Tracks the visibility state of the embedder. |
142 bool visible_; | 144 bool visible_; |
143 // Map that contains outstanding queries to |GetBrowserPluginAt|. | 145 // Map that contains outstanding queries to |GetBrowserPluginAt|. |
144 // We need a roundtrip to renderer process to know the answer, therefore | 146 // We need a roundtrip to renderer process to know the answer, therefore |
145 // storing these callbacks is required. | 147 // storing these callbacks is required. |
146 typedef std::map<int, WebContents::GetRenderViewHostCallback> | 148 typedef std::map<int, WebContents::GetRenderViewHostCallback> |
147 GetRenderViewHostCallbackMap; | 149 GetRenderViewHostCallbackMap; |
148 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; | 150 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; |
149 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. | 151 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. |
150 int next_get_render_view_request_id_; | 152 int next_get_render_view_request_id_; |
| 153 int next_instance_id_; |
151 | 154 |
152 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); | 155 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); |
153 }; | 156 }; |
154 | 157 |
155 } // namespace content | 158 } // namespace content |
156 | 159 |
157 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 160 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
OLD | NEW |