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_MENU_BUTTON_IMPL_H_ 6 #define CEF_LIBCEF_BROWSER_VIEWS_MENU_BUTTON_IMPL_H_ 7 #pragma once 8 9 #include "include/views/cef_menu_button.h" 10 #include "include/views/cef_menu_button_delegate.h" 11 12 #include "libcef/browser/menu_model_impl.h" 13 #include "libcef/browser/views/label_button_impl.h" 14 15 #include "ui/views/controls/button/menu_button.h" 16 17 class CefMenuButtonImpl : public CefLabelButtonImpl<views::MenuButton, 18 CefMenuButton, 19 CefMenuButtonDelegate> { 20 public: 21 using ParentClass = CefLabelButtonImpl<views::MenuButton, 22 CefMenuButton, 23 CefMenuButtonDelegate>; 24 25 CefMenuButtonImpl(const CefMenuButtonImpl&) = delete; 26 CefMenuButtonImpl& operator=(const CefMenuButtonImpl&) = delete; 27 28 // Create a new CefMenuButton instance. |delegate| must not be nullptr. 29 static CefRefPtr<CefMenuButtonImpl> Create( 30 CefRefPtr<CefMenuButtonDelegate> delegate, 31 const CefString& text); 32 33 // CefMenuButton methods: 34 void ShowMenu(CefRefPtr<CefMenuModel> menu_model, 35 const CefPoint& screen_point, 36 cef_menu_anchor_position_t anchor_position) override; 37 void TriggerMenu() override; 38 39 // CefLabelButton methods: AsMenuButton()40 CefRefPtr<CefMenuButton> AsMenuButton() override { return this; } 41 42 // CefViewAdapter methods: GetDebugType()43 std::string GetDebugType() override { return "MenuButton"; } 44 45 // CefView methods: 46 void SetFocusable(bool focusable) override; 47 48 private: 49 // Create a new implementation object. 50 // Always call Initialize() after creation. 51 // |delegate| must not be nullptr. 52 explicit CefMenuButtonImpl(CefRefPtr<CefMenuButtonDelegate> delegate); 53 54 // CefViewImpl methods: 55 views::MenuButton* CreateRootView() override; 56 void InitializeRootView() override; 57 58 IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefMenuButtonImpl); 59 }; 60 61 #endif // CEF_LIBCEF_BROWSER_VIEWS_MENU_BUTTON_IMPL_H_ 62