1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_WEBUI_MENU_CONTROL_H_ 6 #define CHROME_BROWSER_CHROMEOS_WEBUI_MENU_CONTROL_H_ 7 #pragma once 8 9 namespace gfx { 10 class Size; 11 } // namespace gfx 12 13 namespace ui { 14 class MenuModel; 15 } // namespace ui 16 17 namespace chromeos { 18 19 // WebUIMenuControl class is used to control the UI counterpart of 20 // a MenuModel. One instance of WebUIMenuControl is created for each 21 // MenuModel instance, that is, a submenu will have its own 22 // WebUIMenuControl. 23 class WebUIMenuControl { 24 public: 25 enum ActivationMode { 26 ACTIVATE_NO_CLOSE, // Activate the command without closing menu. 27 CLOSE_AND_ACTIVATE, // Close the menu and then activate the command. 28 }; 29 virtual ~WebUIMenuControl() {} 30 31 // Returns the MenuModel associated with this control. 32 virtual ui::MenuModel* GetMenuModel() = 0; 33 34 // Activates an item in the |model| at |index|. 35 virtual void Activate(ui::MenuModel* model, 36 int index, 37 ActivationMode activation_mode) = 0; 38 39 // Close All menu window from root menu to leaf submenus. 40 virtual void CloseAll() = 0; 41 42 // Close the submenu (and all decendant submenus). 43 virtual void CloseSubmenu() = 0; 44 45 // Move the input to parent. Used in keyboard navigation. 46 virtual void MoveInputToParent() = 0; 47 48 // Move the input to submenu. Used in keyboard navigation. 49 virtual void MoveInputToSubmenu() = 0; 50 51 // Called when the menu page is loaded. This is used to call 52 // initialize function in JavaScript. 53 virtual void OnLoad() = 0; 54 55 // Open submenu using the submenu model at index in the model. 56 // The top coordinate of the selected menu is passed as |y_top| 57 // so that the submenu can be aligned to the selected item. 58 virtual void OpenSubmenu(int index, int y_top) =0; 59 60 // Sets the size of the menu. 61 virtual void SetSize(const gfx::Size& size) = 0; 62 }; 63 64 } // namespace chromeos 65 66 #endif // CHROME_BROWSER_CHROMEOS_WEBUI_MENU_CONTROL_H_ 67