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 CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ |
6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ |
7 | 7 |
8 #include "chrome/browser/guest_view/guest_view_base.h" | 8 #include "chrome/browser/guest_view/guest_view_base.h" |
9 | 9 |
10 template <typename T> | 10 template <typename T> |
11 class GuestView : public GuestViewBase { | 11 class GuestView : public GuestViewBase { |
12 public: | 12 public: |
13 static T* From(int embedder_process_id, int guest_instance_id) { | 13 static T* From(int embedder_process_id, int guest_instance_id) { |
14 GuestViewBase* guest = | 14 GuestViewBase* guest = |
15 GuestViewBase::From(embedder_process_id, guest_instance_id); | 15 GuestViewBase::From(embedder_process_id, guest_instance_id); |
16 if (!guest) | 16 if (!guest) |
17 return NULL; | 17 return NULL; |
18 return guest->As<T>(); | 18 return guest->As<T>(); |
19 } | 19 } |
20 | 20 |
21 static T* FromWebContents(content::WebContents* contents) { | 21 static T* FromWebContents(content::WebContents* contents) { |
22 GuestViewBase* guest = GuestViewBase::FromWebContents(contents); | 22 GuestViewBase* guest = GuestViewBase::FromWebContents(contents); |
23 return guest ? guest->As<T>() : NULL; | 23 return guest ? guest->As<T>() : NULL; |
24 } | 24 } |
25 | 25 |
| 26 T* GetOpener() const { |
| 27 GuestViewBase* guest = GuestViewBase::GetOpener(); |
| 28 if (!guest) |
| 29 return NULL; |
| 30 return guest->As<T>(); |
| 31 } |
| 32 |
| 33 void SetOpener(T* opener) { |
| 34 GuestViewBase::SetOpener(opener); |
| 35 } |
| 36 |
26 // GuestViewBase implementation. | 37 // GuestViewBase implementation. |
27 virtual const char* GetViewType() const OVERRIDE { | 38 virtual const char* GetViewType() const OVERRIDE { |
28 return T::Type; | 39 return T::Type; |
29 } | 40 } |
30 | 41 |
31 protected: | 42 protected: |
32 GuestView(content::WebContents* guest_web_contents, | 43 GuestView(int guest_instance_id, |
33 const std::string& embedder_extension_id, | 44 content::WebContents* guest_web_contents, |
34 const base::WeakPtr<GuestViewBase>& opener) | 45 const std::string& embedder_extension_id) |
35 : GuestViewBase(guest_web_contents, embedder_extension_id, opener) {} | 46 : GuestViewBase(guest_instance_id, |
| 47 guest_web_contents, |
| 48 embedder_extension_id) {} |
36 | 49 |
37 private: | 50 private: |
38 DISALLOW_COPY_AND_ASSIGN(GuestView); | 51 DISALLOW_COPY_AND_ASSIGN(GuestView); |
39 }; | 52 }; |
40 | 53 |
41 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ | 54 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_ |
OLD | NEW |