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

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

Issue 272573005: <webview>: Move NewWindow API to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_rename
Patch Set: Addressed Istiaque's comments Created 6 years, 7 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
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 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. Any 9 // BrowserPluginGuest lives on the UI thread of the browser process. Any
10 // messages about the guest render process that the embedder might be interested 10 // messages about the guest render process that the embedder might be interested
(...skipping 11 matching lines...) Expand all
22 #include <queue> 22 #include <queue>
23 23
24 #include "base/compiler_specific.h" 24 #include "base/compiler_specific.h"
25 #include "base/memory/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
26 #include "base/values.h" 26 #include "base/values.h"
27 #include "content/common/edit_command.h" 27 #include "content/common/edit_command.h"
28 #include "content/common/input/input_event_ack_state.h" 28 #include "content/common/input/input_event_ack_state.h"
29 #include "content/public/browser/browser_plugin_guest_delegate.h" 29 #include "content/public/browser/browser_plugin_guest_delegate.h"
30 #include "content/public/browser/web_contents_delegate.h" 30 #include "content/public/browser/web_contents_delegate.h"
31 #include "content/public/browser/web_contents_observer.h" 31 #include "content/public/browser/web_contents_observer.h"
32 #include "content/public/common/browser_plugin_permission_type.h"
33 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 32 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
34 #include "third_party/WebKit/public/web/WebDragOperation.h" 33 #include "third_party/WebKit/public/web/WebDragOperation.h"
35 #include "third_party/WebKit/public/web/WebDragStatus.h" 34 #include "third_party/WebKit/public/web/WebDragStatus.h"
36 #include "third_party/WebKit/public/web/WebInputEvent.h" 35 #include "third_party/WebKit/public/web/WebInputEvent.h"
37 #include "ui/base/ime/text_input_mode.h" 36 #include "ui/base/ime/text_input_mode.h"
38 #include "ui/base/ime/text_input_type.h" 37 #include "ui/base/ime/text_input_type.h"
39 #include "ui/gfx/rect.h" 38 #include "ui/gfx/rect.h"
40 #include "ui/surface/transport_dib.h" 39 #include "ui/surface/transport_dib.h"
41 40
42 struct BrowserPluginHostMsg_AutoSize_Params; 41 struct BrowserPluginHostMsg_AutoSize_Params;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // initialized yet and so it does not yet hold a SiteInstance. 86 // initialized yet and so it does not yet hold a SiteInstance.
88 // BrowserPluginGuest must be constructed and installed into a WebContents 87 // BrowserPluginGuest must be constructed and installed into a WebContents
89 // prior to its initialization because WebContents needs to determine what 88 // prior to its initialization because WebContents needs to determine what
90 // type of WebContentsView to construct on initialization. The content 89 // type of WebContentsView to construct on initialization. The content
91 // embedder needs to be aware of |guest_site_instance| on the guest's 90 // embedder needs to be aware of |guest_site_instance| on the guest's
92 // construction and so we pass it in here. 91 // construction and so we pass it in here.
93 static BrowserPluginGuest* Create( 92 static BrowserPluginGuest* Create(
94 int instance_id, 93 int instance_id,
95 SiteInstance* guest_site_instance, 94 SiteInstance* guest_site_instance,
96 WebContentsImpl* web_contents, 95 WebContentsImpl* web_contents,
97 scoped_ptr<base::DictionaryValue> extra_params); 96 scoped_ptr<base::DictionaryValue> extra_params,
98
99 static BrowserPluginGuest* CreateWithOpener(
100 int instance_id,
101 bool has_render_view,
102 WebContentsImpl* web_contents,
103 BrowserPluginGuest* opener); 97 BrowserPluginGuest* opener);
104 98
105 // Returns a WeakPtr to this BrowserPluginGuest. 99 // Returns a WeakPtr to this BrowserPluginGuest.
106 base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); 100 base::WeakPtr<BrowserPluginGuest> AsWeakPtr();
107 101
108 // Called when the embedder WebContents is destroyed to give the 102 // Called when the embedder WebContents is destroyed to give the
109 // BrowserPluginGuest an opportunity to clean up after itself. 103 // BrowserPluginGuest an opportunity to clean up after itself.
110 void EmbedderDestroyed(); 104 void EmbedderDestroyed();
111 105
112 // Called when the embedder WebContents changes visibility. 106 // Called when the embedder WebContents changes visibility.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 266 }
273 267
274 void SetZoom(double zoom_factor); 268 void SetZoom(double zoom_factor);
275 269
276 void PointerLockPermissionResponse(bool allow); 270 void PointerLockPermissionResponse(bool allow);
277 271
278 private: 272 private:
279 class EmbedderWebContentsObserver; 273 class EmbedderWebContentsObserver;
280 friend class TestBrowserPluginGuest; 274 friend class TestBrowserPluginGuest;
281 275
282 class DownloadRequest;
283 class NewWindowRequest;
284 class PermissionRequest;
285
286 // Tracks the name, and target URL of the new window and whether or not it has
287 // changed since the WebContents has been created and before the new window
288 // has been attached to a BrowserPlugin. Once the first navigation commits, we
289 // no longer track this information.
290 struct NewWindowInfo {
291 bool changed;
292 GURL url;
293 std::string name;
294 NewWindowInfo(const GURL& url, const std::string& name) :
295 changed(false),
296 url(url),
297 name(name) {}
298 };
299
300 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and 276 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and
301 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. 277 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest.
302 BrowserPluginGuest(int instance_id, 278 BrowserPluginGuest(int instance_id,
303 bool has_render_view, 279 bool has_render_view,
304 WebContentsImpl* web_contents); 280 WebContentsImpl* web_contents);
305 281
306 // Destroy unattached new windows that have been opened by this 282 void WillDestroy(WebContents* web_contents);
307 // BrowserPluginGuest.
308 void DestroyUnattachedWindows();
309
310 void LoadURLWithParams(const GURL& url,
311 const Referrer& referrer,
312 PageTransition transition_type,
313 WebContents* web_contents);
314
315 // Returns the |request_id| generated for the |request| provided.
316 void RequestPermission(
317 BrowserPluginPermissionType permission_type,
318 scoped_refptr<BrowserPluginGuest::PermissionRequest> request,
319 const base::DictionaryValue& request_info);
320
321 // Creates a new guest window, and BrowserPluginGuest that is owned by this
322 // BrowserPluginGuest.
323 BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params);
324 283
325 bool InAutoSizeBounds(const gfx::Size& size) const; 284 bool InAutoSizeBounds(const gfx::Size& size) const;
326 285
327 void RequestNewWindowPermission(WindowOpenDisposition disposition,
328 const gfx::Rect& initial_bounds,
329 bool user_gesture,
330 WebContentsImpl* new_contents);
331
332 // Message handlers for messages from embedder. 286 // Message handlers for messages from embedder.
333 287
334 void OnCompositorFrameSwappedACK( 288 void OnCompositorFrameSwappedACK(
335 int instance_id, 289 int instance_id,
336 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); 290 const FrameHostMsg_CompositorFrameSwappedACK_Params& params);
337 void OnCopyFromCompositingSurfaceAck(int instance_id, 291 void OnCopyFromCompositingSurfaceAck(int instance_id,
338 int request_id, 292 int request_id,
339 const SkBitmap& bitmap); 293 const SkBitmap& bitmap);
340 // Handles drag events from the embedder. 294 // Handles drag events from the embedder.
341 // When dragging, the drag events go to the embedder first, and if the drag 295 // When dragging, the drag events go to the embedder first, and if the drag
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 gfx::Size min_auto_size_; 436 gfx::Size min_auto_size_;
483 gfx::Size full_size_; 437 gfx::Size full_size_;
484 438
485 // Each copy-request is identified by a unique number. The unique number is 439 // Each copy-request is identified by a unique number. The unique number is
486 // used to keep track of the right callback. 440 // used to keep track of the right callback.
487 int copy_request_id_; 441 int copy_request_id_;
488 typedef base::Callback<void(bool, const SkBitmap&)> CopyRequestCallback; 442 typedef base::Callback<void(bool, const SkBitmap&)> CopyRequestCallback;
489 typedef std::map<int, const CopyRequestCallback> CopyRequestMap; 443 typedef std::map<int, const CopyRequestCallback> CopyRequestMap;
490 CopyRequestMap copy_request_callbacks_; 444 CopyRequestMap copy_request_callbacks_;
491 445
492 typedef std::map<BrowserPluginGuest*, NewWindowInfo> PendingWindowMap;
493 PendingWindowMap pending_new_windows_;
494 // A counter to generate a unique request id for a permission request.
495 // We only need the ids to be unique for a given BrowserPluginGuest.
496 int next_permission_request_id_;
497
498 // A map to store relevant info for a request keyed by the request's id.
499 typedef std::map<int, scoped_refptr<PermissionRequest> > RequestMap;
500 RequestMap permission_request_map_;
501
502 // Indicates that this BrowserPluginGuest has associated renderer-side state. 446 // Indicates that this BrowserPluginGuest has associated renderer-side state.
503 // This is used to determine whether or not to create a new RenderView when 447 // This is used to determine whether or not to create a new RenderView when
504 // this guest is attached. 448 // this guest is attached.
505 bool has_render_view_; 449 bool has_render_view_;
506 450
507 // Last seen size of guest contents (by OnUpdateRect). 451 // Last seen size of guest contents (by OnUpdateRect).
508 gfx::Size last_seen_view_size_; 452 gfx::Size last_seen_view_size_;
509 // Last seen autosize attribute state (by OnUpdateRect). 453 // Last seen autosize attribute state (by OnUpdateRect).
510 bool last_seen_auto_size_enabled_; 454 bool last_seen_auto_size_enabled_;
511 455
512 bool is_in_destruction_; 456 bool is_in_destruction_;
513 457
514 // Text input type states. 458 // Text input type states.
515 ui::TextInputType last_text_input_type_; 459 ui::TextInputType last_text_input_type_;
516 ui::TextInputMode last_input_mode_; 460 ui::TextInputMode last_input_mode_;
517 bool last_can_compose_inline_; 461 bool last_can_compose_inline_;
518 462
519 // This is a queue of messages that are destined to be sent to the embedder 463 // This is a queue of messages that are destined to be sent to the embedder
520 // once the guest is attached to a particular embedder. 464 // once the guest is attached to a particular embedder.
521 std::queue<IPC::Message*> pending_messages_; 465 std::queue<IPC::Message*> pending_messages_;
522 466
523 scoped_ptr<BrowserPluginGuestDelegate> delegate_; 467 scoped_ptr<BrowserPluginGuestDelegate> delegate_;
524 468
525 // These are parameters passed from JavaScript on attachment to the content
526 // embedder.
527 scoped_ptr<base::DictionaryValue> extra_attach_params_;
528
529 // Weak pointer used to ask GeolocationPermissionContext about geolocation 469 // Weak pointer used to ask GeolocationPermissionContext about geolocation
530 // permission. 470 // permission.
531 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; 471 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_;
532 472
533 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 473 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
534 }; 474 };
535 475
536 } // namespace content 476 } // namespace content
537 477
538 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 478 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698