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 // Appends items with the extension's icon. | |
37 void AppendExtensionItems(const MenuItem::ExtensionKey& extension_key, | 38 void AppendExtensionItems(const MenuItem::ExtensionKey& extension_key, |
38 const base::string16& selection_text, | 39 const base::string16& selection_text, |
39 int* index); | 40 int* index); |
40 | 41 |
42 // This is a helper function to append items for one particular extension. | |
43 // The |index| parameter is used for assigning id's, and is incremented for | |
44 // each item actually added. | |
45 // Appends items without the extension's icon. | |
46 void AppendExtensionItemsWithoutIcons( | |
Devlin
2014/07/15 17:37:54
I know we did this in the other patch for Extensio
gpdavis
2014/07/15 19:46:07
Done.
| |
47 const MenuItem::ExtensionKey& extension_key, | |
48 const base::string16& selection_text, | |
49 int* index); | |
50 | |
41 void Clear(); | 51 void Clear(); |
42 | 52 |
43 // This function returns the top level context menu title of an extension | 53 // This function returns the top level context menu title of an extension |
44 // based on a printable selection text. | 54 // based on a printable selection text. |
45 base::string16 GetTopLevelContextMenuTitle( | 55 base::string16 GetTopLevelContextMenuTitle( |
46 const MenuItem::ExtensionKey& extension_key, | 56 const MenuItem::ExtensionKey& extension_key, |
47 const base::string16& selection_text); | 57 const base::string16& selection_text); |
48 | 58 |
49 bool IsCommandIdChecked(int command_id) const; | 59 bool IsCommandIdChecked(int command_id) const; |
50 bool IsCommandIdEnabled(int command_id) const; | 60 bool IsCommandIdEnabled(int command_id) const; |
51 void ExecuteCommand(int command_id, | 61 void ExecuteCommand(int command_id, |
52 content::WebContents* web_contents, | 62 content::WebContents* web_contents, |
53 const content::ContextMenuParams& params); | 63 const content::ContextMenuParams& params); |
54 | 64 |
55 private: | 65 private: |
56 friend class ::ExtensionContextMenuBrowserTest; | 66 friend class ::ExtensionContextMenuBrowserTest; |
57 | 67 |
68 // This is a helper function to append items for one particular extension. | |
69 // The |index| parameter is used for assigning id's, and is incremented for | |
70 // each item actually added. |include_icons| is used to determine whether | |
71 // the extension's icon should be included with the items. | |
72 void AppendExtensionItemsImpl(const MenuItem::ExtensionKey& extension_key, | |
73 const base::string16& selection_text, | |
74 int* index, | |
75 bool include_icons); | |
76 | |
58 bool GetRelevantExtensionTopLevelItems( | 77 bool GetRelevantExtensionTopLevelItems( |
59 const MenuItem::ExtensionKey& extension_key, | 78 const MenuItem::ExtensionKey& extension_key, |
60 const Extension** extension, | 79 const Extension** extension, |
61 bool* can_cross_incognito, | 80 bool* can_cross_incognito, |
62 MenuItem::List& items); | 81 MenuItem::List& items); |
63 | 82 |
64 MenuItem::List GetRelevantExtensionItems( | 83 MenuItem::List GetRelevantExtensionItems( |
65 const MenuItem::List& items, | 84 const MenuItem::List& items, |
66 bool can_cross_incognito); | 85 bool can_cross_incognito); |
67 | 86 |
(...skipping 21 matching lines...) Expand all Loading... | |
89 | 108 |
90 // Keep track of and clean up menu models for submenus. | 109 // Keep track of and clean up menu models for submenus. |
91 ScopedVector<ui::SimpleMenuModel> extension_menu_models_; | 110 ScopedVector<ui::SimpleMenuModel> extension_menu_models_; |
92 | 111 |
93 DISALLOW_COPY_AND_ASSIGN(ContextMenuMatcher); | 112 DISALLOW_COPY_AND_ASSIGN(ContextMenuMatcher); |
94 }; | 113 }; |
95 | 114 |
96 } // namespace extensions | 115 } // namespace extensions |
97 | 116 |
98 #endif // CHROME_BROWSER_EXTENSIONS_CONTEXT_MENU_MATCHER_H_ | 117 #endif // CHROME_BROWSER_EXTENSIONS_CONTEXT_MENU_MATCHER_H_ |
OLD | NEW |