OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_CONTEXT_MENU_MATCHER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CONTEXT_MENU_MATCHER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_CONTEXT_MENU_MATCHER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CONTEXT_MENU_MATCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // The |filter| will be called on possibly matching menu items, and its | 27 // The |filter| will be called on possibly matching menu items, and its |
28 // result is used to determine which items to actually append to the menu. | 28 // result is used to determine which items to actually append to the menu. |
29 ContextMenuMatcher(Profile* profile, | 29 ContextMenuMatcher(Profile* profile, |
30 ui::SimpleMenuModel::Delegate* delegate, | 30 ui::SimpleMenuModel::Delegate* delegate, |
31 ui::SimpleMenuModel* menu_model, | 31 ui::SimpleMenuModel* menu_model, |
32 const base::Callback<bool(const MenuItem*)>& filter); | 32 const base::Callback<bool(const MenuItem*)>& filter); |
33 | 33 |
34 // This is a helper function to append items for one particular extension. | 34 // This is a helper function to append items for one particular extension. |
35 // The |index| parameter is used for assigning id's, and is incremented for | 35 // The |index| parameter is used for assigning id's, and is incremented for |
36 // each item actually added. | 36 // each item actually added. |
37 void AppendExtensionItems(const std::string& extension_id, | 37 void AppendExtensionItems(const MenuItem::ExtensionKey& extension_key, |
38 const base::string16& selection_text, | 38 const base::string16& selection_text, |
39 int* index); | 39 int* index); |
40 | 40 |
41 void Clear(); | 41 void Clear(); |
42 | 42 |
43 // This function returns the top level context menu title of an extension | 43 // This function returns the top level context menu title of an extension |
44 // based on a printable selection text. | 44 // based on a printable selection text. |
45 base::string16 GetTopLevelContextMenuTitle( | 45 base::string16 GetTopLevelContextMenuTitle( |
46 const std::string& extension_id, | 46 const MenuItem::ExtensionKey& extension_key, |
47 const base::string16& selection_text); | 47 const base::string16& selection_text); |
48 | 48 |
49 bool IsCommandIdChecked(int command_id) const; | 49 bool IsCommandIdChecked(int command_id) const; |
50 bool IsCommandIdEnabled(int command_id) const; | 50 bool IsCommandIdEnabled(int command_id) const; |
51 void ExecuteCommand(int command_id, | 51 void ExecuteCommand(int command_id, |
52 content::WebContents* web_contents, | 52 content::WebContents* web_contents, |
53 const content::ContextMenuParams& params); | 53 const content::ContextMenuParams& params); |
54 | 54 |
55 private: | 55 private: |
56 friend class ::ExtensionContextMenuBrowserTest; | 56 friend class ::ExtensionContextMenuBrowserTest; |
57 | 57 |
58 bool GetRelevantExtensionTopLevelItems( | 58 bool GetRelevantExtensionTopLevelItems( |
59 const std::string& extension_id, | 59 const MenuItem::ExtensionKey& extension_key, |
60 const Extension** extension, | 60 const Extension** extension, |
61 bool* can_cross_incognito, | 61 bool* can_cross_incognito, |
62 MenuItem::List& items); | 62 MenuItem::List& items); |
63 | 63 |
64 MenuItem::List GetRelevantExtensionItems( | 64 MenuItem::List GetRelevantExtensionItems( |
65 const MenuItem::List& items, | 65 const MenuItem::List& items, |
66 bool can_cross_incognito); | 66 bool can_cross_incognito); |
67 | 67 |
68 // Used for recursively adding submenus of extension items. | 68 // Used for recursively adding submenus of extension items. |
69 void RecursivelyAppendExtensionItems(const MenuItem::List& items, | 69 void RecursivelyAppendExtensionItems(const MenuItem::List& items, |
(...skipping 19 matching lines...) Expand all Loading... |
89 | 89 |
90 // Keep track of and clean up menu models for submenus. | 90 // Keep track of and clean up menu models for submenus. |
91 ScopedVector<ui::SimpleMenuModel> extension_menu_models_; | 91 ScopedVector<ui::SimpleMenuModel> extension_menu_models_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(ContextMenuMatcher); | 93 DISALLOW_COPY_AND_ASSIGN(ContextMenuMatcher); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace extensions | 96 } // namespace extensions |
97 | 97 |
98 #endif // CHROME_BROWSER_EXTENSIONS_CONTEXT_MENU_MATCHER_H_ | 98 #endif // CHROME_BROWSER_EXTENSIONS_CONTEXT_MENU_MATCHER_H_ |
OLD | NEW |