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 COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
6 #define COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
8 #include "base/callback.h"
9 #include "content/public/common/context_menu_params.h"
10 #include "ui/base/models/simple_menu_model.h"
16 namespace extensions
{
20 // ContextMenuContentType is a helper to decide which category/group of items
21 // are relevant for a given WebContents and a context.
23 // Subclasses can override the behavior of showing/hiding a category.
24 class ContextMenuContentType
{
26 virtual ~ContextMenuContentType();
28 // Represents a group of menu items.
29 // Order matters as they are appended in the enum order.
35 ITEM_GROUP_MEDIA_IMAGE
,
36 ITEM_GROUP_SEARCHWEBFORIMAGE
,
37 ITEM_GROUP_MEDIA_VIDEO
,
38 ITEM_GROUP_MEDIA_AUDIO
,
39 ITEM_GROUP_MEDIA_CANVAS
,
40 ITEM_GROUP_MEDIA_PLUGIN
,
41 ITEM_GROUP_MEDIA_FILE
,
44 ITEM_GROUP_SEARCH_PROVIDER
,
46 ITEM_GROUP_ALL_EXTENSION
,
47 ITEM_GROUP_CURRENT_EXTENSION
,
49 ITEM_GROUP_DEVTOOLS_UNPACKED_EXT
,
50 ITEM_GROUP_PRINT_PREVIEW
53 typedef base::Callback
<bool (const GURL
& url
)>
54 InternalResourcesURLChecker
;
56 void set_internal_resources_url_checker(
57 const InternalResourcesURLChecker
& checker
) {
58 internal_resources_url_checker_
= checker
;
61 // Returns if |group| is enabled.
62 virtual bool SupportsGroup(int group
);
64 ContextMenuContentType(content::WebContents
* web_contents
,
65 const content::ContextMenuParams
& params
,
66 bool supports_custom_items
);
69 const content::ContextMenuParams
& params() const { return params_
; }
71 const extensions::Extension
* GetExtension() const;
74 bool SupportsGroupInternal(int group
);
76 bool IsInternalResourcesURL(const GURL
& url
);
78 const content::ContextMenuParams params_
;
79 content::WebContents
* source_web_contents_
;
80 const bool supports_custom_items_
;
82 // A boolean callback to check if the url points to the internal
84 InternalResourcesURLChecker internal_resources_url_checker_
;
86 DISALLOW_COPY_AND_ASSIGN(ContextMenuContentType
);
89 #endif // COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_