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/compiler_specific.h" | 25 #include "base/compiler_specific.h" |
26 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
27 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
28 #include "content/public/browser/web_contents_observer.h" | 28 #include "content/public/browser/web_contents_observer.h" |
| 29 #include "ui/surface/transport_dib.h" |
29 | 30 |
30 class TransportDIB; | |
31 class WebContentsImpl; | 31 class WebContentsImpl; |
| 32 struct BrowserPluginHostMsg_ResizeGuest_Params; |
32 | 33 |
33 namespace WebKit { | 34 namespace WebKit { |
34 class WebInputEvent; | 35 class WebInputEvent; |
35 } | 36 } |
36 | 37 |
37 namespace gfx { | 38 namespace gfx { |
38 class Rect; | 39 class Rect; |
39 class Size; | 40 class Size; |
40 } | 41 } |
41 | 42 |
(...skipping 13 matching lines...) Expand all Loading... |
55 public NotificationObserver { | 56 public NotificationObserver { |
56 public: | 57 public: |
57 typedef std::map<int, WebContents*> ContainerInstanceMap; | 58 typedef std::map<int, WebContents*> ContainerInstanceMap; |
58 | 59 |
59 virtual ~BrowserPluginEmbedder(); | 60 virtual ~BrowserPluginEmbedder(); |
60 | 61 |
61 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents, | 62 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents, |
62 RenderViewHost* render_view_host); | 63 RenderViewHost* render_view_host); |
63 | 64 |
64 // Navigates in a guest (new or existing). | 65 // Navigates in a guest (new or existing). |
65 void NavigateGuest(RenderViewHost* render_view_host, | 66 void NavigateGuest( |
66 int instance_id, | 67 RenderViewHost* render_view_host, |
67 int64 frame_id, | 68 int instance_id, |
68 const std::string& src, | 69 int64 frame_id, |
69 const gfx::Size& size); | 70 const std::string& src, |
| 71 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params); |
| 72 |
| 73 void ResizeGuest(int instance_id, |
| 74 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
| 75 |
70 void Stop(int instance_id); | 76 void Stop(int instance_id); |
71 void Reload(int instance_id); | 77 void Reload(int instance_id); |
72 | 78 |
73 // WebContentsObserver implementation. | 79 // WebContentsObserver implementation. |
74 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; | 80 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
75 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 81 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
76 | 82 |
77 // NotificationObserver method override. | 83 // NotificationObserver method override. |
78 virtual void Observe(int type, | 84 virtual void Observe(int type, |
79 const NotificationSource& source, | 85 const NotificationSource& source, |
80 const NotificationDetails& details) OVERRIDE; | 86 const NotificationDetails& details) OVERRIDE; |
81 | 87 |
82 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper). | 88 // Message handlers (direct/indirect via BrowserPluginEmbedderHelper). |
83 // Routes update rect ack message to the appropriate guest. | 89 // Routes update rect ack message to the appropriate guest. |
84 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size); | 90 void UpdateRectACK(int instance_id, int message_id, const gfx::Size& size); |
85 void SetFocus(int instance_id, bool focused); | 91 void SetFocus(int instance_id, bool focused); |
86 void ResizeGuest(int instance_id, | |
87 TransportDIB* damage_buffer, | |
88 #if defined(OS_WIN) | |
89 int damage_buffer_size, | |
90 #endif | |
91 int width, | |
92 int height, | |
93 bool resize_pending, | |
94 float scale_factor); | |
95 // Handles input events sent from the BrowserPlugin (embedder's renderer | 92 // Handles input events sent from the BrowserPlugin (embedder's renderer |
96 // process) by passing them to appropriate guest's input handler. | 93 // process) by passing them to appropriate guest's input handler. |
97 void HandleInputEvent(int instance_id, | 94 void HandleInputEvent(int instance_id, |
98 RenderViewHost* render_view_host, | 95 RenderViewHost* render_view_host, |
99 const gfx::Rect& guest_rect, | 96 const gfx::Rect& guest_rect, |
100 const WebKit::WebInputEvent& event, | 97 const WebKit::WebInputEvent& event, |
101 IPC::Message* reply_message); | 98 IPC::Message* reply_message); |
102 void PluginDestroyed(int instance_id); | 99 void PluginDestroyed(int instance_id); |
103 | 100 |
104 // Overrides factory for testing. Default (NULL) value indicates regular | 101 // Overrides factory for testing. Default (NULL) value indicates regular |
(...skipping 11 matching lines...) Expand all Loading... |
116 // Returns a guest browser plugin delegate by its container ID specified | 113 // Returns a guest browser plugin delegate by its container ID specified |
117 // in BrowserPlugin. | 114 // in BrowserPlugin. |
118 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const; | 115 BrowserPluginGuest* GetGuestByInstanceID(int instance_id) const; |
119 // 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). |
120 virtual void AddGuest(int instance_id, | 117 virtual void AddGuest(int instance_id, |
121 WebContents* guest_web_contents, | 118 WebContents* guest_web_contents, |
122 int64 frame_id); | 119 int64 frame_id); |
123 void DestroyGuestByInstanceID(int instance_id); | 120 void DestroyGuestByInstanceID(int instance_id); |
124 void DestroyGuests(); | 121 void DestroyGuests(); |
125 | 122 |
| 123 // Returns the transport DIB associated with the dib id. |
| 124 TransportDIB* GetDamageBuffer(const TransportDIB::Id& damage_buffer_id); |
| 125 |
126 // Called when visiblity of web_contents changes, so the embedder will | 126 // Called when visiblity of web_contents changes, so the embedder will |
127 // show/hide its guest. | 127 // show/hide its guest. |
128 void WebContentsVisibilityChanged(bool visible); | 128 void WebContentsVisibilityChanged(bool visible); |
129 | 129 |
130 // Static factory instance (always NULL for non-test). | 130 // Static factory instance (always NULL for non-test). |
131 static BrowserPluginHostFactory* factory_; | 131 static BrowserPluginHostFactory* factory_; |
132 | 132 |
133 // A scoped container for notification registries. | 133 // A scoped container for notification registries. |
134 NotificationRegistrar registrar_; | 134 NotificationRegistrar registrar_; |
135 | 135 |
136 // Contains guests' WebContents, mapping from their instance ids. | 136 // Contains guests' WebContents, mapping from their instance ids. |
137 ContainerInstanceMap guest_web_contents_by_instance_id_; | 137 ContainerInstanceMap guest_web_contents_by_instance_id_; |
138 RenderViewHost* render_view_host_; | 138 RenderViewHost* render_view_host_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); | 140 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); |
141 }; | 141 }; |
142 | 142 |
143 } // namespace content | 143 } // namespace content |
144 | 144 |
145 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 145 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
OLD | NEW |