OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 ASH_RENDERER_CONTEXT_MENU_OPEN_WITH_MENU_CONTROLLER_H_ |
| 6 #define ASH_RENDERER_CONTEXT_MENU_OPEN_WITH_MENU_CONTROLLER_H_ |
| 7 |
| 8 #include "ash/ash_export.h" |
| 9 #include "base/macros.h" |
| 10 |
| 11 class GURL; |
| 12 class RenderViewContextMenuProxy; |
| 13 |
| 14 namespace ash { |
| 15 |
| 16 // A class for populating and updating "Open with <app>" menu items in a |
| 17 // renderer context menu. |
| 18 class ASH_EXPORT OpenWithMenuController { |
| 19 public: |
| 20 class Delegate { |
| 21 public: |
| 22 virtual ~Delegate() {} |
| 23 virtual int PopulateOpenWithMenu(RenderViewContextMenuProxy* proxy, |
| 24 int menu_id_start, |
| 25 size_t num_menu_items, |
| 26 const GURL& url) = 0; |
| 27 virtual void ExecuteCommand(int id) = 0; |
| 28 virtual void MenuClosed() = 0; |
| 29 }; |
| 30 |
| 31 OpenWithMenuController(); |
| 32 void SetDelegate(Delegate* delegate); |
| 33 |
| 34 // Populates "Open with <app>" context menu items for the |url| either |
| 35 // synchronously or asynchronously. Returns the number of menu items that have |
| 36 // to be enabled right away. When there is nothing to do for the |url|, the |
| 37 // function immediately returns 0. The function adds up to |num_menu_items| |
| 38 // context menu items starting from |menu_id_start| to the |proxy|. |
| 39 int PopulateOpenWithMenu(RenderViewContextMenuProxy* proxy, |
| 40 int menu_id_start, |
| 41 size_t num_menu_items, |
| 42 const GURL& url); |
| 43 |
| 44 // Notifies the controller that one of the items in the context menu is |
| 45 // executed. This method can only be called after PopulateOpenWithMenu() |
| 46 // is called and before MenuClosed() is called. |
| 47 void ExecuteCommand(int id); |
| 48 |
| 49 // Notifies the controller that the context menu is being closed. |
| 50 void MenuClosed(); |
| 51 |
| 52 private: |
| 53 Delegate* delegate_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(OpenWithMenuController); |
| 56 }; |
| 57 |
| 58 } // namespace ash |
| 59 |
| 60 #endif // ASH_RENDERER_CONTEXT_MENU_OPEN_WITH_MENU_CONTROLLER_H_ |
OLD | NEW |