Introduce ProfilerMetricsProvider
[chromium-blink-merge.git] / chrome / browser / guest_view / guest_view.h
blobc7d854f9a9656897a657c4b94b148073de5e542f
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 CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_
6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_
8 #include "chrome/browser/guest_view/guest_view_base.h"
10 // A GuestView is the templated base class for out-of-process frames in the
11 // chrome layer. GuestView is templated on its derived type to allow for type-
12 // safe access. See GuestViewBase for more information.
13 template <typename T>
14 class GuestView : public GuestViewBase {
15 public:
16 static T* From(int embedder_process_id, int guest_instance_id) {
17 GuestViewBase* guest =
18 GuestViewBase::From(embedder_process_id, guest_instance_id);
19 if (!guest)
20 return NULL;
21 return guest->As<T>();
24 static T* FromWebContents(content::WebContents* contents) {
25 GuestViewBase* guest = GuestViewBase::FromWebContents(contents);
26 return guest ? guest->As<T>() : NULL;
29 T* GetOpener() const {
30 GuestViewBase* guest = GuestViewBase::GetOpener();
31 if (!guest)
32 return NULL;
33 return guest->As<T>();
36 void SetOpener(T* opener) {
37 GuestViewBase::SetOpener(opener);
40 // GuestViewBase implementation.
41 virtual const char* GetViewType() const OVERRIDE {
42 return T::Type;
45 protected:
46 GuestView(int guest_instance_id,
47 content::WebContents* guest_web_contents,
48 const std::string& embedder_extension_id)
49 : GuestViewBase(guest_instance_id,
50 guest_web_contents,
51 embedder_extension_id) {}
52 virtual ~GuestView() {}
54 private:
55 DISALLOW_COPY_AND_ASSIGN(GuestView);
58 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_H_