Roll src/third_party/skia ae6d622:498bc5f
[chromium-blink-merge.git] / components / renderer_context_menu / context_menu_content_type.h
blob81003dd5b17a0c8f0a213271e980388cafe279e9
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"
12 namespace content {
13 class WebContents;
16 namespace extensions {
17 class Extension;
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 {
25 public:
26 virtual ~ContextMenuContentType();
28 // Represents a group of menu items.
29 // Order matters as they are appended in the enum order.
30 enum ItemGroup {
31 ITEM_GROUP_CUSTOM,
32 ITEM_GROUP_PAGE,
33 ITEM_GROUP_FRAME,
34 ITEM_GROUP_LINK,
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,
42 ITEM_GROUP_EDITABLE,
43 ITEM_GROUP_COPY,
44 ITEM_GROUP_SEARCH_PROVIDER,
45 ITEM_GROUP_PRINT,
46 ITEM_GROUP_ALL_EXTENSION,
47 ITEM_GROUP_CURRENT_EXTENSION,
48 ITEM_GROUP_DEVELOPER,
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);
68 protected:
69 const content::ContextMenuParams& params() const { return params_; }
71 const extensions::Extension* GetExtension() const;
73 private:
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
83 // resources.
84 InternalResourcesURLChecker internal_resources_url_checker_;
86 DISALLOW_COPY_AND_ASSIGN(ContextMenuContentType);
89 #endif // COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_