• 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_BASIC_LABEL_BUTTON_VIEW_H_
6 #define CEF_LIBCEF_BROWSER_VIEWS_BASIC_LABEL_BUTTON_VIEW_H_
7 #pragma once
8 
9 #include "include/views/cef_button_delegate.h"
10 
11 #include "libcef/browser/views/label_button_view.h"
12 
13 #include "ui/views/controls/button/label_button.h"
14 
15 // Extend views::LabelButton with a no-argument constructor as required by the
16 // CefViewView template and extend views::ButtonListener as required by the
17 // CefButtonView template.
18 class LabelButtonEx : public views::LabelButton {
19  public:
LabelButtonEx()20   LabelButtonEx()
21       : views::LabelButton(base::BindRepeating(
22                                [](LabelButtonEx* self, const ui::Event& event) {
23                                  self->ButtonPressed(event);
24                                },
25                                base::Unretained(this)),
26                            std::u16string()) {}
27 
28   virtual void ButtonPressed(const ui::Event& event) = 0;
29 };
30 
31 class CefBasicLabelButtonView
32     : public CefLabelButtonView<LabelButtonEx, CefButtonDelegate> {
33  public:
34   using ParentClass = CefLabelButtonView<LabelButtonEx, CefButtonDelegate>;
35 
36   // |cef_delegate| may be nullptr.
37   explicit CefBasicLabelButtonView(CefButtonDelegate* cef_delegate);
38 
39   CefBasicLabelButtonView(const CefBasicLabelButtonView&) = delete;
40   CefBasicLabelButtonView& operator=(const CefBasicLabelButtonView&) = delete;
41 };
42 
43 #endif  // CEF_LIBCEF_BROWSER_VIEWS_BASIC_LABEL_BUTTON_VIEW_H_
44