Chromium Code Reviews| 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 EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ |
| 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
|
lazyboy
2015/04/20 19:08:57
remove?
Fady Samuel
2015/04/20 20:35:23
Done.
| |
| 9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
| 10 #include "extensions/browser/guest_view/guest_view_base.h" | 10 #include "extensions/browser/guest_view/guest_view_base.h" |
| 11 #include "extensions/browser/guest_view/guest_view_manager.h" | |
| 11 | 12 |
| 12 namespace extensions { | 13 namespace extensions { |
| 13 | 14 |
| 14 // 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 |
| 15 // 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- |
| 16 // safe access. See GuestViewBase for more information. | 17 // safe access. See GuestViewBase for more information. |
| 17 template <typename T> | 18 template <typename T> |
| 18 class GuestView : public GuestViewBase { | 19 class GuestView : public GuestViewBase { |
| 19 public: | 20 public: |
| 20 static void Register() { | |
| 21 GuestViewBase::RegisterGuestViewType(T::Type, base::Bind(&T::Create)); | |
| 22 } | |
| 23 | |
| 24 static T* From(int embedder_process_id, int guest_instance_id) { | 21 static T* From(int embedder_process_id, int guest_instance_id) { |
| 25 auto guest = GuestViewBase::From(embedder_process_id, guest_instance_id); | 22 auto guest = GuestViewBase::From(embedder_process_id, guest_instance_id); |
| 26 if (!guest) | 23 if (!guest) |
| 27 return nullptr; | 24 return nullptr; |
| 28 return guest->As<T>(); | 25 return guest->As<T>(); |
| 29 } | 26 } |
| 30 | 27 |
| 31 static T* FromWebContents(const content::WebContents* contents) { | 28 static T* FromWebContents(const content::WebContents* contents) { |
| 32 auto guest = GuestViewBase::FromWebContents(contents); | 29 auto guest = GuestViewBase::FromWebContents(contents); |
| 33 return guest ? guest->As<T>() : nullptr; | 30 return guest ? guest->As<T>() : nullptr; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 : GuestViewBase(owner_web_contents) {} | 62 : GuestViewBase(owner_web_contents) {} |
| 66 ~GuestView() override {} | 63 ~GuestView() override {} |
| 67 | 64 |
| 68 private: | 65 private: |
| 69 DISALLOW_COPY_AND_ASSIGN(GuestView); | 66 DISALLOW_COPY_AND_ASSIGN(GuestView); |
| 70 }; | 67 }; |
| 71 | 68 |
| 72 } // namespace extensions | 69 } // namespace extensions |
| 73 | 70 |
| 74 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ | 71 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ |
| OLD | NEW |