Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.h

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed crash + cleanup Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 BrowserPluginGuest represents the browser side of browser <--> renderer 5 // A BrowserPluginGuest represents the browser side of browser <--> renderer
6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of
7 // browser <--> guest renderer communication. The 'guest' renderer is a 7 // browser <--> guest renderer communication. The 'guest' renderer is a
8 // <browser> tag. 8 // <browser> tag.
9 // 9 //
10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "ui/surface/transport_dib.h" 45 #include "ui/surface/transport_dib.h"
46 #include "ui/gfx/rect.h" 46 #include "ui/gfx/rect.h"
47 #include "ui/gfx/size.h" 47 #include "ui/gfx/size.h"
48 #include "webkit/glue/webcursor.h" 48 #include "webkit/glue/webcursor.h"
49 49
50 namespace gfx { 50 namespace gfx {
51 class Size; 51 class Size;
52 } 52 }
53 53
54 struct BrowserPluginHostMsg_ResizeGuest_Params; 54 struct BrowserPluginHostMsg_ResizeGuest_Params;
55 struct ViewMsg_PostMessage_Params;
55 struct ViewHostMsg_UpdateRect_Params; 56 struct ViewHostMsg_UpdateRect_Params;
56 57
57 namespace content { 58 namespace content {
58 59
59 class BrowserPluginHostFactory; 60 class BrowserPluginHostFactory;
60 class BrowserPluginEmbedder; 61 class BrowserPluginEmbedder;
61 class RenderProcessHost; 62 class RenderProcessHost;
62 63
63 // A browser plugin guest provides functionality for WebContents to operate in 64 // A browser plugin guest provides functionality for WebContents to operate in
64 // the guest role and implements guest specific overrides for ViewHostMsg_* 65 // the guest role and implements guest specific overrides for ViewHostMsg_*
(...skipping 24 matching lines...) Expand all
89 int64 frame_id, 90 int64 frame_id,
90 bool is_main_frame, 91 bool is_main_frame,
91 const GURL& url, 92 const GURL& url,
92 PageTransition transition_type, 93 PageTransition transition_type,
93 RenderViewHost* render_view_host) OVERRIDE; 94 RenderViewHost* render_view_host) OVERRIDE;
94 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 95 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
95 96
96 // WebContentsDelegate implementation. 97 // WebContentsDelegate implementation.
97 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; 98 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
98 99
100 // Returns the identifier that uniquely identifies a browser plugin guest
101 // within an embedder.
102 int instance_id() const { return instance_id_; }
103
99 private: 104 private:
100 friend class BrowserPluginEmbedder; 105 friend class BrowserPluginEmbedder;
101 friend class BrowserPluginGuestHelper; 106 friend class BrowserPluginGuestHelper;
102 friend class TestBrowserPluginGuest; 107 friend class TestBrowserPluginGuest;
103 108
104 BrowserPluginGuest(int instance_id, 109 BrowserPluginGuest(int instance_id,
105 WebContentsImpl* web_contents, 110 WebContentsImpl* web_contents,
106 RenderViewHost* render_view_host); 111 RenderViewHost* render_view_host);
107 112
108 void set_embedder_render_process_host( 113 void set_embedder_render_process_host(
109 RenderProcessHost* render_process_host) { 114 RenderProcessHost* render_process_host) {
110 embedder_render_process_host_ = render_process_host; 115 embedder_render_process_host_ = render_process_host;
111 } 116 }
112 RenderProcessHost* embedder_render_process_host() { 117 RenderProcessHost* embedder_render_process_host() {
113 return embedder_render_process_host_; 118 return embedder_render_process_host_;
114 } 119 }
115 // Returns the identifier that uniquely identifies a browser plugin guest
116 // within an embedder.
117 int instance_id() const { return instance_id_; }
118 120
119 void SetDamageBuffer(TransportDIB* damage_buffer, 121 void SetDamageBuffer(TransportDIB* damage_buffer,
120 #if defined(OS_WIN) 122 #if defined(OS_WIN)
121 int damage_buffer_size, 123 int damage_buffer_size,
122 #endif 124 #endif
123 const gfx::Size& damage_view_size, 125 const gfx::Size& damage_view_size,
124 float scale_factor); 126 float scale_factor);
125 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } 127 TransportDIB* damage_buffer() const { return damage_buffer_.get(); }
126 const gfx::Size& damage_view_size() const { return damage_view_size_; } 128 const gfx::Size& damage_view_size() const { return damage_view_size_; }
127 float damage_buffer_scale_factor() const { 129 float damage_buffer_scale_factor() const {
128 return damage_buffer_scale_factor_; 130 return damage_buffer_scale_factor_;
129 } 131 }
132 void set_swapped_out_embedder_routing_id(int routing_id) {
133 swapped_out_embedder_routing_id_ = routing_id;
134 }
135 int swapped_out_embedder_routing_id() const {
136 return swapped_out_embedder_routing_id_;
137 }
138 void set_swapped_out_guest_routing_id(int routing_id) {
139 swapped_out_guest_routing_id_ = routing_id;
140 }
141 int swapped_out_guest_routing_id() const {
142 return swapped_out_guest_routing_id_;
143 }
130 144
131 void UpdateRect(RenderViewHost* render_view_host, 145 void UpdateRect(RenderViewHost* render_view_host,
132 const ViewHostMsg_UpdateRect_Params& params); 146 const ViewHostMsg_UpdateRect_Params& params);
133 void UpdateRectACK(int message_id, const gfx::Size& size); 147 void UpdateRectACK(int message_id, const gfx::Size& size);
134 // Handles input event routed through the embedder (which is initiated in the 148 // Handles input event routed through the embedder (which is initiated in the
135 // browser plugin (renderer side of the embedder)). 149 // browser plugin (renderer side of the embedder)).
136 void HandleInputEvent(RenderViewHost* render_view_host, 150 void HandleInputEvent(RenderViewHost* render_view_host,
137 const gfx::Rect& guest_rect, 151 const gfx::Rect& guest_rect,
138 const WebKit::WebInputEvent& event, 152 const WebKit::WebInputEvent& event,
139 IPC::Message* reply_message); 153 IPC::Message* reply_message);
140 // Overrides default ShowWidget message so we show them on the correct 154 // Overrides default ShowWidget message so we show them on the correct
141 // coordinates. 155 // coordinates.
142 void ShowWidget(RenderViewHost* render_view_host, 156 void ShowWidget(RenderViewHost* render_view_host,
143 int route_id, 157 int route_id,
144 const gfx::Rect& initial_pos); 158 const gfx::Rect& initial_pos);
145 // Overriden in tests. 159 // Overriden in tests.
146 virtual void SetFocus(bool focused); 160 virtual void SetFocus(bool focused);
147 void SetCursor(const WebCursor& cursor); 161 void SetCursor(const WebCursor& cursor);
148 // Handles input event acks so they are sent to browser plugin host (via 162 // Handles input event acks so they are sent to browser plugin host (via
149 // embedder) instead of default view/widget host. 163 // embedder) instead of default view/widget host.
150 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); 164 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled);
151 165
166 // Handles postMessages sent from the guest to the embedder.
167 void RouteMessageEvent(const ViewMsg_PostMessage_Params& params);
168
152 // Helper to send messages to embedder. Overriden in test implementation since 169 // Helper to send messages to embedder. Overriden in test implementation since
153 // we want to intercept certain messages for testing. 170 // we want to intercept certain messages for testing.
154 virtual void SendMessageToEmbedder(IPC::Message*); 171 virtual void SendMessageToEmbedder(IPC::Message*);
155 172
156 // Static factory instance (always NULL for non-test). 173 // Static factory instance (always NULL for non-test).
157 static content::BrowserPluginHostFactory* factory_; 174 static content::BrowserPluginHostFactory* factory_;
158 175
159 // Overriden in tests. 176 // Overriden in tests.
160 virtual bool ViewTakeFocus(bool reverse); 177 virtual bool ViewTakeFocus(bool reverse);
161 178
162 RenderProcessHost* embedder_render_process_host_; 179 RenderProcessHost* embedder_render_process_host_;
163 // An identifier that uniquely identifies a browser plugin guest within an 180 // An identifier that uniquely identifies a browser plugin guest within an
164 // embedder. 181 // embedder.
165 int instance_id_; 182 int instance_id_;
166 scoped_ptr<TransportDIB> damage_buffer_; 183 scoped_ptr<TransportDIB> damage_buffer_;
167 #if defined(OS_WIN) 184 #if defined(OS_WIN)
168 size_t damage_buffer_size_; 185 size_t damage_buffer_size_;
169 #endif 186 #endif
170 gfx::Size damage_view_size_; 187 gfx::Size damage_view_size_;
171 float damage_buffer_scale_factor_; 188 float damage_buffer_scale_factor_;
172 scoped_ptr<IPC::Message> pending_input_event_reply_; 189 scoped_ptr<IPC::Message> pending_input_event_reply_;
173 gfx::Rect guest_rect_; 190 gfx::Rect guest_rect_;
174 WebCursor cursor_; 191 WebCursor cursor_;
175 IDMap<RenderViewHost> pending_updates_; 192 IDMap<RenderViewHost> pending_updates_;
176 int pending_update_counter_; 193 int pending_update_counter_;
177 base::TimeDelta guest_hang_timeout_; 194 base::TimeDelta guest_hang_timeout_;
195 int swapped_out_embedder_routing_id_;
196 int swapped_out_guest_routing_id_;
178 197
179 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 198 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
180 }; 199 };
181 200
182 } // namespace content 201 } // namespace content
183 202
184 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 203 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698