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.
5 #ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
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"
15 class RenderFrameHost;
19 namespace extensions {
23 // ContextMenuContentType is a helper to decide which category/group of items
24 // are relevant for a given RenderFrameHost and a context.
26 // Subclasses can override the behavior of showing/hiding a category.
27 class ContextMenuContentType {
29 virtual ~ContextMenuContentType();
31 // Represents a group of menu items.
32 // Order matters as they are appended in the enum order.
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,
46 ITEM_GROUP_SEARCH_PROVIDER,
48 ITEM_GROUP_ALL_EXTENSION,
49 ITEM_GROUP_CURRENT_EXTENSION,
51 ITEM_GROUP_DEVTOOLS_UNPACKED_EXT,
52 ITEM_GROUP_PRINT_PREVIEW
55 static ContextMenuContentType* Create(
56 content::WebContents* web_contents,
57 content::RenderFrameHost* render_frame_host,
58 const content::ContextMenuParams& params);
60 // Returns if |group| is enabled.
61 virtual bool SupportsGroup(int group);
64 ContextMenuContentType(content::RenderFrameHost* render_frame_host,
65 const content::ContextMenuParams& params,
66 bool supports_custom_items);
68 const content::ContextMenuParams& params() const { return params_; }
70 const extensions::Extension* GetExtension() const;
73 friend class ContextMenuContentTypeFactory;
74 friend class ContextMenuContentTypeTest;
76 bool SupportsGroupInternal(int group);
78 const content::ContextMenuParams params_;
79 content::WebContents* source_web_contents_;
81 const bool supports_custom_items_;
83 DISALLOW_COPY_AND_ASSIGN(ContextMenuContentType);
86 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_