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

Unified Diff: chrome/browser/tab_contents/menu_category_base.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: fix incorrect dcheck + platform app logic 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/tab_contents/menu_category_base.h
diff --git a/chrome/browser/tab_contents/menu_category_base.h b/chrome/browser/tab_contents/menu_category_base.h
new file mode 100644
index 0000000000000000000000000000000000000000..93959cf5831086fc41fb7978001b5ee21cc4ef9a
--- /dev/null
+++ b/chrome/browser/tab_contents/menu_category_base.h
@@ -0,0 +1,86 @@
+// 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_TAB_CONTENTS_MENU_CATEGORY_BASE_H_
+#define CHROME_BROWSER_TAB_CONTENTS_MENU_CATEGORY_BASE_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;
+}
+
+// MenuCategoryBase 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 MenuCategoryBase {
Fady Samuel 2014/02/24 19:07:29 This class represents a context not category. It t
lazyboy 2014/02/24 23:45:00 I've renamed the class to MenuContext, others to M
+ public:
+ virtual ~MenuCategoryBase();
+
+ // Represents a category of menu item groups.
+ // Order matters as they are appended in the enum order.
+ enum ItemCategory {
+ ITEM_CATEGORY_CUSTOM,
Fady Samuel 2014/02/24 19:07:29 Do the bit shifting here perhaps?
lazyboy 2014/02/24 23:45:00 Obsolte now since we're not using masks anymore.
+ ITEM_CATEGORY_PAGE,
+ ITEM_CATEGORY_FRAME,
+ ITEM_CATEGORY_LINK,
+ ITEM_CATEGORY_MEDIA_IMAGE,
+ ITEM_CATEGORY_SEARCHWEBFORIMAGE,
+ ITEM_CATEGORY_MEDIA_VIDEO,
+ ITEM_CATEGORY_MEDIA_AUDIO,
+ ITEM_CATEGORY_MEDIA_PLUGIN,
+ ITEM_CATEGORY_MEDIA_FILE,
+ ITEM_CATEGORY_EDITABLE,
+ ITEM_CATEGORY_COPY,
+ ITEM_CATEGORY_SEARCH_PROVIDER,
+ ITEM_CATEGORY_PRINT,
+ ITEM_CATEGORY_ALL_EXTENSION,
+ ITEM_CATEGORY_CURRENT_EXTENSION,
+ ITEM_CATEGORY_DEVELOPER,
+ ITEM_CATEGORY_DEVTOOLS_UNPACKED_EXT,
+ ITEM_CATEGORY_PRINT_PREVIEW,
+ ITEM_CATEGORY_LAST = ITEM_CATEGORY_PRINT_PREVIEW
+ };
Fady Samuel 2014/02/24 19:07:29 A helper method here: SupportsCategory(...) might
lazyboy 2014/02/24 23:45:00 Removed bitmask, so this is not required anymore.
+
+ static MenuCategoryBase* Create(
+ content::WebContents* web_contents,
+ content::RenderFrameHost* render_frame_host,
+ const content::ContextMenuParams& params);
+
+ // Returns a bitmask of |ItemCategory|, representing the list of
+ // item categories that are enabled.
+ int GetCategories();
+
+ protected:
+ MenuCategoryBase(content::RenderFrameHost* render_frame_host,
+ const content::ContextMenuParams& params);
+
+ // Returns if |category| is enabled.
+ virtual bool IsCategoryEnabled(int category);
+
+ const extensions::Extension* GetExtension() const;
+
+ content::ContextMenuParams params_;
+ content::WebContents* source_web_contents_;
+ Profile* profile_;
+
+ private:
+ friend class MenuCategoryFactory;
+
+ bool HasCustomItems(const std::vector<content::MenuItem>& items) const;
+
+ DISALLOW_COPY_AND_ASSIGN(MenuCategoryBase);
+};
+
+#endif // CHROME_BROWSER_TAB_CONTENTS_MENU_CATEGORY_BASE_H_

Powered by Google App Engine
This is Rietveld 408576698