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"
18 namespace extensions {
22 // ContextMenuContentType is a helper to decide which category/group of items
23 // are relevant for a given WebContents and a context.
25 // Subclasses can override the behavior of showing/hiding a category.
26 class ContextMenuContentType {
28 virtual ~ContextMenuContentType();
30 // Represents a group of menu items.
31 // Order matters as they are appended in the enum order.
37 ITEM_GROUP_MEDIA_IMAGE,
38 ITEM_GROUP_SEARCHWEBFORIMAGE,
39 ITEM_GROUP_MEDIA_VIDEO,
40 ITEM_GROUP_MEDIA_AUDIO,
41 ITEM_GROUP_MEDIA_CANVAS,
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 const content::ContextMenuParams& params);
59 // Returns if |group| is enabled.
60 virtual bool SupportsGroup(int group);
63 ContextMenuContentType(content::WebContents* web_contents,
64 const content::ContextMenuParams& params,
65 bool supports_custom_items);
67 const content::ContextMenuParams& params() const { return params_; }
69 const extensions::Extension* GetExtension() const;
72 friend class ContextMenuContentTypeFactory;
73 friend class ContextMenuContentTypeTest;
75 bool SupportsGroupInternal(int group);
77 const content::ContextMenuParams params_;
78 content::WebContents* source_web_contents_;
80 const bool supports_custom_items_;
82 DISALLOW_COPY_AND_ASSIGN(ContextMenuContentType);
85 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_