Chromium Code Reviews| 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_CATEGORY_BASE_H_ | |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_MENU_CATEGORY_BASE_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 // MenuCategoryBase 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 MenuCategoryBase { | |
|
Fady Samuel
2014/02/24 19:07:29
This class represents a context not category. It t
lazyboy
2014/02/24 23:45:00
I've renamed the class to MenuContext, others to M
| |
| 28 public: | |
| 29 virtual ~MenuCategoryBase(); | |
| 30 | |
| 31 // Represents a category of menu item groups. | |
| 32 // Order matters as they are appended in the enum order. | |
| 33 enum ItemCategory { | |
| 34 ITEM_CATEGORY_CUSTOM, | |
|
Fady Samuel
2014/02/24 19:07:29
Do the bit shifting here perhaps?
lazyboy
2014/02/24 23:45:00
Obsolte now since we're not using masks anymore.
| |
| 35 ITEM_CATEGORY_PAGE, | |
| 36 ITEM_CATEGORY_FRAME, | |
| 37 ITEM_CATEGORY_LINK, | |
| 38 ITEM_CATEGORY_MEDIA_IMAGE, | |
| 39 ITEM_CATEGORY_SEARCHWEBFORIMAGE, | |
| 40 ITEM_CATEGORY_MEDIA_VIDEO, | |
| 41 ITEM_CATEGORY_MEDIA_AUDIO, | |
| 42 ITEM_CATEGORY_MEDIA_PLUGIN, | |
| 43 ITEM_CATEGORY_MEDIA_FILE, | |
| 44 ITEM_CATEGORY_EDITABLE, | |
| 45 ITEM_CATEGORY_COPY, | |
| 46 ITEM_CATEGORY_SEARCH_PROVIDER, | |
| 47 ITEM_CATEGORY_PRINT, | |
| 48 ITEM_CATEGORY_ALL_EXTENSION, | |
| 49 ITEM_CATEGORY_CURRENT_EXTENSION, | |
| 50 ITEM_CATEGORY_DEVELOPER, | |
| 51 ITEM_CATEGORY_DEVTOOLS_UNPACKED_EXT, | |
| 52 ITEM_CATEGORY_PRINT_PREVIEW, | |
| 53 ITEM_CATEGORY_LAST = ITEM_CATEGORY_PRINT_PREVIEW | |
| 54 }; | |
|
Fady Samuel
2014/02/24 19:07:29
A helper method here: SupportsCategory(...) might
lazyboy
2014/02/24 23:45:00
Removed bitmask, so this is not required anymore.
| |
| 55 | |
| 56 static MenuCategoryBase* Create( | |
| 57 content::WebContents* web_contents, | |
| 58 content::RenderFrameHost* render_frame_host, | |
| 59 const content::ContextMenuParams& params); | |
| 60 | |
| 61 // Returns a bitmask of |ItemCategory|, representing the list of | |
| 62 // item categories that are enabled. | |
| 63 int GetCategories(); | |
| 64 | |
| 65 protected: | |
| 66 MenuCategoryBase(content::RenderFrameHost* render_frame_host, | |
| 67 const content::ContextMenuParams& params); | |
| 68 | |
| 69 // Returns if |category| is enabled. | |
| 70 virtual bool IsCategoryEnabled(int category); | |
| 71 | |
| 72 const extensions::Extension* GetExtension() const; | |
| 73 | |
| 74 content::ContextMenuParams params_; | |
| 75 content::WebContents* source_web_contents_; | |
| 76 Profile* profile_; | |
| 77 | |
| 78 private: | |
| 79 friend class MenuCategoryFactory; | |
| 80 | |
| 81 bool HasCustomItems(const std::vector<content::MenuItem>& items) const; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(MenuCategoryBase); | |
| 84 }; | |
| 85 | |
| 86 #endif // CHROME_BROWSER_TAB_CONTENTS_MENU_CATEGORY_BASE_H_ | |
| OLD | NEW |