| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 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_TAB_CONTENTS_MENU_CONTEXT_MENU_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_MENU_CONTEXT_MENU_CONTEXT_H_ |
| 7 |
| 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 9 #include "content/public/common/context_menu_params.h" |
| 10 #include "ui/base/models/simple_menu_model.h" |
| 11 |
| 12 class Profile; |
| 13 |
| 14 namespace content { |
| 15 class RenderFrameHost; |
| 16 class WebContents; |
| 17 } |
| 18 |
| 19 namespace extensions { |
| 20 class Extension; |
| 21 } |
| 22 |
| 23 // MenuContext is a helper to decide which category/group of items are |
| 24 // relevant for a given RenderFrameHost and a context. |
| 25 // |
| 26 // Subclasses can override the behavior of showing/hiding a category. |
| 27 class MenuContext { |
| 28 public: |
| 29 virtual ~MenuContext(); |
| 30 |
| 31 // Represents a group of menu items. |
| 32 // Order matters as they are appended in the enum order. |
| 33 enum ItemGroup { |
| 34 ITEM_GROUP_CUSTOM, |
| 35 ITEM_GROUP_PAGE, |
| 36 ITEM_GROUP_FRAME, |
| 37 ITEM_GROUP_LINK, |
| 38 ITEM_GROUP_MEDIA_IMAGE, |
| 39 ITEM_GROUP_SEARCHWEBFORIMAGE, |
| 40 ITEM_GROUP_MEDIA_VIDEO, |
| 41 ITEM_GROUP_MEDIA_AUDIO, |
| 42 ITEM_GROUP_MEDIA_PLUGIN, |
| 43 ITEM_GROUP_MEDIA_FILE, |
| 44 ITEM_GROUP_EDITABLE, |
| 45 ITEM_GROUP_COPY, |
| 46 ITEM_GROUP_SEARCH_PROVIDER, |
| 47 ITEM_GROUP_PRINT, |
| 48 ITEM_GROUP_ALL_EXTENSION, |
| 49 ITEM_GROUP_CURRENT_EXTENSION, |
| 50 ITEM_GROUP_DEVELOPER, |
| 51 ITEM_GROUP_DEVTOOLS_UNPACKED_EXT, |
| 52 ITEM_GROUP_PRINT_PREVIEW |
| 53 }; |
| 54 |
| 55 static MenuContext* Create(content::WebContents* web_contents, |
| 56 content::RenderFrameHost* render_frame_host, |
| 57 const content::ContextMenuParams& params); |
| 58 |
| 59 // Returns if |group| is enabled. |
| 60 virtual bool SupportsGroup(int group); |
| 61 |
| 62 protected: |
| 63 MenuContext(content::RenderFrameHost* render_frame_host, |
| 64 const content::ContextMenuParams& params); |
| 65 |
| 66 const extensions::Extension* GetExtension() const; |
| 67 |
| 68 content::ContextMenuParams params_; |
| 69 content::WebContents* source_web_contents_; |
| 70 Profile* profile_; |
| 71 bool has_custom_items_; |
| 72 |
| 73 private: |
| 74 friend class MenuContextFactory; |
| 75 |
| 76 bool HasCustomItems(const std::vector<content::MenuItem>& items) const; |
| 77 void Initialize(); |
| 78 bool SupportsGroupInternal(int group); |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(MenuContext); |
| 81 }; |
| 82 |
| 83 #endif // CHROME_BROWSER_TAB_CONTENTS_MENU_CONTEXT_MENU_CONTEXT_H_ |
| OLD | NEW |