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

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu.h

Issue 1042003: Initial version of an experimental Extensions Context Menu API.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ 6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_
7 7
8 #include <map>
9 #include <string>
10 #include <vector>
11
8 #include "base/string16.h" 12 #include "base/string16.h"
9 #include "chrome/common/page_transition_types.h" 13 #include "chrome/common/page_transition_types.h"
10 #include "webkit/glue/context_menu.h" 14 #include "webkit/glue/context_menu.h"
11 #include "webkit/glue/window_open_disposition.h" 15 #include "webkit/glue/window_open_disposition.h"
12 16
17 class ExtensionMenuItem;
13 class Profile; 18 class Profile;
14 class TabContents; 19 class TabContents;
15 20
16 namespace gfx { 21 namespace gfx {
17 class Point; 22 class Point;
18 } 23 }
19 24
20 namespace WebKit { 25 namespace WebKit {
21 struct WebMediaPlayerAction; 26 struct WebMediaPlayerAction;
22 } 27 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 void AppendLinkItems(); 87 void AppendLinkItems();
83 void AppendImageItems(); 88 void AppendImageItems();
84 void AppendAudioItems(); 89 void AppendAudioItems();
85 void AppendVideoItems(); 90 void AppendVideoItems();
86 void AppendMediaItems(); 91 void AppendMediaItems();
87 void AppendPageItems(); 92 void AppendPageItems();
88 void AppendFrameItems(); 93 void AppendFrameItems();
89 void AppendCopyItem(); 94 void AppendCopyItem();
90 void AppendEditableItems(); 95 void AppendEditableItems();
91 void AppendSearchProvider(); 96 void AppendSearchProvider();
97 void AppendAllExtensionItems();
98
99 // When extensions have more than 1 top-level item or a single parent item
100 // with children, we will start a sub menu. In the case of 1 parent with
101 // children, we will remove the parent from |items| and insert the children
102 // into it. The |index| parameter is incremented if we start a submenu. This
103 // returns true if a submenu was started. If we had multiple top-level items
104 // that needed to be pushed into a submenu, we'll use |extension_name| as the
105 // title.
106 bool MaybeStartExtensionSubMenu(const string16& selection_text,
107 const std::string& extension_name,
108 std::vector<const ExtensionMenuItem*>* items,
109 int* index);
110
111 // Fills in |items| with matching items for extension with |extension_id|.
112 void GetItemsForExtension(const std::string& extension_id,
113 std::vector<const ExtensionMenuItem*>* items);
114
115 // This is a helper function to append items for one particular extension.
116 // The |index| parameter is used for assigning id's, and is incremented for
117 // each item actually added.
118 void AppendExtensionItems(const std::string& extension_id, int* index);
92 119
93 // Opens the specified URL string in a new tab. If |in_current_window| is 120 // Opens the specified URL string in a new tab. If |in_current_window| is
94 // false, a new window is created to hold the new tab. 121 // false, a new window is created to hold the new tab.
95 void OpenURL(const GURL& url, 122 void OpenURL(const GURL& url,
96 WindowOpenDisposition disposition, 123 WindowOpenDisposition disposition,
97 PageTransition::Type transition); 124 PageTransition::Type transition);
98 125
99 // Copy to the clipboard an image located at a point in the RenderView 126 // Copy to the clipboard an image located at a point in the RenderView
100 void CopyImageAt(int x, int y); 127 void CopyImageAt(int x, int y);
101 128
102 // Launch the inspector targeting a point in the RenderView 129 // Launch the inspector targeting a point in the RenderView
103 void Inspect(int x, int y); 130 void Inspect(int x, int y);
104 131
105 // Writes the specified text/url to the system clipboard 132 // Writes the specified text/url to the system clipboard
106 void WriteURLToClipboard(const GURL& url); 133 void WriteURLToClipboard(const GURL& url);
107 134
108 void MediaPlayerActionAt(const gfx::Point& location, 135 void MediaPlayerActionAt(const gfx::Point& location,
109 const WebKit::WebMediaPlayerAction& action); 136 const WebKit::WebMediaPlayerAction& action);
110 137
111 bool IsDevCommandEnabled(int id) const; 138 bool IsDevCommandEnabled(int id) const;
112 139
140 // Returns a (possibly truncated) version of the current selection text
141 // suitable or putting in the title of a menu item.
142 string16 PrintableSelectionText();
143
144 // Attempts to get an ExtensionMenuItem given the id of a context menu item.
145 ExtensionMenuItem* GetExtensionMenuItem(int id) const;
146
113 // The destination URL to use if the user tries to search for or navigate to 147 // The destination URL to use if the user tries to search for or navigate to
114 // a text selection. 148 // a text selection.
115 GURL selection_navigation_url_; 149 GURL selection_navigation_url_;
116 150
151 // Maps the id from a context menu item to the ExtensionMenuItem's internal
152 // id.
153 std::map<int, int> extension_item_map_;
154
117 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu); 155 DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenu);
118 }; 156 };
119 157
120 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_ 158 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698