| OLD | NEW |
| 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 COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_ | 5 #ifndef COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_ |
| 6 #define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_ | 6 #define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "components/guest_view/common/guest_view_constants.h" | 13 #include "components/guest_view/common/guest_view_constants.h" |
| 14 #include "components/ui/zoom/zoom_observer.h" | 14 #include "components/ui/zoom/zoom_observer.h" |
| 15 #include "content/public/browser/browser_plugin_guest_delegate.h" | 15 #include "content/public/browser/browser_plugin_guest_delegate.h" |
| 16 #include "content/public/browser/guest_host.h" | 16 #include "content/public/browser/guest_host.h" |
| 17 #include "content/public/browser/render_process_host_observer.h" | 17 #include "content/public/browser/render_process_host_observer.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/browser/web_contents_delegate.h" | 19 #include "content/public/browser/web_contents_delegate.h" |
| 20 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
| 21 | 21 |
| 22 struct RendererContentSettingRules; | 22 struct RendererContentSettingRules; |
| 23 | 23 |
| 24 namespace chrome { |
| 25 class ChromeGuestViewMessageFilter; |
| 26 } |
| 27 |
| 24 namespace guest_view { | 28 namespace guest_view { |
| 25 | 29 |
| 26 class GuestViewEvent; | 30 class GuestViewEvent; |
| 27 | 31 |
| 28 // A struct of parameters for SetSize(). The parameters are all declared as | 32 // A struct of parameters for SetSize(). The parameters are all declared as |
| 29 // scoped pointers since they are all optional. Null pointers indicate that the | 33 // scoped pointers since they are all optional. Null pointers indicate that the |
| 30 // parameter has not been provided, and the last used value should be used. Note | 34 // parameter has not been provided, and the last used value should be used. Note |
| 31 // that when |enable_auto_size| is true, providing |normal_size| is not | 35 // that when |enable_auto_size| is true, providing |normal_size| is not |
| 32 // meaningful. This is because the normal size of the guestview is overridden | 36 // meaningful. This is because the normal size of the guestview is overridden |
| 33 // whenever autosizing occurs. | 37 // whenever autosizing occurs. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // |web_contents| does not belong to a GuestView, it will be returned | 83 // |web_contents| does not belong to a GuestView, it will be returned |
| 80 // unchanged. | 84 // unchanged. |
| 81 static content::WebContents* GetTopLevelWebContents( | 85 static content::WebContents* GetTopLevelWebContents( |
| 82 content::WebContents* web_contents); | 86 content::WebContents* web_contents); |
| 83 | 87 |
| 84 static bool IsGuest(content::WebContents* web_contents); | 88 static bool IsGuest(content::WebContents* web_contents); |
| 85 | 89 |
| 86 // Returns the name of the derived type of this GuestView. | 90 // Returns the name of the derived type of this GuestView. |
| 87 virtual const char* GetViewType() const = 0; | 91 virtual const char* GetViewType() const = 0; |
| 88 | 92 |
| 93 // Invoked if an IPC message is coming from a container attached to this |
| 94 // guest. |
| 95 virtual bool OnMessageReceivedFromEmbedder(const IPC::Message& message); |
| 96 |
| 89 // This method queries whether autosize is supported for this particular view. | 97 // This method queries whether autosize is supported for this particular view. |
| 90 // By default, autosize is not supported. Derived classes can override this | 98 // By default, autosize is not supported. Derived classes can override this |
| 91 // behavior to support autosize. | 99 // behavior to support autosize. |
| 92 virtual bool IsAutoSizeSupported() const; | 100 virtual bool IsAutoSizeSupported() const; |
| 93 | 101 |
| 94 // This method queries whether preferred size events are enabled for this | 102 // This method queries whether preferred size events are enabled for this |
| 95 // view. By default, preferred size events are disabled, since they add a | 103 // view. By default, preferred size events are disabled, since they add a |
| 96 // small amount of overhead. | 104 // small amount of overhead. |
| 97 virtual bool IsPreferredSizeModeEnabled() const; | 105 virtual bool IsPreferredSizeModeEnabled() const; |
| 98 | 106 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 326 |
| 319 // Convert sizes in pixels from physical to logical numbers of pixels. | 327 // Convert sizes in pixels from physical to logical numbers of pixels. |
| 320 // Note that a size can consist of a fractional number of logical pixels | 328 // Note that a size can consist of a fractional number of logical pixels |
| 321 // (hence the return value is represented as a double), but will always | 329 // (hence the return value is represented as a double), but will always |
| 322 // consist of an integral number of physical pixels (hence |physical_pixels| | 330 // consist of an integral number of physical pixels (hence |physical_pixels| |
| 323 // is represented as an int). | 331 // is represented as an int). |
| 324 double PhysicalPixelsToLogicalPixels(int physical_pixels) const; | 332 double PhysicalPixelsToLogicalPixels(int physical_pixels) const; |
| 325 | 333 |
| 326 void SetGuestZoomLevelToMatchEmbedder(); | 334 void SetGuestZoomLevelToMatchEmbedder(); |
| 327 | 335 |
| 328 private: | 336 protected: |
| 329 friend class GuestViewMessageFilter; | 337 friend class GuestViewMessageFilter; |
| 338 // TODO(fsamuel): This is a bit of a hack. Don't make things outside this |
| 339 // component a friend. |
| 340 friend class chrome::ChromeGuestViewMessageFilter; |
| 330 | 341 |
| 331 class OwnerContentsObserver; | 342 class OwnerContentsObserver; |
| 332 class OpenerLifetimeObserver; | 343 class OpenerLifetimeObserver; |
| 333 | 344 |
| 334 // BrowserPluginGuestDelegate implementation. | 345 // BrowserPluginGuestDelegate implementation. |
| 335 content::WebContents* CreateNewGuestWindow( | 346 content::WebContents* CreateNewGuestWindow( |
| 336 const content::WebContents::CreateParams& create_params) final; | 347 const content::WebContents::CreateParams& create_params) final; |
| 337 void DidAttach(int guest_proxy_routing_id) final; | 348 void DidAttach(int guest_proxy_routing_id) final; |
| 338 void DidDetach() final; | 349 void DidDetach() final; |
| 339 content::WebContents* GetOwnerWebContents() const final; | 350 content::WebContents* GetOwnerWebContents() const final; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // This is used to ensure pending tasks will not fire after this object is | 489 // This is used to ensure pending tasks will not fire after this object is |
| 479 // destroyed. | 490 // destroyed. |
| 480 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 491 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
| 481 | 492 |
| 482 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 493 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
| 483 }; | 494 }; |
| 484 | 495 |
| 485 } // namespace guest_view | 496 } // namespace guest_view |
| 486 | 497 |
| 487 #endif // COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_ | 498 #endif // COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_ |
| OLD | NEW |