• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2021 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #ifndef CEF_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_CONTROLS_H_
6 #define CEF_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_CONTROLS_H_
7 #pragma once
8 
9 #include "include/views/cef_button_delegate.h"
10 #include "include/views/cef_label_button.h"
11 #include "include/views/cef_menu_button.h"
12 #include "include/views/cef_overlay_controller.h"
13 #include "include/views/cef_panel.h"
14 
15 namespace client {
16 
17 // Implements window overlay controls that receive absolute positioning on top
18 // of the browser view. All methods must be called on the browser process UI
19 // thread.
20 class ViewsOverlayControls : public CefButtonDelegate {
21  public:
22   enum class Command {
23     kMinimize = 1,
24     kMaximize,
25     kClose,
26   };
27 
28   ViewsOverlayControls();
29 
30   void Initialize(CefRefPtr<CefWindow> window,
31                   CefRefPtr<CefMenuButton> menu_button,
32                   CefRefPtr<CefView> location_bar,
33                   bool is_chrome_toolbar);
34   void Destroy();
35 
36   // Update window control button state and location bar bounds.
37   void UpdateControls();
38 
39   // Exclude all regions obscured by overlays.
40   void UpdateDraggableRegions(std::vector<CefDraggableRegion>& window_regions);
41 
42  private:
43   // CefButtonDelegate methods:
44   void OnButtonPressed(CefRefPtr<CefButton> button) override;
45 
46   CefRefPtr<CefLabelButton> CreateButton(Command command);
47 
48   void MaybeUpdateMaximizeButton();
49 
50   CefRefPtr<CefWindow> window_;
51   bool window_maximized_;
52 
53   // Window control buttons.
54   CefRefPtr<CefPanel> panel_;
55   CefRefPtr<CefOverlayController> panel_controller_;
56 
57   // Location bar.
58   CefRefPtr<CefView> location_bar_;
59   bool is_chrome_toolbar_;
60   CefRefPtr<CefOverlayController> location_controller_;
61 
62   // Menu button.
63   CefRefPtr<CefOverlayController> menu_controller_;
64 
65   IMPLEMENT_REFCOUNTING(ViewsOverlayControls);
66   DISALLOW_COPY_AND_ASSIGN(ViewsOverlayControls);
67 };
68 
69 }  // namespace client
70 
71 #endif  // CEF_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_CONTROLS_H_
72