| 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_H_ | 5 #ifndef COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_H_ |
| 6 #define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_H_ | 6 #define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/guest_view/browser/guest_view_base.h" | 9 #include "components/guest_view/browser/guest_view_base.h" |
| 10 #include "components/guest_view/browser/guest_view_manager.h" | 10 #include "components/guest_view/browser/guest_view_manager.h" |
| 11 #include "content/public/browser/render_frame_host.h" | 11 #include "content/public/browser/render_frame_host.h" |
| 12 | 12 |
| 13 namespace guest_view { | 13 namespace guest_view { |
| 14 | 14 |
| 15 // A GuestView is the templated base class for out-of-process frames in the | 15 // A GuestView is the templated base class for out-of-process frames in the |
| 16 // chrome layer. GuestView is templated on its derived type to allow for type- | 16 // chrome layer. GuestView is templated on its derived type to allow for type- |
| 17 // safe access. See GuestViewBase for more information. | 17 // safe access. See GuestViewBase for more information. |
| 18 template <typename T> | 18 template <typename T> |
| 19 class GuestView : public GuestViewBase { | 19 class GuestView : public GuestViewBase { |
| 20 public: | 20 public: |
| 21 static T* From(int embedder_process_id, int guest_instance_id) { | 21 static T* From(int embedder_process_id, int guest_instance_id) { |
| 22 auto guest = GuestViewBase::From(embedder_process_id, guest_instance_id); | 22 auto* guest = GuestViewBase::From(embedder_process_id, guest_instance_id); |
| 23 if (!guest) | 23 if (!guest) |
| 24 return nullptr; | 24 return nullptr; |
| 25 return guest->As<T>(); | 25 return guest->As<T>(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 static T* FromWebContents(const content::WebContents* contents) { | 28 static T* FromWebContents(const content::WebContents* contents) { |
| 29 auto guest = GuestViewBase::FromWebContents(contents); | 29 auto* guest = GuestViewBase::FromWebContents(contents); |
| 30 return guest ? guest->As<T>() : nullptr; | 30 return guest ? guest->As<T>() : nullptr; |
| 31 } | 31 } |
| 32 | 32 |
| 33 static T* FromFrameID(int render_process_id, int render_frame_id) { | 33 static T* FromFrameID(int render_process_id, int render_frame_id) { |
| 34 auto render_frame_host = | 34 auto* render_frame_host = |
| 35 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | 35 content::RenderFrameHost::FromID(render_process_id, render_frame_id); |
| 36 if (!render_frame_host) | 36 if (!render_frame_host) |
| 37 return nullptr; | 37 return nullptr; |
| 38 | 38 |
| 39 auto web_contents = | 39 auto* web_contents = |
| 40 content::WebContents::FromRenderFrameHost(render_frame_host); | 40 content::WebContents::FromRenderFrameHost(render_frame_host); |
| 41 return FromWebContents(web_contents); | 41 return FromWebContents(web_contents); |
| 42 } | 42 } |
| 43 | 43 |
| 44 T* GetOpener() const { | 44 T* GetOpener() const { |
| 45 GuestViewBase* guest = GuestViewBase::GetOpener(); | 45 GuestViewBase* guest = GuestViewBase::GetOpener(); |
| 46 if (!guest) | 46 if (!guest) |
| 47 return nullptr; | 47 return nullptr; |
| 48 return guest->As<T>(); | 48 return guest->As<T>(); |
| 49 } | 49 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 62 : GuestViewBase(owner_web_contents) {} | 62 : GuestViewBase(owner_web_contents) {} |
| 63 ~GuestView() override {} | 63 ~GuestView() override {} |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 DISALLOW_COPY_AND_ASSIGN(GuestView); | 66 DISALLOW_COPY_AND_ASSIGN(GuestView); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace guest_view | 69 } // namespace guest_view |
| 70 | 70 |
| 71 #endif // COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_H_ | 71 #endif // COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_H_ |
| OLD | NEW |