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 BrowserPluginGuest is the browser side of a browser <--> embedder | 5 // A BrowserPluginGuest is the browser side of a browser <--> embedder |
6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder | 6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder |
7 // renderer side of browser <--> embedder renderer communication. | 7 // renderer side of browser <--> embedder renderer communication. |
8 // | 8 // |
9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a | 9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a |
10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The | 10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 #include "base/compiler_specific.h" | 27 #include "base/compiler_specific.h" |
28 #include "base/id_map.h" | 28 #include "base/id_map.h" |
29 #include "base/memory/shared_memory.h" | 29 #include "base/memory/shared_memory.h" |
30 #include "base/memory/weak_ptr.h" | 30 #include "base/memory/weak_ptr.h" |
31 #include "base/values.h" | 31 #include "base/values.h" |
32 #include "content/common/browser_plugin/browser_plugin_message_enums.h" | 32 #include "content/common/browser_plugin/browser_plugin_message_enums.h" |
33 #include "content/common/edit_command.h" | 33 #include "content/common/edit_command.h" |
34 #include "content/port/common/input_event_ack_state.h" | 34 #include "content/port/common/input_event_ack_state.h" |
35 #include "content/public/browser/browser_plugin_guest_delegate.h" | 35 #include "content/public/browser/browser_plugin_guest_delegate.h" |
36 #include "content/public/browser/javascript_dialog_manager.h" | |
36 #include "content/public/browser/notification_observer.h" | 37 #include "content/public/browser/notification_observer.h" |
37 #include "content/public/browser/notification_registrar.h" | 38 #include "content/public/browser/notification_registrar.h" |
38 #include "content/public/browser/render_view_host_observer.h" | 39 #include "content/public/browser/render_view_host_observer.h" |
39 #include "content/public/browser/web_contents_delegate.h" | 40 #include "content/public/browser/web_contents_delegate.h" |
40 #include "content/public/browser/web_contents_observer.h" | 41 #include "content/public/browser/web_contents_observer.h" |
41 #include "third_party/WebKit/public/web/WebDragOperation.h" | 42 #include "third_party/WebKit/public/web/WebDragOperation.h" |
42 #include "third_party/WebKit/public/web/WebDragStatus.h" | 43 #include "third_party/WebKit/public/web/WebDragStatus.h" |
43 #include "third_party/WebKit/public/web/WebInputEvent.h" | 44 #include "third_party/WebKit/public/web/WebInputEvent.h" |
44 #include "ui/gfx/rect.h" | 45 #include "ui/gfx/rect.h" |
45 #include "ui/surface/transport_dib.h" | 46 #include "ui/surface/transport_dib.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 // When a guest is initially created, it is in an unattached state. That is, | 80 // When a guest is initially created, it is in an unattached state. That is, |
80 // it is not visible anywhere and has no embedder WebContents assigned. | 81 // it is not visible anywhere and has no embedder WebContents assigned. |
81 // A BrowserPluginGuest is said to be "attached" if it has an embedder. | 82 // A BrowserPluginGuest is said to be "attached" if it has an embedder. |
82 // A BrowserPluginGuest can also create a new unattached guest via | 83 // A BrowserPluginGuest can also create a new unattached guest via |
83 // CreateNewWindow. The newly created guest will live in the same partition, | 84 // CreateNewWindow. The newly created guest will live in the same partition, |
84 // which means it can share storage and can script this guest. | 85 // which means it can share storage and can script this guest. |
85 class CONTENT_EXPORT BrowserPluginGuest | 86 class CONTENT_EXPORT BrowserPluginGuest |
86 : public NotificationObserver, | 87 : public NotificationObserver, |
87 public WebContentsDelegate, | 88 public WebContentsDelegate, |
88 public WebContentsObserver, | 89 public WebContentsObserver, |
90 public JavaScriptDialogManager, | |
lazyboy
2013/07/19 21:43:16
sort?
Fady Samuel
2013/07/23 15:41:10
Done.
| |
89 public base::SupportsWeakPtr<BrowserPluginGuest> { | 91 public base::SupportsWeakPtr<BrowserPluginGuest> { |
90 public: | 92 public: |
91 typedef base::Callback<void(bool)> GeolocationCallback; | 93 typedef base::Callback<void(bool)> GeolocationCallback; |
92 virtual ~BrowserPluginGuest(); | 94 virtual ~BrowserPluginGuest(); |
93 | 95 |
94 static BrowserPluginGuest* Create( | 96 static BrowserPluginGuest* Create( |
95 int instance_id, | 97 int instance_id, |
96 WebContentsImpl* web_contents, | 98 WebContentsImpl* web_contents, |
97 scoped_ptr<base::DictionaryValue> extra_params); | 99 scoped_ptr<base::DictionaryValue> extra_params); |
98 | 100 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 const GURL& url, | 156 const GURL& url, |
155 PageTransition transition_type, | 157 PageTransition transition_type, |
156 RenderViewHost* render_view_host) OVERRIDE; | 158 RenderViewHost* render_view_host) OVERRIDE; |
157 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; | 159 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; |
158 | 160 |
159 virtual void RenderViewReady() OVERRIDE; | 161 virtual void RenderViewReady() OVERRIDE; |
160 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; | 162 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; |
161 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 163 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
162 | 164 |
163 // WebContentsDelegate implementation. | 165 // WebContentsDelegate implementation. |
164 | |
165 virtual bool AddMessageToConsole(WebContents* source, | 166 virtual bool AddMessageToConsole(WebContents* source, |
166 int32 level, | 167 int32 level, |
167 const string16& message, | 168 const string16& message, |
168 int32 line_no, | 169 int32 line_no, |
169 const string16& source_id) OVERRIDE; | 170 const string16& source_id) OVERRIDE; |
170 // If a new window is created with target="_blank" and rel="noreferrer", then | 171 // If a new window is created with target="_blank" and rel="noreferrer", then |
171 // this method is called, indicating that the new WebContents is ready to be | 172 // this method is called, indicating that the new WebContents is ready to be |
172 // attached. | 173 // attached. |
173 virtual void AddNewContents(WebContents* source, | 174 virtual void AddNewContents(WebContents* source, |
174 WebContents* new_contents, | 175 WebContents* new_contents, |
175 WindowOpenDisposition disposition, | 176 WindowOpenDisposition disposition, |
176 const gfx::Rect& initial_pos, | 177 const gfx::Rect& initial_pos, |
177 bool user_gesture, | 178 bool user_gesture, |
178 bool* was_blocked) OVERRIDE; | 179 bool* was_blocked) OVERRIDE; |
179 virtual void CanDownload(RenderViewHost* render_view_host, | 180 virtual void CanDownload(RenderViewHost* render_view_host, |
180 int request_id, | 181 int request_id, |
181 const std::string& request_method, | 182 const std::string& request_method, |
182 const base::Callback<void(bool)>& callback) OVERRIDE; | 183 const base::Callback<void(bool)>& callback) OVERRIDE; |
183 virtual void CloseContents(WebContents* source) OVERRIDE; | 184 virtual void CloseContents(WebContents* source) OVERRIDE; |
185 virtual JavaScriptDialogManager* GetJavaScriptDialogManager() OVERRIDE; | |
184 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; | 186 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; |
185 virtual void HandleKeyboardEvent( | 187 virtual void HandleKeyboardEvent( |
186 WebContents* source, | 188 WebContents* source, |
187 const NativeWebKeyboardEvent& event) OVERRIDE; | 189 const NativeWebKeyboardEvent& event) OVERRIDE; |
188 virtual WebContents* OpenURLFromTab(WebContents* source, | 190 virtual WebContents* OpenURLFromTab(WebContents* source, |
189 const OpenURLParams& params) OVERRIDE; | 191 const OpenURLParams& params) OVERRIDE; |
190 virtual void WebContentsCreated(WebContents* source_contents, | 192 virtual void WebContentsCreated(WebContents* source_contents, |
191 int64 source_frame_id, | 193 int64 source_frame_id, |
192 const string16& frame_name, | 194 const string16& frame_name, |
193 const GURL& target_url, | 195 const GURL& target_url, |
194 WebContents* new_contents) OVERRIDE; | 196 WebContents* new_contents) OVERRIDE; |
195 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; | 197 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; |
196 virtual void RendererResponsive(WebContents* source) OVERRIDE; | 198 virtual void RendererResponsive(WebContents* source) OVERRIDE; |
197 virtual void RunFileChooser(WebContents* web_contents, | 199 virtual void RunFileChooser(WebContents* web_contents, |
198 const FileChooserParams& params) OVERRIDE; | 200 const FileChooserParams& params) OVERRIDE; |
199 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; | 201 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; |
200 virtual void RequestMediaAccessPermission( | 202 virtual void RequestMediaAccessPermission( |
201 WebContents* web_contents, | 203 WebContents* web_contents, |
202 const MediaStreamRequest& request, | 204 const MediaStreamRequest& request, |
203 const MediaResponseCallback& callback) OVERRIDE; | 205 const MediaResponseCallback& callback) OVERRIDE; |
204 | 206 |
207 // JavaScriptDialogManager implementation. | |
208 virtual void RunJavaScriptDialog( | |
209 WebContents* web_contents, | |
210 const GURL& origin_url, | |
211 const std::string& accept_lang, | |
212 JavaScriptMessageType javascript_message_type, | |
213 const string16& message_text, | |
214 const string16& default_prompt_text, | |
215 const DialogClosedCallback& callback, | |
216 bool* did_suppress_message) OVERRIDE; | |
217 virtual void RunBeforeUnloadDialog( | |
218 WebContents* web_contents, | |
219 const string16& message_text, | |
220 bool is_reload, | |
221 const DialogClosedCallback& callback) OVERRIDE; | |
222 virtual bool HandleJavaScriptDialog(WebContents* web_contents, | |
223 bool accept, | |
224 const string16* prompt_override) OVERRIDE; | |
225 virtual void ResetJavaScriptState(WebContents* web_contents) OVERRIDE; | |
226 | |
205 // Exposes the protected web_contents() from WebContentsObserver. | 227 // Exposes the protected web_contents() from WebContentsObserver. |
206 WebContentsImpl* GetWebContents(); | 228 WebContentsImpl* GetWebContents(); |
207 | 229 |
208 // Overridden in tests. | 230 // Overridden in tests. |
209 virtual void SetDamageBuffer( | 231 virtual void SetDamageBuffer( |
210 const BrowserPluginHostMsg_ResizeGuest_Params& params); | 232 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
211 | 233 |
212 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; | 234 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; |
213 | 235 |
214 // Helper to send messages to embedder. This methods fills the message with | 236 // Helper to send messages to embedder. This methods fills the message with |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 | 279 |
258 // |this| takes ownership of |delegate|. | 280 // |this| takes ownership of |delegate|. |
259 void SetDelegate(BrowserPluginGuestDelegate* delegate); | 281 void SetDelegate(BrowserPluginGuestDelegate* delegate); |
260 | 282 |
261 private: | 283 private: |
262 class EmbedderRenderViewHostObserver; | 284 class EmbedderRenderViewHostObserver; |
263 friend class TestBrowserPluginGuest; | 285 friend class TestBrowserPluginGuest; |
264 | 286 |
265 class DownloadRequest; | 287 class DownloadRequest; |
266 class GeolocationRequest; | 288 class GeolocationRequest; |
289 class JavaScriptDialogRequest; | |
267 // MediaRequest because of naming conflicts with MediaStreamRequest. | 290 // MediaRequest because of naming conflicts with MediaStreamRequest. |
268 class MediaRequest; | 291 class MediaRequest; |
269 class NewWindowRequest; | 292 class NewWindowRequest; |
270 class PermissionRequest; | 293 class PermissionRequest; |
271 | 294 |
272 BrowserPluginGuest(int instance_id, | 295 BrowserPluginGuest(int instance_id, |
273 WebContentsImpl* web_contents, | 296 WebContentsImpl* web_contents, |
274 BrowserPluginGuest* opener, | 297 BrowserPluginGuest* opener, |
275 bool has_render_view); | 298 bool has_render_view); |
276 | 299 |
(...skipping 20 matching lines...) Expand all Loading... | |
297 // Message handlers for messages from embedder. | 320 // Message handlers for messages from embedder. |
298 | 321 |
299 void OnCompositorFrameACK(int instance_id, | 322 void OnCompositorFrameACK(int instance_id, |
300 int route_id, | 323 int route_id, |
301 int renderer_host_id, | 324 int renderer_host_id, |
302 const cc::CompositorFrameAck& ack); | 325 const cc::CompositorFrameAck& ack); |
303 | 326 |
304 // Allows or denies a permission request access, after the embedder has had a | 327 // Allows or denies a permission request access, after the embedder has had a |
305 // chance to decide. | 328 // chance to decide. |
306 void OnRespondPermission(int instance_id, | 329 void OnRespondPermission(int instance_id, |
307 BrowserPluginPermissionType permission_type, | |
308 int request_id, | 330 int request_id, |
309 bool should_allow); | 331 bool should_allow, |
332 const std::string& user_input); | |
310 // Handles drag events from the embedder. | 333 // Handles drag events from the embedder. |
311 // When dragging, the drag events go to the embedder first, and if the drag | 334 // When dragging, the drag events go to the embedder first, and if the drag |
312 // happens on the browser plugin, then the plugin sends a corresponding | 335 // happens on the browser plugin, then the plugin sends a corresponding |
313 // drag-message to the guest. This routes the drag-message to the guest | 336 // drag-message to the guest. This routes the drag-message to the guest |
314 // renderer. | 337 // renderer. |
315 void OnDragStatusUpdate(int instance_id, | 338 void OnDragStatusUpdate(int instance_id, |
316 WebKit::WebDragStatus drag_status, | 339 WebKit::WebDragStatus drag_status, |
317 const DropData& drop_data, | 340 const DropData& drop_data, |
318 WebKit::WebDragOperationsMask drag_mask, | 341 WebKit::WebDragOperationsMask drag_mask, |
319 const gfx::Point& location); | 342 const gfx::Point& location); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 std::queue<IPC::Message*> pending_messages_; | 505 std::queue<IPC::Message*> pending_messages_; |
483 | 506 |
484 scoped_ptr<BrowserPluginGuestDelegate> delegate_; | 507 scoped_ptr<BrowserPluginGuestDelegate> delegate_; |
485 | 508 |
486 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 509 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
487 }; | 510 }; |
488 | 511 |
489 } // namespace content | 512 } // namespace content |
490 | 513 |
491 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 514 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |