• 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_TEXTFIELD_VIEW_H_
6 #define CEF_LIBCEF_BROWSER_VIEWS_TEXTFIELD_VIEW_H_
7 #pragma once
8 
9 #include "include/views/cef_textfield_delegate.h"
10 
11 #include "include/views/cef_textfield.h"
12 #include "libcef/browser/views/view_view.h"
13 
14 #include "ui/views/controls/textfield/textfield.h"
15 #include "ui/views/controls/textfield/textfield_controller.h"
16 
17 class CefTextfieldView
18     : public CefViewView<views::Textfield, CefTextfieldDelegate>,
19       public views::TextfieldController {
20  public:
21   typedef CefViewView<views::Textfield, CefTextfieldDelegate> ParentClass;
22 
23   // |cef_delegate| may be nullptr.
24   explicit CefTextfieldView(CefTextfieldDelegate* cef_delegate);
25 
26   void Initialize() override;
27 
28   // Returns the CefTextfield associated with this view. See comments on
29   // CefViewView::GetCefView.
GetCefTextfield()30   CefRefPtr<CefTextfield> GetCefTextfield() const {
31     CefRefPtr<CefTextfield> textfield = GetCefView()->AsTextfield();
32     DCHECK(textfield);
33     return textfield;
34   }
35 
36   // TextfieldController methods:
37   bool HandleKeyEvent(views::Textfield* sender,
38                       const ui::KeyEvent& key_event) override;
39   void OnAfterUserAction(views::Textfield* sender) override;
40 
41  private:
42   DISALLOW_COPY_AND_ASSIGN(CefTextfieldView);
43 };
44 
45 #endif  // CEF_LIBCEF_BROWSER_VIEWS_TEXTFIELD_VIEW_H_
46