Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Unified Diff: chrome/browser/context_menu/context_menu_content_type.h

Issue 169093009: Separate out logic to handle different category/group of context menu items from RVContextMenu class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@work-mmm-refactor1
Patch Set: Forgot to add context_menu_content_type_webview.* Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/context_menu/context_menu_content_type.h
diff --git a/chrome/browser/context_menu/context_menu_content_type.h b/chrome/browser/context_menu/context_menu_content_type.h
new file mode 100644
index 0000000000000000000000000000000000000000..729ed631da80eee521aa31818a17169f697cdda3
--- /dev/null
+++ b/chrome/browser/context_menu/context_menu_content_type.h
@@ -0,0 +1,84 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
+#define CHROME_BROWSER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
+
+#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
+#include "content/public/common/context_menu_params.h"
+#include "ui/base/models/simple_menu_model.h"
+
+class Profile;
+
+namespace content {
+class RenderFrameHost;
+class WebContents;
+}
+
+namespace extensions {
+class Extension;
+}
+
+// ContextMenuContentType is a helper to decide which category/group of items
+// are relevant for a given RenderFrameHost and a context.
+//
+// Subclasses can override the behavior of showing/hiding a category.
+class ContextMenuContentType {
+ public:
+ virtual ~ContextMenuContentType();
+
+ // Represents a group of menu items.
+ // Order matters as they are appended in the enum order.
+ enum ItemGroup {
+ ITEM_GROUP_CUSTOM,
+ ITEM_GROUP_PAGE,
+ ITEM_GROUP_FRAME,
+ ITEM_GROUP_LINK,
+ ITEM_GROUP_MEDIA_IMAGE,
+ ITEM_GROUP_SEARCHWEBFORIMAGE,
+ ITEM_GROUP_MEDIA_VIDEO,
+ ITEM_GROUP_MEDIA_AUDIO,
+ ITEM_GROUP_MEDIA_PLUGIN,
+ ITEM_GROUP_MEDIA_FILE,
+ ITEM_GROUP_EDITABLE,
+ ITEM_GROUP_COPY,
+ ITEM_GROUP_SEARCH_PROVIDER,
+ ITEM_GROUP_PRINT,
+ ITEM_GROUP_ALL_EXTENSION,
+ ITEM_GROUP_CURRENT_EXTENSION,
+ ITEM_GROUP_DEVELOPER,
+ ITEM_GROUP_DEVTOOLS_UNPACKED_EXT,
+ ITEM_GROUP_PRINT_PREVIEW
+ };
+
+ static ContextMenuContentType* Create(
+ content::WebContents* web_contents,
+ content::RenderFrameHost* render_frame_host,
+ const content::ContextMenuParams& params);
+
+ // Returns if |group| is enabled.
+ virtual bool SupportsGroup(int group);
+
+ protected:
+ ContextMenuContentType(content::RenderFrameHost* render_frame_host,
+ const content::ContextMenuParams& params);
+
+ const extensions::Extension* GetExtension() const;
+
+ content::ContextMenuParams params_;
+ content::WebContents* source_web_contents_;
+ Profile* profile_;
+ bool has_custom_items_;
+
+ private:
+ friend class ContextMenuContentTypeFactory;
+
+ bool HasCustomItems(const std::vector<content::MenuItem>& items) const;
+ void Initialize();
+ bool SupportsGroupInternal(int group);
+
+ DISALLOW_COPY_AND_ASSIGN(ContextMenuContentType);
+};
+
+#endif // CHROME_BROWSER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_

Powered by Google App Engine
This is Rietveld 408576698