Remove unused parameter.
[chromium-blink-merge.git] / extensions / browser / guest_view / guest_view.h
blob9b74df5af3c65ba415d7a3cda0a09ddded61b64a
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_
8 #include "base/bind.h"
9 #include "content/public/browser/render_frame_host.h"
10 #include "extensions/browser/guest_view/guest_view_base.h"
12 namespace extensions {
14 // 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 // safe access. See GuestViewBase for more information.
17 template <typename T>
18 class GuestView : public GuestViewBase {
19 public:
20 static void Register() {
21 GuestViewBase::RegisterGuestViewType(T::Type, base::Bind(&T::Create));
24 static T* From(int embedder_process_id, int guest_instance_id) {
25 auto guest = GuestViewBase::From(embedder_process_id, guest_instance_id);
26 if (!guest)
27 return nullptr;
28 return guest->As<T>();
31 static T* FromWebContents(const content::WebContents* contents) {
32 auto guest = GuestViewBase::FromWebContents(contents);
33 return guest ? guest->As<T>() : nullptr;
36 static T* FromFrameID(int render_process_id, int render_frame_id) {
37 auto render_frame_host =
38 content::RenderFrameHost::FromID(render_process_id, render_frame_id);
39 if (!render_frame_host)
40 return nullptr;
42 auto web_contents =
43 content::WebContents::FromRenderFrameHost(render_frame_host);
44 return FromWebContents(web_contents);
47 T* GetOpener() const {
48 GuestViewBase* guest = GuestViewBase::GetOpener();
49 if (!guest)
50 return nullptr;
51 return guest->As<T>();
54 void SetOpener(T* opener) {
55 GuestViewBase::SetOpener(opener);
58 // GuestViewBase implementation.
59 const char* GetViewType() const final {
60 return T::Type;
63 protected:
64 explicit GuestView(content::WebContents* owner_web_contents)
65 : GuestViewBase(owner_web_contents) {}
66 ~GuestView() override {}
68 private:
69 DISALLOW_COPY_AND_ASSIGN(GuestView);
72 } // namespace extensions
74 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_H_