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