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

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

Issue 800543005: Revert of Implemented explicit resizing from guestview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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_sizer.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
25 // A struct of parameters for SetSize(). The parameters are all declared as
26 // scoped pointers since they are all optional. Null pointers indicate that the
27 // parameter has not been provided, and the last used value should be used. Note
28 // that when |enable_auto_size| is true, providing |normal_size| is not
29 // meaningful. This is because the normal size of the guestview is overridden
30 // whenever autosizing occurs.
31 struct SetSizeParams {
32 SetSizeParams();
33 ~SetSizeParams();
34
35 scoped_ptr<bool> enable_auto_size;
36 scoped_ptr<gfx::Size> min_size;
37 scoped_ptr<gfx::Size> max_size;
38 scoped_ptr<gfx::Size> normal_size;
39 };
40
41 // A GuestViewBase is the base class browser-side API implementation for a 25 // A GuestViewBase is the base class browser-side API implementation for a
42 // <*view> tag. GuestViewBase maintains an association between a guest 26 // <*view> tag. GuestViewBase maintains an association between a guest
43 // WebContents and an owner WebContents. It receives events issued from 27 // WebContents and an owner WebContents. It receives events issued from
44 // the guest and relays them to the owner. GuestViewBase tracks the lifetime 28 // the guest and relays them to the owner. GuestViewBase tracks the lifetime
45 // of its owner. A GuestViewBase's owner is referred to as an embedder if 29 // of its owner. A GuestViewBase's owner is referred to as an embedder if
46 // it is attached to a container within the owner's WebContents. 30 // it is attached to a container within the owner's WebContents.
47 class GuestViewBase : public content::BrowserPluginGuestDelegate, 31 class GuestViewBase : public content::BrowserPluginGuestDelegate,
48 public content::WebContentsDelegate, 32 public content::WebContentsDelegate,
49 public content::WebContentsObserver, 33 public content::WebContentsObserver,
50 public ui_zoom::ZoomObserver { 34 public ui_zoom::ZoomObserver {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void Init(const base::DictionaryValue& create_params, 183 void Init(const base::DictionaryValue& create_params,
200 const WebContentsCreatedCallback& callback); 184 const WebContentsCreatedCallback& callback);
201 185
202 void InitWithWebContents(const base::DictionaryValue& create_params, 186 void InitWithWebContents(const base::DictionaryValue& create_params,
203 content::WebContents* guest_web_contents); 187 content::WebContents* guest_web_contents);
204 188
205 bool IsViewType(const char* const view_type) const { 189 bool IsViewType(const char* const view_type) const {
206 return !strcmp(GetViewType(), view_type); 190 return !strcmp(GetViewType(), view_type);
207 } 191 }
208 192
209 // Used to toggle autosize mode for this GuestView, and set both the automatic 193 // Toggles autosize mode for this GuestView.
210 // and normal sizes. 194 void SetAutoSize(bool enabled,
211 void SetSize(const SetSizeParams& params); 195 const gfx::Size& min_size,
196 const gfx::Size& max_size);
212 197
213 bool initialized() const { return initialized_; } 198 bool initialized() const { return initialized_; }
214 199
215 content::WebContents* embedder_web_contents() const { 200 content::WebContents* embedder_web_contents() const {
216 return attached() ? owner_web_contents_ : NULL; 201 return attached() ? owner_web_contents_ : NULL;
217 } 202 }
218 203
219 content::WebContents* owner_web_contents() const { 204 content::WebContents* owner_web_contents() const {
220 return owner_web_contents_; 205 return owner_web_contents_;
221 } 206 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 class OwnerLifetimeObserver; 284 class OwnerLifetimeObserver;
300 285
301 class OpenerLifetimeObserver; 286 class OpenerLifetimeObserver;
302 287
303 void SendQueuedEvents(); 288 void SendQueuedEvents();
304 289
305 void CompleteInit(scoped_ptr<base::DictionaryValue> create_params, 290 void CompleteInit(scoped_ptr<base::DictionaryValue> create_params,
306 const WebContentsCreatedCallback& callback, 291 const WebContentsCreatedCallback& callback,
307 content::WebContents* guest_web_contents); 292 content::WebContents* guest_web_contents);
308 293
309 void SetUpSizing(const base::DictionaryValue& params); 294 void SetUpAutoSize(const base::DictionaryValue& params);
310 295
311 void StartTrackingEmbedderZoomLevel(); 296 void StartTrackingEmbedderZoomLevel();
312 void StopTrackingEmbedderZoomLevel(); 297 void StopTrackingEmbedderZoomLevel();
313 298
314 static void RegisterGuestViewTypes(); 299 static void RegisterGuestViewTypes();
315 300
316 // WebContentsObserver implementation. 301 // WebContentsObserver implementation.
317 void DidStopLoading(content::RenderViewHost* render_view_host) final; 302 void DidStopLoading(content::RenderViewHost* render_view_host) final;
318 void RenderViewReady() final; 303 void RenderViewReady() final;
319 void WebContentsDestroyed() final; 304 void WebContentsDestroyed() final;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 scoped_ptr<base::DictionaryValue> attach_params_; 356 scoped_ptr<base::DictionaryValue> attach_params_;
372 357
373 // This observer ensures that this guest self-destructs if the embedder goes 358 // This observer ensures that this guest self-destructs if the embedder goes
374 // away. 359 // away.
375 scoped_ptr<OwnerLifetimeObserver> owner_lifetime_observer_; 360 scoped_ptr<OwnerLifetimeObserver> owner_lifetime_observer_;
376 361
377 // This observer ensures that if the guest is unattached and its opener goes 362 // This observer ensures that if the guest is unattached and its opener goes
378 // away then this guest also self-destructs. 363 // away then this guest also self-destructs.
379 scoped_ptr<OpenerLifetimeObserver> opener_lifetime_observer_; 364 scoped_ptr<OpenerLifetimeObserver> opener_lifetime_observer_;
380 365
366 // The size of the container element.
367 gfx::Size element_size_;
368
381 // The size of the guest content. Note: In autosize mode, the container 369 // The size of the guest content. Note: In autosize mode, the container
382 // element may not match the size of the guest. 370 // element may not match the size of the guest.
383 gfx::Size guest_size_; 371 gfx::Size guest_size_;
384 372
385 // A pointer to the guest_sizer. 373 // A pointer to the guest_sizer.
386 content::GuestSizer* guest_sizer_; 374 content::GuestSizer* guest_sizer_;
387 375
388 // Indicates whether autosize mode is enabled or not. 376 // Indicates whether autosize mode is enabled or not.
389 bool auto_size_enabled_; 377 bool auto_size_enabled_;
390 378
391 // The maximum size constraints of the container element in autosize mode. 379 // The maximum size constraints of the container element in autosize mode.
392 gfx::Size max_auto_size_; 380 gfx::Size max_auto_size_;
393 381
394 // The minimum size constraints of the container element in autosize mode. 382 // The minimum size constraints of the container element in autosize mode.
395 gfx::Size min_auto_size_; 383 gfx::Size min_auto_size_;
396 384
397 // The size that will be used when autosize mode is disabled.
398 gfx::Size normal_size_;
399
400 // Whether the guest view is inside a plugin document. 385 // Whether the guest view is inside a plugin document.
401 bool is_full_page_plugin_; 386 bool is_full_page_plugin_;
402 387
403 // This is used to ensure pending tasks will not fire after this object is 388 // This is used to ensure pending tasks will not fire after this object is
404 // destroyed. 389 // destroyed.
405 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; 390 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
406 391
407 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); 392 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
408 }; 393 };
409 394
410 } // namespace extensions 395 } // namespace extensions
411 396
412 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 397 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/guest_view/guest_view_internal_api.cc ('k') | extensions/browser/guest_view/guest_view_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698