• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be found
3 // in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_VIEW_H_
6 #define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_VIEW_H_
7 #pragma once
8 
9 #include "include/views/cef_browser_view_delegate.h"
10 
11 #include "libcef/browser/views/view_view.h"
12 
13 #include "ui/views/controls/webview/webview.h"
14 
15 // Extend views::WebView with a no-argument constructor as required by the
16 // CefViewView template.
17 class WebViewEx : public views::WebView {
18  public:
WebViewEx()19   WebViewEx() : views::WebView(nullptr) {}
20 };
21 
22 class CefBrowserViewView
23     : public CefViewView<WebViewEx, CefBrowserViewDelegate> {
24  public:
25   using ParentClass = CefViewView<WebViewEx, CefBrowserViewDelegate>;
26 
27   CefBrowserViewView(const CefBrowserViewView&) = delete;
28   CefBrowserViewView& operator=(const CefBrowserViewView&) = delete;
29 
30   class Delegate {
31    public:
32     // Called when the BrowserView has been added to a parent view.
33     virtual void OnBrowserViewAdded() = 0;
34 
35     // Called when the BrowserView bounds have changed.
36     virtual void OnBoundsChanged() = 0;
37 
38    protected:
~Delegate()39     virtual ~Delegate() {}
40   };
41 
42   // |cef_delegate| may be nullptr.
43   // |browser_view_delegate| must be non-nullptr.
44   CefBrowserViewView(CefBrowserViewDelegate* cef_delegate,
45                      Delegate* browser_view_delegate);
46 
47   // View methods:
48   void ViewHierarchyChanged(
49       const views::ViewHierarchyChangedDetails& details) override;
50   void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
51 
52  private:
53   // Not owned by this object.
54   Delegate* browser_view_delegate_;
55 };
56 
57 #endif  // CEF_LIBCEF_BROWSER_VIEWS_BROWSER_VIEW_VIEW_H_
58