summaryrefslogtreecommitdiff
path: root/libcef/browser/views/view_adapter.h
blob: 958be7f714f91db139b579e027caf7fbd6f670e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.

#ifndef CEF_LIBCEF_BROWSER_VIEWS_VIEW_ADAPTER_H_
#define CEF_LIBCEF_BROWSER_VIEWS_VIEW_ADAPTER_H_
#pragma once

#include "include/views/cef_view.h"

#include "base/values.h"

namespace views {
class View;
}

// Exposes a common interface from all CefView implementation objects to
// simplify the view_util implementation. See comments in view_impl.h for a
// usage overview.
class CefViewAdapter {
 public:
  CefViewAdapter() {}

  // Returns the CefViewAdapter for the specified |view|.
  static CefViewAdapter* GetFor(CefRefPtr<CefView> view);
  static CefViewAdapter* GetFor(views::View* view);

  // Returns the underlying views::View object. Does not transfer ownership.
  virtual views::View* Get() const = 0;

  // Pass ownership of the underlying views::View object to the caller. This
  // object keeps an unowned reference to the views::View object. This is called
  // when the views::View is parented to another views::View.
  virtual std::unique_ptr<views::View> PassOwnership() = 0;

  // Resume ownership of the underlying views::View object. This is called when
  // the views::View is no longer parented to another views::View.
  virtual void ResumeOwnership() = 0;

  // Release all references to the views::View object. This is called when the
  // views::View is deleted after being parented to another views::View.
  virtual void Detach() = 0;

  // Override this method to provide a string representation of the View type.
  // Only implement this method in concrete classes.
  virtual std::string GetDebugType() = 0;

  // Override this method to provide debug info specific to the View type.
  virtual void GetDebugInfo(base::Value::Dict* info, bool include_children) = 0;

 protected:
  virtual ~CefViewAdapter() {}
};

#endif  // CEF_LIBCEF_BROWSER_VIEWS_VIEW_ADAPTER_H_