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

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 Charlie's comments 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
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_guest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 25 matching lines...) Expand all
36 #include "third_party/WebKit/public/web/WebInputEvent.h" 36 #include "third_party/WebKit/public/web/WebInputEvent.h"
37 #include "ui/base/ime/text_input_mode.h" 37 #include "ui/base/ime/text_input_mode.h"
38 #include "ui/base/ime/text_input_type.h" 38 #include "ui/base/ime/text_input_type.h"
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 struct FrameMsg_CompositorFrameSwapped_Params;
47
46 #if defined(OS_MACOSX) 48 #if defined(OS_MACOSX)
47 struct FrameHostMsg_ShowPopup_Params; 49 struct FrameHostMsg_ShowPopup_Params;
48 #endif 50 #endif
49 51
50 namespace blink { 52 namespace blink {
51 class WebInputEvent; 53 class WebInputEvent;
52 } // namespace blink 54 } // namespace blink
53 55
54 namespace cc { 56 namespace cc {
55 class CompositorFrame; 57 class CompositorFrame;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // construction and so we pass it in here. 93 // construction and so we pass it in here.
92 static BrowserPluginGuest* Create(WebContentsImpl* web_contents, 94 static BrowserPluginGuest* Create(WebContentsImpl* web_contents,
93 BrowserPluginGuestDelegate* delegate); 95 BrowserPluginGuestDelegate* delegate);
94 96
95 // Returns whether the given WebContents is a BrowserPlugin guest. 97 // Returns whether the given WebContents is a BrowserPlugin guest.
96 static bool IsGuest(WebContentsImpl* web_contents); 98 static bool IsGuest(WebContentsImpl* web_contents);
97 99
98 // Returns whether the given RenderviewHost is a BrowserPlugin guest. 100 // Returns whether the given RenderviewHost is a BrowserPlugin guest.
99 static bool IsGuest(RenderViewHostImpl* render_view_host); 101 static bool IsGuest(RenderViewHostImpl* render_view_host);
100 102
103 // BrowserPluginGuest::Init is called after the associated guest WebContents
104 // initializes. If this guest cannot navigate without being attached to a
105 // container, then this call is a no-op. For guest types that can be
106 // navigated, this call adds the associated RenderWdigetHostViewGuest to the
107 // view hierachy and sets up the appropriate RendererPreferences so that this
108 // guest can navigate and resize offscreen.
109 void Init();
110
101 // Returns a WeakPtr to this BrowserPluginGuest. 111 // Returns a WeakPtr to this BrowserPluginGuest.
102 base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); 112 base::WeakPtr<BrowserPluginGuest> AsWeakPtr();
103 113
104 // Sets the focus state of the current RenderWidgetHostView. 114 // Sets the focus state of the current RenderWidgetHostView.
105 void SetFocus(RenderWidgetHost* rwh, bool focused); 115 void SetFocus(RenderWidgetHost* rwh, bool focused);
106 116
107 // Sets the tooltip text. 117 // Sets the tooltip text.
108 void SetTooltipText(const base::string16& tooltip_text); 118 void SetTooltipText(const base::string16& tooltip_text);
109 119
110 // Sets the lock state of the pointer. Returns true if |allowed| is true and 120 // Sets the lock state of the pointer. Returns true if |allowed| is true and
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 class EmbedderVisibilityObserver; 219 class EmbedderVisibilityObserver;
210 220
211 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and 221 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and
212 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. 222 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest.
213 BrowserPluginGuest(bool has_render_view, 223 BrowserPluginGuest(bool has_render_view,
214 WebContentsImpl* web_contents, 224 WebContentsImpl* web_contents,
215 BrowserPluginGuestDelegate* delegate); 225 BrowserPluginGuestDelegate* delegate);
216 226
217 void WillDestroy(); 227 void WillDestroy();
218 228
219 void Initialize(int browser_plugin_instance_id, 229 void InitInternal(const BrowserPluginHostMsg_Attach_Params& params,
220 const BrowserPluginHostMsg_Attach_Params& params, 230 WebContentsImpl* owner_web_contents);
221 WebContentsImpl* embedder_web_contents);
222 231
223 bool InAutoSizeBounds(const gfx::Size& size) const; 232 bool InAutoSizeBounds(const gfx::Size& size) const;
224 233
225 // Message handlers for messages from embedder. 234 // Message handlers for messages from embedder.
226 void OnCompositorFrameSwappedACK( 235 void OnCompositorFrameSwappedACK(
227 int instance_id, 236 int instance_id,
228 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); 237 const FrameHostMsg_CompositorFrameSwappedACK_Params& params);
229 void OnDetach(int instance_id); 238 void OnDetach(int instance_id);
230 // Handles drag events from the embedder. 239 // Handles drag events from the embedder.
231 // When dragging, the drag events go to the embedder first, and if the drag 240 // When dragging, the drag events go to the embedder first, and if the drag
(...skipping 13 matching lines...) Expand all
245 void OnReclaimCompositorResources( 254 void OnReclaimCompositorResources(
246 int instance_id, 255 int instance_id,
247 const FrameHostMsg_ReclaimCompositorResources_Params& params); 256 const FrameHostMsg_ReclaimCompositorResources_Params& params);
248 257
249 void OnLockMouse(bool user_gesture, 258 void OnLockMouse(bool user_gesture,
250 bool last_unlocked_by_target, 259 bool last_unlocked_by_target,
251 bool privileged); 260 bool privileged);
252 void OnLockMouseAck(int instance_id, bool succeeded); 261 void OnLockMouseAck(int instance_id, bool succeeded);
253 // Resizes the guest's web contents. 262 // Resizes the guest's web contents.
254 void OnResizeGuest( 263 void OnResizeGuest(
255 int instance_id, const BrowserPluginHostMsg_ResizeGuest_Params& params); 264 int browser_plugin_instance_id,
265 const BrowserPluginHostMsg_ResizeGuest_Params& params);
256 void OnSetFocus(int instance_id, bool focused); 266 void OnSetFocus(int instance_id, bool focused);
257 // Sets the name of the guest so that other guests in the same partition can 267 // Sets the name of the guest so that other guests in the same partition can
258 // access it. 268 // access it.
259 void OnSetName(int instance_id, const std::string& name); 269 void OnSetName(int instance_id, const std::string& name);
260 // Updates the size state of the guest. 270 // Updates the size state of the guest.
261 void OnSetEditCommandsForNextKeyEvent( 271 void OnSetEditCommandsForNextKeyEvent(
262 int instance_id, 272 int instance_id,
263 const std::vector<EditCommand>& edit_commands); 273 const std::vector<EditCommand>& edit_commands);
264 // The guest WebContents is visible if both its embedder is visible and 274 // 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 275 // 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. 361 // maintains a JavaScript reference to its opener.
352 bool has_render_view_; 362 bool has_render_view_;
353 363
354 // Last seen size of guest contents (by SwapCompositorFrame). 364 // Last seen size of guest contents (by SwapCompositorFrame).
355 gfx::Size last_seen_view_size_; 365 gfx::Size last_seen_view_size_;
356 // Last seen size of BrowserPlugin (by OnResizeGuest). 366 // Last seen size of BrowserPlugin (by OnResizeGuest).
357 gfx::Size last_seen_browser_plugin_size_; 367 gfx::Size last_seen_browser_plugin_size_;
358 368
359 bool is_in_destruction_; 369 bool is_in_destruction_;
360 370
371 // BrowserPluginGuest::Init can only be called once. This flag allows it to
372 // exit early if it's already been called.
373 bool initialized_;
374
361 // Text input type states. 375 // Text input type states.
362 ui::TextInputType last_text_input_type_; 376 ui::TextInputType last_text_input_type_;
363 ui::TextInputMode last_input_mode_; 377 ui::TextInputMode last_input_mode_;
364 int last_input_flags_; 378 int last_input_flags_;
365 bool last_can_compose_inline_; 379 bool last_can_compose_inline_;
366 380
367 // The is the routing ID for a swapped out RenderView for the guest 381 // The is the routing ID for a swapped out RenderView for the guest
368 // WebContents in the embedder's process. 382 // WebContents in the embedder's process.
369 int guest_proxy_routing_id_; 383 int guest_proxy_routing_id_;
370 384
385 // Guests generate frames and send a CompositorFrameSwapped (CFS) message
386 // indicating the next frame is ready to be positioned and composited.
387 // Subsequent frames are not generated until the IPC is ACKed. We would like
388 // to ensure that the guest generates frames on attachment so we directly ACK
389 // an unACKed CFS. ACKs could get lost between the time a guest is detached
390 // from a container and the time it is attached elsewhere. This mitigates this
391 // race by ensuring the guest is ACKed on attachment.
392 scoped_ptr<FrameMsg_CompositorFrameSwapped_Params> last_pending_frame_;
393
371 // This is a queue of messages that are destined to be sent to the embedder 394 // 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. 395 // once the guest is attached to a particular embedder.
373 std::deque<linked_ptr<IPC::Message> > pending_messages_; 396 std::deque<linked_ptr<IPC::Message> > pending_messages_;
374 397
375 BrowserPluginGuestDelegate* const delegate_; 398 BrowserPluginGuestDelegate* const delegate_;
376 399
377 // Weak pointer used to ask GeolocationPermissionContext about geolocation 400 // Weak pointer used to ask GeolocationPermissionContext about geolocation
378 // permission. 401 // permission.
379 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; 402 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_;
380 403
381 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 404 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
382 }; 405 };
383 406
384 } // namespace content 407 } // namespace content
385 408
386 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 409 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698