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

Side by Side Diff: extensions/browser/guest_view/guest_view_base.h

Issue 910073003: <webview>: Make contentWindow available prior to attachment (on display:none). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed creis' comments Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/ui/zoom/zoom_observer.h" 12 #include "components/ui/zoom/zoom_observer.h"
13 #include "content/public/browser/browser_plugin_guest_delegate.h" 13 #include "content/public/browser/browser_plugin_guest_delegate.h"
14 #include "content/public/browser/guest_sizer.h" 14 #include "content/public/browser/guest_proxy_host.h"
15 #include "content/public/browser/render_process_host_observer.h" 15 #include "content/public/browser/render_process_host_observer.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_delegate.h" 17 #include "content/public/browser/web_contents_delegate.h"
18 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
19 #include "extensions/common/guest_view/guest_view_constants.h" 19 #include "extensions/common/guest_view/guest_view_constants.h"
20 20
21 struct RendererContentSettingRules; 21 struct RendererContentSettingRules;
22 22
23 namespace extensions { 23 namespace extensions {
24 24
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 const WebContentsCreatedCallback& callback) = 0; 191 const WebContentsCreatedCallback& callback) = 0;
192 192
193 // This creates a WebContents and initializes |this| GuestViewBase to use the 193 // This creates a WebContents and initializes |this| GuestViewBase to use the
194 // newly created WebContents. 194 // newly created WebContents.
195 void Init(const base::DictionaryValue& create_params, 195 void Init(const base::DictionaryValue& create_params,
196 const WebContentsCreatedCallback& callback); 196 const WebContentsCreatedCallback& callback);
197 197
198 void InitWithWebContents(const base::DictionaryValue& create_params, 198 void InitWithWebContents(const base::DictionaryValue& create_params,
199 content::WebContents* guest_web_contents); 199 content::WebContents* guest_web_contents);
200 200
201 void LoadURLWithParams(
202 const content::NavigationController::LoadURLParams& load_params);
203
201 bool IsViewType(const char* const view_type) const { 204 bool IsViewType(const char* const view_type) const {
202 return !strcmp(GetViewType(), view_type); 205 return !strcmp(GetViewType(), view_type);
203 } 206 }
204 207
205 // Used to toggle autosize mode for this GuestView, and set both the automatic 208 // Used to toggle autosize mode for this GuestView, and set both the automatic
206 // and normal sizes. 209 // and normal sizes.
207 void SetSize(const SetSizeParams& params); 210 void SetSize(const SetSizeParams& params);
208 211
209 bool initialized() const { return initialized_; } 212 bool initialized() const { return initialized_; }
210 213
211 content::WebContents* embedder_web_contents() const { 214 content::WebContents* embedder_web_contents() const {
212 return attached() ? owner_web_contents_ : nullptr; 215 return attached() ? owner_web_contents_ : nullptr;
213 } 216 }
214 217
215 content::WebContents* owner_web_contents() const { 218 content::WebContents* owner_web_contents() const {
216 return owner_web_contents_; 219 return owner_web_contents_;
217 } 220 }
218 221
222 content::GuestProxyHost* proxy_host() const {
223 return guest_proxy_host_;
224 }
225
219 // Returns the parameters associated with the element hosting this GuestView 226 // Returns the parameters associated with the element hosting this GuestView
220 // passed in from JavaScript. 227 // passed in from JavaScript.
221 base::DictionaryValue* attach_params() const { return attach_params_.get(); } 228 base::DictionaryValue* attach_params() const { return attach_params_.get(); }
222 229
223 // Returns whether this guest has an associated embedder. 230 // Returns whether this guest has an associated embedder.
224 bool attached() const { 231 bool attached() const {
225 return element_instance_id_ != guestview::kInstanceIDNone; 232 return element_instance_id_ != guestview::kInstanceIDNone;
226 } 233 }
227 234
228 // Returns the instance ID of the <*view> element. 235 // Returns the instance ID of the <*view> element.
(...skipping 21 matching lines...) Expand all
250 GuestViewBase* GetOpener() const { 257 GuestViewBase* GetOpener() const {
251 return opener_.get(); 258 return opener_.get();
252 } 259 }
253 260
254 // Returns the URL of the owner WebContents. 261 // Returns the URL of the owner WebContents.
255 const GURL& GetOwnerSiteURL() const; 262 const GURL& GetOwnerSiteURL() const;
256 263
257 // Whether the guest view is inside a plugin document. 264 // Whether the guest view is inside a plugin document.
258 bool is_full_page_plugin() { return is_full_page_plugin_; } 265 bool is_full_page_plugin() { return is_full_page_plugin_; }
259 266
267 // Returns the routing ID of the guest proxy in the owner's renderer process.
Charlie Reis 2015/03/09 21:25:22 Mention this is only valid after either attach or
Fady Samuel 2015/03/09 23:02:42 Done.
268 int proxy_routing_id() const { return guest_proxy_routing_id_; }
269
260 // Destroy this guest. 270 // Destroy this guest.
261 void Destroy(); 271 void Destroy();
262 272
263 // Saves the attach state of the custom element hosting this GuestView. 273 // Saves the attach state of the custom element hosting this GuestView.
264 void SetAttachParams(const base::DictionaryValue& params); 274 void SetAttachParams(const base::DictionaryValue& params);
265 void SetOpener(GuestViewBase* opener); 275 void SetOpener(GuestViewBase* opener);
266 276
267 // BrowserPluginGuestDelegate implementation. 277 // BrowserPluginGuestDelegate implementation.
268 content::WebContents* CreateNewGuestWindow( 278 content::WebContents* CreateNewGuestWindow(
269 const content::WebContents::CreateParams& create_params) final; 279 const content::WebContents::CreateParams& create_params) final;
270 void DidAttach(int guest_proxy_routing_id) final; 280 void DidAttach(int guest_proxy_routing_id) final;
271 void DidDetach() final; 281 void DidDetach() final;
272 content::WebContents* GetOwnerWebContents() const final; 282 content::WebContents* GetOwnerWebContents() const final;
273 void GuestSizeChanged(const gfx::Size& new_size) final; 283 void GuestSizeChanged(const gfx::Size& new_size) final;
274 void RegisterDestructionCallback(const DestructionCallback& callback) final; 284 void SetGuestProxyHost(content::GuestProxyHost* guest_proxy_host) final;
275 void SetGuestSizer(content::GuestSizer* guest_sizer) final;
276 void WillAttach(content::WebContents* embedder_web_contents, 285 void WillAttach(content::WebContents* embedder_web_contents,
277 int browser_plugin_instance_id, 286 int browser_plugin_instance_id,
278 bool is_full_page_plugin) final; 287 bool is_full_page_plugin) final;
279 288
280 // ui_zoom::ZoomObserver implementation. 289 // ui_zoom::ZoomObserver implementation.
281 void OnZoomChanged( 290 void OnZoomChanged(
282 const ui_zoom::ZoomController::ZoomChangedEventData& data) override; 291 const ui_zoom::ZoomController::ZoomChangedEventData& data) override;
283 292
284 // Dispatches an event to the guest proxy. 293 // Dispatches an event to the guest proxy.
285 void DispatchEventToGuestProxy(Event* event); 294 void DispatchEventToGuestProxy(Event* event);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // Indicates that this guest is in the process of being destroyed. 398 // Indicates that this guest is in the process of being destroyed.
390 bool is_being_destroyed_; 399 bool is_being_destroyed_;
391 400
392 // This is a queue of Events that are destined to be sent to the embedder once 401 // This is a queue of Events that are destined to be sent to the embedder once
393 // the guest is attached to a particular embedder. 402 // the guest is attached to a particular embedder.
394 std::deque<linked_ptr<Event> > pending_events_; 403 std::deque<linked_ptr<Event> > pending_events_;
395 404
396 // The opener guest view. 405 // The opener guest view.
397 base::WeakPtr<GuestViewBase> opener_; 406 base::WeakPtr<GuestViewBase> opener_;
398 407
399 DestructionCallback destruction_callback_;
400
401 // The parameters associated with the element hosting this GuestView that 408 // The parameters associated with the element hosting this GuestView that
402 // are passed in from JavaScript. This will typically be the view instance ID, 409 // are passed in from JavaScript. This will typically be the view instance ID,
403 // and element-specific parameters. These parameters are passed along to new 410 // and element-specific parameters. These parameters are passed along to new
404 // guests that are created from this guest. 411 // guests that are created from this guest.
405 scoped_ptr<base::DictionaryValue> attach_params_; 412 scoped_ptr<base::DictionaryValue> attach_params_;
406 413
407 // This observer ensures that this guest self-destructs if the embedder goes 414 // This observer ensures that this guest self-destructs if the embedder goes
408 // away. 415 // away.
409 scoped_ptr<OwnerLifetimeObserver> owner_lifetime_observer_; 416 scoped_ptr<OwnerLifetimeObserver> owner_lifetime_observer_;
410 417
411 // This observer ensures that if the guest is unattached and its opener goes 418 // This observer ensures that if the guest is unattached and its opener goes
412 // away then this guest also self-destructs. 419 // away then this guest also self-destructs.
413 scoped_ptr<OpenerLifetimeObserver> opener_lifetime_observer_; 420 scoped_ptr<OpenerLifetimeObserver> opener_lifetime_observer_;
414 421
415 // The size of the guest content. Note: In autosize mode, the container 422 // The size of the guest content. Note: In autosize mode, the container
416 // element may not match the size of the guest. 423 // element may not match the size of the guest.
417 gfx::Size guest_size_; 424 gfx::Size guest_size_;
418 425
419 // A pointer to the guest_sizer. 426 // A pointer to the guest_proxy_host.
420 content::GuestSizer* guest_sizer_; 427 content::GuestProxyHost* guest_proxy_host_;
421 428
422 // Indicates whether autosize mode is enabled or not. 429 // Indicates whether autosize mode is enabled or not.
423 bool auto_size_enabled_; 430 bool auto_size_enabled_;
424 431
425 // The maximum size constraints of the container element in autosize mode. 432 // The maximum size constraints of the container element in autosize mode.
426 gfx::Size max_auto_size_; 433 gfx::Size max_auto_size_;
427 434
428 // The minimum size constraints of the container element in autosize mode. 435 // The minimum size constraints of the container element in autosize mode.
429 gfx::Size min_auto_size_; 436 gfx::Size min_auto_size_;
430 437
431 // The size that will be used when autosize mode is disabled. 438 // The size that will be used when autosize mode is disabled.
432 gfx::Size normal_size_; 439 gfx::Size normal_size_;
433 440
434 // Whether the guest view is inside a plugin document. 441 // Whether the guest view is inside a plugin document.
435 bool is_full_page_plugin_; 442 bool is_full_page_plugin_;
436 443
444 // The routing ID of the proxy to the guest in the owner's renderer process.
445 int guest_proxy_routing_id_;
Charlie Reis 2015/03/09 18:52:59 Why do you need to cache this? It seems like we c
Charlie Reis 2015/03/09 21:25:22 Disregard. Only makes sense in Option 2.
Fady Samuel 2015/03/09 23:02:42 Done.
Fady Samuel 2015/03/09 23:02:42 Done.
446
437 // This is used to ensure pending tasks will not fire after this object is 447 // This is used to ensure pending tasks will not fire after this object is
438 // destroyed. 448 // destroyed.
439 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; 449 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
440 450
441 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); 451 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
442 }; 452 };
443 453
444 } // namespace extensions 454 } // namespace extensions
445 455
446 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 456 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698