OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 void RenderViewContextMenu::Init() { | 194 void RenderViewContextMenu::Init() { |
195 InitMenu(); | 195 InitMenu(); |
196 PlatformInit(); | 196 PlatformInit(); |
197 } | 197 } |
198 | 198 |
199 static bool ExtensionContextMatch(const ContextMenuParams& params, | 199 static bool ExtensionContextMatch(const ContextMenuParams& params, |
200 ExtensionMenuItem::ContextList contexts) { | 200 ExtensionMenuItem::ContextList contexts) { |
201 bool has_link = !params.link_url.is_empty(); | 201 bool has_link = !params.link_url.is_empty(); |
202 bool has_selection = !params.selection_text.empty(); | 202 bool has_selection = !params.selection_text.empty(); |
| 203 bool in_frame = !params.frame_url.is_empty(); |
203 | 204 |
204 if (contexts.Contains(ExtensionMenuItem::ALL) || | 205 if (contexts.Contains(ExtensionMenuItem::ALL) || |
205 (has_selection && contexts.Contains(ExtensionMenuItem::SELECTION)) || | 206 (has_selection && contexts.Contains(ExtensionMenuItem::SELECTION)) || |
206 (has_link && contexts.Contains(ExtensionMenuItem::LINK)) || | 207 (has_link && contexts.Contains(ExtensionMenuItem::LINK)) || |
207 (params.is_editable && contexts.Contains(ExtensionMenuItem::EDITABLE))) { | 208 (params.is_editable && contexts.Contains(ExtensionMenuItem::EDITABLE)) || |
| 209 (in_frame && contexts.Contains(ExtensionMenuItem::FRAME))) { |
208 return true; | 210 return true; |
209 } | 211 } |
210 | 212 |
211 switch (params.media_type) { | 213 switch (params.media_type) { |
212 case WebContextMenuData::MediaTypeImage: | 214 case WebContextMenuData::MediaTypeImage: |
213 return contexts.Contains(ExtensionMenuItem::IMAGE); | 215 return contexts.Contains(ExtensionMenuItem::IMAGE); |
214 | 216 |
215 case WebContextMenuData::MediaTypeVideo: | 217 case WebContextMenuData::MediaTypeVideo: |
216 return contexts.Contains(ExtensionMenuItem::VIDEO); | 218 return contexts.Contains(ExtensionMenuItem::VIDEO); |
217 | 219 |
218 case WebContextMenuData::MediaTypeAudio: | 220 case WebContextMenuData::MediaTypeAudio: |
219 return contexts.Contains(ExtensionMenuItem::AUDIO); | 221 return contexts.Contains(ExtensionMenuItem::AUDIO); |
220 | 222 |
221 default: | 223 default: |
222 break; | 224 break; |
223 } | 225 } |
224 | 226 |
225 // PAGE is the least specific context, so we only examine that if none of the | 227 // PAGE is the least specific context, so we only examine that if none of the |
226 // other contexts apply. | 228 // other contexts apply (except for FRAME, which is included in PAGE for |
| 229 // backwards compatibility). |
227 if (!has_link && !has_selection && !params.is_editable && | 230 if (!has_link && !has_selection && !params.is_editable && |
228 params.media_type == WebContextMenuData::MediaTypeNone && | 231 params.media_type == WebContextMenuData::MediaTypeNone && |
229 contexts.Contains(ExtensionMenuItem::PAGE)) | 232 contexts.Contains(ExtensionMenuItem::PAGE)) |
230 return true; | 233 return true; |
231 | 234 |
232 return false; | 235 return false; |
233 } | 236 } |
234 | 237 |
235 static bool ExtensionPatternMatch(const ExtensionExtent& patterns, | 238 static bool ExtensionPatternMatch(const ExtensionExtent& patterns, |
236 const GURL& url) { | 239 const GURL& url) { |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1545 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
1543 g_browser_process->clipboard()); | 1546 g_browser_process->clipboard()); |
1544 } | 1547 } |
1545 | 1548 |
1546 void RenderViewContextMenu::MediaPlayerActionAt( | 1549 void RenderViewContextMenu::MediaPlayerActionAt( |
1547 const gfx::Point& location, | 1550 const gfx::Point& location, |
1548 const WebMediaPlayerAction& action) { | 1551 const WebMediaPlayerAction& action) { |
1549 source_tab_contents_->render_view_host()->MediaPlayerActionAt( | 1552 source_tab_contents_->render_view_host()->MediaPlayerActionAt( |
1550 location, action); | 1553 location, action); |
1551 } | 1554 } |
OLD | NEW |