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 using ParentClass = CefViewView<views::Textfield, CefTextfieldDelegate>; 22 23 // |cef_delegate| may be nullptr. 24 explicit CefTextfieldView(CefTextfieldDelegate* cef_delegate); 25 26 CefTextfieldView(const CefTextfieldView&) = delete; 27 CefTextfieldView& operator=(const CefTextfieldView&) = delete; 28 29 void Initialize() override; 30 31 // Returns the CefTextfield associated with this view. See comments on 32 // CefViewView::GetCefView. GetCefTextfield()33 CefRefPtr<CefTextfield> GetCefTextfield() const { 34 CefRefPtr<CefTextfield> textfield = GetCefView()->AsTextfield(); 35 DCHECK(textfield); 36 return textfield; 37 } 38 39 // TextfieldController methods: 40 bool HandleKeyEvent(views::Textfield* sender, 41 const ui::KeyEvent& key_event) override; 42 void OnAfterUserAction(views::Textfield* sender) override; 43 }; 44 45 #endif // CEF_LIBCEF_BROWSER_VIEWS_TEXTFIELD_VIEW_H_ 46