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 typedef CefLabelButtonImpl<views::MenuButton, 22 CefMenuButton, 23 CefMenuButtonDelegate> 24 ParentClass; 25 26 // Create a new CefMenuButton instance. |delegate| must not be nullptr. 27 static CefRefPtr<CefMenuButtonImpl> Create( 28 CefRefPtr<CefMenuButtonDelegate> delegate, 29 const CefString& text); 30 31 // CefMenuButton methods: 32 void ShowMenu(CefRefPtr<CefMenuModel> menu_model, 33 const CefPoint& screen_point, 34 cef_menu_anchor_position_t anchor_position) override; 35 void TriggerMenu() override; 36 37 // CefLabelButton methods: AsMenuButton()38 CefRefPtr<CefMenuButton> AsMenuButton() override { return this; } 39 40 // CefViewAdapter methods: GetDebugType()41 std::string GetDebugType() override { return "MenuButton"; } 42 43 // CefView methods: 44 void SetFocusable(bool focusable) override; 45 46 private: 47 // Create a new implementation object. 48 // Always call Initialize() after creation. 49 // |delegate| must not be nullptr. 50 explicit CefMenuButtonImpl(CefRefPtr<CefMenuButtonDelegate> delegate); 51 52 // CefViewImpl methods: 53 views::MenuButton* CreateRootView() override; 54 void InitializeRootView() override; 55 56 IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefMenuButtonImpl); 57 DISALLOW_COPY_AND_ASSIGN(CefMenuButtonImpl); 58 }; 59 60 #endif // CEF_LIBCEF_BROWSER_VIEWS_MENU_BUTTON_IMPL_H_ 61