• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_NATIVE_WINDOW_DELEGATE_VIEW_H_
6 #define CEF_LIBCEF_BROWSER_NATIVE_WINDOW_DELEGATE_VIEW_H_
7 #pragma once
8 
9 #include "ui/views/widget/widget_delegate.h"
10 
11 namespace content {
12 class WebContents;
13 }
14 
15 namespace views {
16 class WebView;
17 }
18 
19 // Manages the views-based root window that hosts the web contents. This object
20 // will be deleted automatically when the associated root window is destroyed.
21 class CefWindowDelegateView : public views::WidgetDelegateView {
22  public:
23   CefWindowDelegateView(SkColor background_color,
24                         bool always_on_top,
25                         base::RepeatingClosure on_bounds_changed);
26 
27   CefWindowDelegateView(const CefWindowDelegateView&) = delete;
28   CefWindowDelegateView& operator=(const CefWindowDelegateView&) = delete;
29 
30   // Create the Widget and associated root window.
31   void Init(gfx::AcceleratedWidget parent_widget,
32             content::WebContents* web_contents,
33             const gfx::Rect& bounds);
34 
35  private:
36   // Initialize the Widget's content.
37   void InitContent();
38 
39   // WidgetDelegateView methods:
CanMaximize()40   bool CanMaximize() const override { return true; }
GetContentsView()41   View* GetContentsView() override { return this; }
42 
43   // View methods:
44   void ViewHierarchyChanged(
45       const views::ViewHierarchyChangedDetails& details) override;
46   void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
47 
48  private:
49   SkColor background_color_;
50   views::WebView* web_view_;
51   bool always_on_top_;
52   base::RepeatingClosure on_bounds_changed_;
53 };
54 
55 #endif  // CEF_LIBCEF_BROWSER_NATIVE_WINDOW_DELEGATE_VIEW_H_
56