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

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

Issue 769363002: Initialize BrowserPluginGuest to attach to the View hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@basic_detach_plumbing
Patch Set: Addressed nit Created 6 years 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 28 matching lines...) Expand all
39 #include "ui/gfx/rect.h" 39 #include "ui/gfx/rect.h"
40 40
41 class SkBitmap; 41 class SkBitmap;
42 struct BrowserPluginHostMsg_Attach_Params; 42 struct BrowserPluginHostMsg_Attach_Params;
43 struct BrowserPluginHostMsg_ResizeGuest_Params; 43 struct BrowserPluginHostMsg_ResizeGuest_Params;
44 struct FrameHostMsg_CompositorFrameSwappedACK_Params; 44 struct FrameHostMsg_CompositorFrameSwappedACK_Params;
45 struct FrameHostMsg_ReclaimCompositorResources_Params; 45 struct FrameHostMsg_ReclaimCompositorResources_Params;
46 #if defined(OS_MACOSX) 46 #if defined(OS_MACOSX)
47 struct FrameHostMsg_ShowPopup_Params; 47 struct FrameHostMsg_ShowPopup_Params;
48 #endif 48 #endif
49 struct FrameMsg_CompositorFrameSwapped_Params;
Charlie Reis 2014/12/04 22:16:52 Style nit: I think the ifdef'd structs are suppose
Fady Samuel 2014/12/05 00:56:30 Done.
49 50
50 namespace blink { 51 namespace blink {
51 class WebInputEvent; 52 class WebInputEvent;
52 } // namespace blink 53 } // namespace blink
53 54
54 namespace cc { 55 namespace cc {
55 class CompositorFrame; 56 class CompositorFrame;
56 } // namespace cc 57 } // namespace cc
57 58
58 namespace gfx { 59 namespace gfx {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 120
120 // Creates a new guest WebContentsImpl with the provided |params| with |this| 121 // Creates a new guest WebContentsImpl with the provided |params| with |this|
121 // as the |opener|. 122 // as the |opener|.
122 WebContentsImpl* CreateNewGuestWindow( 123 WebContentsImpl* CreateNewGuestWindow(
123 const WebContents::CreateParams& params); 124 const WebContents::CreateParams& params);
124 125
125 // Returns the identifier that uniquely identifies a browser plugin guest 126 // Returns the identifier that uniquely identifies a browser plugin guest
126 // within an embedder. 127 // within an embedder.
127 int browser_plugin_instance_id() const { return browser_plugin_instance_id_; } 128 int browser_plugin_instance_id() const { return browser_plugin_instance_id_; }
128 129
130 void Init();
Charlie Reis 2014/12/04 22:16:52 Perhaps this should be closer to Create? Can you
Fady Samuel 2014/12/05 00:56:30 I moved it right below the constructor.
131
129 bool OnMessageReceivedFromEmbedder(const IPC::Message& message); 132 bool OnMessageReceivedFromEmbedder(const IPC::Message& message);
130 133
131 WebContentsImpl* embedder_web_contents() const { 134 WebContentsImpl* embedder_web_contents() const {
132 return attached_ ? owner_web_contents_ : NULL; 135 return attached_ ? owner_web_contents_ : NULL;
133 } 136 }
134 137
135 // Returns the embedder's RenderWidgetHostView if it is available. 138 // Returns the embedder's RenderWidgetHostView if it is available.
136 // Returns NULL otherwise. 139 // Returns NULL otherwise.
137 RenderWidgetHostView* GetOwnerRenderWidgetHostView(); 140 RenderWidgetHostView* GetOwnerRenderWidgetHostView();
138 141
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 class EmbedderVisibilityObserver; 212 class EmbedderVisibilityObserver;
210 213
211 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and 214 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and
212 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. 215 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest.
213 BrowserPluginGuest(bool has_render_view, 216 BrowserPluginGuest(bool has_render_view,
214 WebContentsImpl* web_contents, 217 WebContentsImpl* web_contents,
215 BrowserPluginGuestDelegate* delegate); 218 BrowserPluginGuestDelegate* delegate);
216 219
217 void WillDestroy(); 220 void WillDestroy();
218 221
219 void Initialize(int browser_plugin_instance_id, 222 void InitInternal(const BrowserPluginHostMsg_Attach_Params& params,
220 const BrowserPluginHostMsg_Attach_Params& params, 223 WebContentsImpl* owner_web_contents);
221 WebContentsImpl* embedder_web_contents);
222 224
223 bool InAutoSizeBounds(const gfx::Size& size) const; 225 bool InAutoSizeBounds(const gfx::Size& size) const;
224 226
225 // Message handlers for messages from embedder. 227 // Message handlers for messages from embedder.
226 void OnCompositorFrameSwappedACK( 228 void OnCompositorFrameSwappedACK(
227 int instance_id, 229 int instance_id,
228 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); 230 const FrameHostMsg_CompositorFrameSwappedACK_Params& params);
229 void OnDetach(int instance_id); 231 void OnDetach(int instance_id);
230 // Handles drag events from the embedder. 232 // Handles drag events from the embedder.
231 // When dragging, the drag events go to the embedder first, and if the drag 233 // When dragging, the drag events go to the embedder first, and if the drag
(...skipping 13 matching lines...) Expand all
245 void OnReclaimCompositorResources( 247 void OnReclaimCompositorResources(
246 int instance_id, 248 int instance_id,
247 const FrameHostMsg_ReclaimCompositorResources_Params& params); 249 const FrameHostMsg_ReclaimCompositorResources_Params& params);
248 250
249 void OnLockMouse(bool user_gesture, 251 void OnLockMouse(bool user_gesture,
250 bool last_unlocked_by_target, 252 bool last_unlocked_by_target,
251 bool privileged); 253 bool privileged);
252 void OnLockMouseAck(int instance_id, bool succeeded); 254 void OnLockMouseAck(int instance_id, bool succeeded);
253 // Resizes the guest's web contents. 255 // Resizes the guest's web contents.
254 void OnResizeGuest( 256 void OnResizeGuest(
255 int instance_id, const BrowserPluginHostMsg_ResizeGuest_Params& params); 257 int browser_plugin_instance_id,
258 const BrowserPluginHostMsg_ResizeGuest_Params& params);
256 void OnSetFocus(int instance_id, bool focused); 259 void OnSetFocus(int instance_id, bool focused);
257 // Sets the name of the guest so that other guests in the same partition can 260 // Sets the name of the guest so that other guests in the same partition can
258 // access it. 261 // access it.
259 void OnSetName(int instance_id, const std::string& name); 262 void OnSetName(int instance_id, const std::string& name);
260 // Updates the size state of the guest. 263 // Updates the size state of the guest.
261 void OnSetEditCommandsForNextKeyEvent( 264 void OnSetEditCommandsForNextKeyEvent(
262 int instance_id, 265 int instance_id,
263 const std::vector<EditCommand>& edit_commands); 266 const std::vector<EditCommand>& edit_commands);
264 // The guest WebContents is visible if both its embedder is visible and 267 // The guest WebContents is visible if both its embedder is visible and
265 // the browser plugin element is visible. If either one is not then the 268 // the browser plugin element is visible. If either one is not then the
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // maintains a JavaScript reference to its opener. 354 // maintains a JavaScript reference to its opener.
352 bool has_render_view_; 355 bool has_render_view_;
353 356
354 // Last seen size of guest contents (by SwapCompositorFrame). 357 // Last seen size of guest contents (by SwapCompositorFrame).
355 gfx::Size last_seen_view_size_; 358 gfx::Size last_seen_view_size_;
356 // Last seen size of BrowserPlugin (by OnResizeGuest). 359 // Last seen size of BrowserPlugin (by OnResizeGuest).
357 gfx::Size last_seen_browser_plugin_size_; 360 gfx::Size last_seen_browser_plugin_size_;
358 361
359 bool is_in_destruction_; 362 bool is_in_destruction_;
360 363
364 // BrowserPluginGuest::Init can only be called once. This flag allows it to
365 // exit early if it's already been called.
366 bool initialized_;
367
361 // Text input type states. 368 // Text input type states.
362 ui::TextInputType last_text_input_type_; 369 ui::TextInputType last_text_input_type_;
363 ui::TextInputMode last_input_mode_; 370 ui::TextInputMode last_input_mode_;
364 int last_input_flags_; 371 int last_input_flags_;
365 bool last_can_compose_inline_; 372 bool last_can_compose_inline_;
366 373
367 // The is the routing ID for a swapped out RenderView for the guest 374 // The is the routing ID for a swapped out RenderView for the guest
368 // WebContents in the embedder's process. 375 // WebContents in the embedder's process.
369 int guest_proxy_routing_id_; 376 int guest_proxy_routing_id_;
370 377
378 // Guests generate frames and send a CompositorFrameSwapped (CFS) message
379 // indicating the next frame is ready to be positioned and composited.
380 // Subsequent frames are not generated until the IPC is ACKed. We would like
381 // to ensure that the guest generates frames on attachment so we directly ACK
382 // an unACKed CFS. ACKs could get lost between the time a guest is detached
383 // from a container and the time it is attached elsewhere. This mitigates this
384 // race by ensuring the guest is ACKed on attachment.
385 scoped_ptr<FrameMsg_CompositorFrameSwapped_Params> pending_frame_;
386
371 // This is a queue of messages that are destined to be sent to the embedder 387 // This is a queue of messages that are destined to be sent to the embedder
372 // once the guest is attached to a particular embedder. 388 // once the guest is attached to a particular embedder.
373 std::deque<linked_ptr<IPC::Message> > pending_messages_; 389 std::deque<linked_ptr<IPC::Message> > pending_messages_;
374 390
375 BrowserPluginGuestDelegate* const delegate_; 391 BrowserPluginGuestDelegate* const delegate_;
376 392
377 // Weak pointer used to ask GeolocationPermissionContext about geolocation 393 // Weak pointer used to ask GeolocationPermissionContext about geolocation
378 // permission. 394 // permission.
379 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; 395 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_;
380 396
381 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 397 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
382 }; 398 };
383 399
384 } // namespace content 400 } // namespace content
385 401
386 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 402 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698