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

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: Merge with ToT 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 // Sets the lock state of the pointer. Returns true if |allowed| is true and 102 // Sets the lock state of the pointer. Returns true if |allowed| is true and
109 // the mouse has been successfully locked. 103 // the mouse has been successfully locked.
110 bool LockMouse(bool allowed); 104 bool LockMouse(bool allowed);
111 105
112 // Called when the embedder WebContents is destroyed to give the 106 // Called when the embedder WebContents is destroyed to give the
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 267 }
274 268
275 void SetZoom(double zoom_factor); 269 void SetZoom(double zoom_factor);
276 270
277 void PointerLockPermissionResponse(bool allow); 271 void PointerLockPermissionResponse(bool allow);
278 272
279 private: 273 private:
280 class EmbedderWebContentsObserver; 274 class EmbedderWebContentsObserver;
281 friend class TestBrowserPluginGuest; 275 friend class TestBrowserPluginGuest;
282 276
283 class DownloadRequest;
284 class NewWindowRequest;
285 class PermissionRequest;
286
287 // Tracks the name, and target URL of the new window and whether or not it has
288 // changed since the WebContents has been created and before the new window
289 // has been attached to a BrowserPlugin. Once the first navigation commits, we
290 // no longer track this information.
291 struct NewWindowInfo {
292 bool changed;
293 GURL url;
294 std::string name;
295 NewWindowInfo(const GURL& url, const std::string& name) :
296 changed(false),
297 url(url),
298 name(name) {}
299 };
300
301 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and 277 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and
302 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. 278 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest.
303 BrowserPluginGuest(int instance_id, 279 BrowserPluginGuest(int instance_id,
304 bool has_render_view, 280 bool has_render_view,
305 WebContentsImpl* web_contents); 281 WebContentsImpl* web_contents);
306 282
307 // Destroy unattached new windows that have been opened by this 283 void WillDestroy(WebContents* web_contents);
308 // BrowserPluginGuest.
309 void DestroyUnattachedWindows();
310
311 void LoadURLWithParams(const GURL& url,
312 const Referrer& referrer,
313 PageTransition transition_type,
314 WebContents* web_contents);
315
316 // Returns the |request_id| generated for the |request| provided.
317 void RequestPermission(
318 BrowserPluginPermissionType permission_type,
319 scoped_refptr<BrowserPluginGuest::PermissionRequest> request,
320 const base::DictionaryValue& request_info);
321
322 // Creates a new guest window, and BrowserPluginGuest that is owned by this
323 // BrowserPluginGuest.
324 BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params);
325 284
326 bool InAutoSizeBounds(const gfx::Size& size) const; 285 bool InAutoSizeBounds(const gfx::Size& size) const;
327 286
328 void RequestNewWindowPermission(WindowOpenDisposition disposition,
329 const gfx::Rect& initial_bounds,
330 bool user_gesture,
331 WebContentsImpl* new_contents);
332
333 // Message handlers for messages from embedder. 287 // Message handlers for messages from embedder.
334 288
335 void OnCompositorFrameSwappedACK( 289 void OnCompositorFrameSwappedACK(
336 int instance_id, 290 int instance_id,
337 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); 291 const FrameHostMsg_CompositorFrameSwappedACK_Params& params);
338 void OnCopyFromCompositingSurfaceAck(int instance_id, 292 void OnCopyFromCompositingSurfaceAck(int instance_id,
339 int request_id, 293 int request_id,
340 const SkBitmap& bitmap); 294 const SkBitmap& bitmap);
341 // Handles drag events from the embedder. 295 // Handles drag events from the embedder.
342 // When dragging, the drag events go to the embedder first, and if the drag 296 // When dragging, the drag events go to the embedder first, and if the drag
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 gfx::Size min_auto_size_; 429 gfx::Size min_auto_size_;
476 gfx::Size full_size_; 430 gfx::Size full_size_;
477 431
478 // Each copy-request is identified by a unique number. The unique number is 432 // Each copy-request is identified by a unique number. The unique number is
479 // used to keep track of the right callback. 433 // used to keep track of the right callback.
480 int copy_request_id_; 434 int copy_request_id_;
481 typedef base::Callback<void(bool, const SkBitmap&)> CopyRequestCallback; 435 typedef base::Callback<void(bool, const SkBitmap&)> CopyRequestCallback;
482 typedef std::map<int, const CopyRequestCallback> CopyRequestMap; 436 typedef std::map<int, const CopyRequestCallback> CopyRequestMap;
483 CopyRequestMap copy_request_callbacks_; 437 CopyRequestMap copy_request_callbacks_;
484 438
485 typedef std::map<BrowserPluginGuest*, NewWindowInfo> PendingWindowMap;
486 PendingWindowMap pending_new_windows_;
487 // A counter to generate a unique request id for a permission request.
488 // We only need the ids to be unique for a given BrowserPluginGuest.
489 int next_permission_request_id_;
490
491 // A map to store relevant info for a request keyed by the request's id.
492 typedef std::map<int, scoped_refptr<PermissionRequest> > RequestMap;
493 RequestMap permission_request_map_;
494
495 // Indicates that this BrowserPluginGuest has associated renderer-side state. 439 // Indicates that this BrowserPluginGuest has associated renderer-side state.
496 // This is used to determine whether or not to create a new RenderView when 440 // This is used to determine whether or not to create a new RenderView when
497 // this guest is attached. 441 // this guest is attached.
498 bool has_render_view_; 442 bool has_render_view_;
499 443
500 // Last seen size of guest contents (by OnUpdateRect). 444 // Last seen size of guest contents (by OnUpdateRect).
501 gfx::Size last_seen_view_size_; 445 gfx::Size last_seen_view_size_;
502 // Last seen autosize attribute state (by OnUpdateRect). 446 // Last seen autosize attribute state (by OnUpdateRect).
503 bool last_seen_auto_size_enabled_; 447 bool last_seen_auto_size_enabled_;
504 448
505 bool is_in_destruction_; 449 bool is_in_destruction_;
506 450
507 // Text input type states. 451 // Text input type states.
508 ui::TextInputType last_text_input_type_; 452 ui::TextInputType last_text_input_type_;
509 ui::TextInputMode last_input_mode_; 453 ui::TextInputMode last_input_mode_;
510 bool last_can_compose_inline_; 454 bool last_can_compose_inline_;
511 455
512 // This is a queue of messages that are destined to be sent to the embedder 456 // This is a queue of messages that are destined to be sent to the embedder
513 // once the guest is attached to a particular embedder. 457 // once the guest is attached to a particular embedder.
514 std::queue<IPC::Message*> pending_messages_; 458 std::queue<IPC::Message*> pending_messages_;
515 459
516 scoped_ptr<BrowserPluginGuestDelegate> delegate_; 460 scoped_ptr<BrowserPluginGuestDelegate> delegate_;
517 461
518 // These are parameters passed from JavaScript on attachment to the content
519 // embedder.
520 scoped_ptr<base::DictionaryValue> extra_attach_params_;
521
522 // Weak pointer used to ask GeolocationPermissionContext about geolocation 462 // Weak pointer used to ask GeolocationPermissionContext about geolocation
523 // permission. 463 // permission.
524 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; 464 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_;
525 465
526 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 466 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
527 }; 467 };
528 468
529 } // namespace content 469 } // namespace content
530 470
531 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 471 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/web_view/web_view_permission_types.h ('k') | content/browser/browser_plugin/browser_plugin_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698