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

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

Issue 9382037: Move ContextMenuParams struct from webkit/glue to content/public/common. The reasons are: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/tab_contents/render_view_context_menu.h" 9 #include "chrome/browser/tab_contents/render_view_context_menu.h"
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "content/browser/download/download_types.h" 63 #include "content/browser/download/download_types.h"
64 #include "content/browser/renderer_host/render_view_host.h" 64 #include "content/browser/renderer_host/render_view_host.h"
65 #include "content/browser/renderer_host/render_widget_host_view.h" 65 #include "content/browser/renderer_host/render_widget_host_view.h"
66 #include "content/browser/speech/speech_input_preferences.h" 66 #include "content/browser/speech/speech_input_preferences.h"
67 #include "content/browser/ssl/ssl_manager.h" 67 #include "content/browser/ssl/ssl_manager.h"
68 #include "content/public/browser/child_process_security_policy.h" 68 #include "content/public/browser/child_process_security_policy.h"
69 #include "content/public/browser/download_manager.h" 69 #include "content/public/browser/download_manager.h"
70 #include "content/public/browser/navigation_details.h" 70 #include "content/public/browser/navigation_details.h"
71 #include "content/public/browser/navigation_entry.h" 71 #include "content/public/browser/navigation_entry.h"
72 #include "content/public/browser/notification_service.h" 72 #include "content/public/browser/notification_service.h"
73 #include "content/public/browser/ssl_status.h"
74 #include "content/public/browser/user_metrics.h" 73 #include "content/public/browser/user_metrics.h"
75 #include "content/public/browser/web_contents.h" 74 #include "content/public/browser/web_contents.h"
76 #include "content/public/common/content_restriction.h" 75 #include "content/public/common/content_restriction.h"
76 #include "content/public/common/ssl_status.h"
77 #include "grit/generated_resources.h" 77 #include "grit/generated_resources.h"
78 #include "net/base/escape.h" 78 #include "net/base/escape.h"
79 #include "net/base/net_util.h" 79 #include "net/base/net_util.h"
80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" 81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h"
82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" 82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h"
83 #include "ui/base/l10n/l10n_util.h" 83 #include "ui/base/l10n/l10n_util.h"
84 #include "ui/base/text/text_elider.h" 84 #include "ui/base/text/text_elider.h"
85 #include "ui/gfx/favicon_size.h" 85 #include "ui/gfx/favicon_size.h"
86 #include "webkit/glue/webmenuitem.h" 86 #include "webkit/glue/webmenuitem.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) { 232 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) {
233 if (!url.SchemeIs(chrome::kChromeUIScheme)) 233 if (!url.SchemeIs(chrome::kChromeUIScheme))
234 return false; 234 return false;
235 return url.host() == chrome::kChromeUISyncResourcesHost; 235 return url.host() == chrome::kChromeUISyncResourcesHost;
236 } 236 }
237 237
238 static const int kSpellcheckRadioGroup = 1; 238 static const int kSpellcheckRadioGroup = 1;
239 239
240 RenderViewContextMenu::RenderViewContextMenu( 240 RenderViewContextMenu::RenderViewContextMenu(
241 WebContents* web_contents, 241 WebContents* web_contents,
242 const ContextMenuParams& params) 242 const content::ContextMenuParams& params)
243 : params_(params), 243 : params_(params),
244 source_web_contents_(web_contents), 244 source_web_contents_(web_contents),
245 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 245 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
246 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)), 246 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)),
247 external_(false), 247 external_(false),
248 ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)), 248 ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)),
249 ALLOW_THIS_IN_INITIALIZER_LIST(bidi_submenu_model_(this)), 249 ALLOW_THIS_IN_INITIALIZER_LIST(bidi_submenu_model_(this)),
250 ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)), 250 ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)),
251 protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) { 251 protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) {
252 } 252 }
(...skipping 11 matching lines...) Expand all
264 static bool ExtensionPatternMatch(const URLPatternSet& patterns, 264 static bool ExtensionPatternMatch(const URLPatternSet& patterns,
265 const GURL& url) { 265 const GURL& url) {
266 // No patterns means no restriction, so that implicitly matches. 266 // No patterns means no restriction, so that implicitly matches.
267 if (patterns.is_empty()) 267 if (patterns.is_empty())
268 return true; 268 return true;
269 return patterns.MatchesURL(url); 269 return patterns.MatchesURL(url);
270 } 270 }
271 271
272 // static 272 // static
273 bool RenderViewContextMenu::ExtensionContextAndPatternMatch( 273 bool RenderViewContextMenu::ExtensionContextAndPatternMatch(
274 const ContextMenuParams& params, 274 const content::ContextMenuParams& params,
275 ExtensionMenuItem::ContextList contexts, 275 ExtensionMenuItem::ContextList contexts,
276 const URLPatternSet& target_url_patterns) { 276 const URLPatternSet& target_url_patterns) {
277 bool has_link = !params.link_url.is_empty(); 277 bool has_link = !params.link_url.is_empty();
278 bool has_selection = !params.selection_text.empty(); 278 bool has_selection = !params.selection_text.empty();
279 bool in_frame = !params.frame_url.is_empty(); 279 bool in_frame = !params.frame_url.is_empty();
280 280
281 if (contexts.Contains(ExtensionMenuItem::ALL) || 281 if (contexts.Contains(ExtensionMenuItem::ALL) ||
282 (has_selection && contexts.Contains(ExtensionMenuItem::SELECTION)) || 282 (has_selection && contexts.Contains(ExtensionMenuItem::SELECTION)) ||
283 (params.is_editable && contexts.Contains(ExtensionMenuItem::EDITABLE)) || 283 (params.is_editable && contexts.Contains(ExtensionMenuItem::EDITABLE)) ||
284 (in_frame && contexts.Contains(ExtensionMenuItem::FRAME))) 284 (in_frame && contexts.Contains(ExtensionMenuItem::FRAME)))
(...skipping 30 matching lines...) Expand all
315 // other contexts apply (except for FRAME, which is included in PAGE for 315 // other contexts apply (except for FRAME, which is included in PAGE for
316 // backwards compatibility). 316 // backwards compatibility).
317 if (!has_link && !has_selection && !params.is_editable && 317 if (!has_link && !has_selection && !params.is_editable &&
318 params.media_type == WebContextMenuData::MediaTypeNone && 318 params.media_type == WebContextMenuData::MediaTypeNone &&
319 contexts.Contains(ExtensionMenuItem::PAGE)) 319 contexts.Contains(ExtensionMenuItem::PAGE))
320 return true; 320 return true;
321 321
322 return false; 322 return false;
323 } 323 }
324 324
325 static const GURL& GetDocumentURL(const ContextMenuParams& params) { 325 static const GURL& GetDocumentURL(const content::ContextMenuParams& params) {
326 return params.frame_url.is_empty() ? params.page_url : params.frame_url; 326 return params.frame_url.is_empty() ? params.page_url : params.frame_url;
327 } 327 }
328 328
329 // Given a list of items, returns the ones that match given the contents 329 // Given a list of items, returns the ones that match given the contents
330 // of |params| and the profile. 330 // of |params| and the profile.
331 // static 331 // static
332 ExtensionMenuItem::List RenderViewContextMenu::GetRelevantExtensionItems( 332 ExtensionMenuItem::List RenderViewContextMenu::GetRelevantExtensionItems(
333 const ExtensionMenuItem::List& items, 333 const ExtensionMenuItem::List& items,
334 const ContextMenuParams& params, 334 const content::ContextMenuParams& params,
335 Profile* profile, 335 Profile* profile,
336 bool can_cross_incognito) { 336 bool can_cross_incognito) {
337 ExtensionMenuItem::List result; 337 ExtensionMenuItem::List result;
338 for (ExtensionMenuItem::List::const_iterator i = items.begin(); 338 for (ExtensionMenuItem::List::const_iterator i = items.begin();
339 i != items.end(); ++i) { 339 i != items.end(); ++i) {
340 const ExtensionMenuItem* item = *i; 340 const ExtensionMenuItem* item = *i;
341 341
342 if (!ExtensionContextAndPatternMatch(params, item->contexts(), 342 if (!ExtensionContextAndPatternMatch(params, item->contexts(),
343 item->target_url_patterns())) 343 item->target_url_patterns()))
344 continue; 344 continue;
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 case IDC_CONTENT_CONTEXT_RELOADFRAME: 1715 case IDC_CONTENT_CONTEXT_RELOADFRAME:
1716 rvh->ReloadFrame(); 1716 rvh->ReloadFrame();
1717 break; 1717 break;
1718 1718
1719 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: 1719 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE:
1720 source_web_contents_->ViewFrameSource(params_.frame_url, 1720 source_web_contents_->ViewFrameSource(params_.frame_url,
1721 params_.frame_content_state); 1721 params_.frame_content_state);
1722 break; 1722 break;
1723 1723
1724 case IDC_CONTENT_CONTEXT_VIEWFRAMEINFO: { 1724 case IDC_CONTENT_CONTEXT_VIEWFRAMEINFO: {
1725 // Deserialize the SSL info. 1725 source_web_contents_->ShowPageInfo(params_.frame_url,
1726 SSLStatus ssl; 1726 params_.security_info,
1727 if (!params_.security_info.empty()) {
1728 int cert_id;
1729 net::CertStatus cert_status;
1730 int security_bits;
1731 int connection_status;
1732 SSLManager::DeserializeSecurityInfo(params_.security_info,
1733 &cert_id,
1734 &cert_status,
1735 &security_bits,
1736 &connection_status);
1737 ssl.cert_id = cert_id;
1738 ssl.cert_status = cert_status;
1739 ssl.security_bits = security_bits;
1740 ssl.connection_status = connection_status;
1741 }
1742 source_web_contents_->ShowPageInfo(params_.frame_url, ssl,
1743 false); // Don't show the history. 1727 false); // Don't show the history.
1744 break; 1728 break;
1745 } 1729 }
1746 1730
1747 case IDC_CONTENT_CONTEXT_UNDO: 1731 case IDC_CONTENT_CONTEXT_UNDO:
1748 rvh->Undo(); 1732 rvh->Undo();
1749 break; 1733 break;
1750 1734
1751 case IDC_CONTENT_CONTEXT_REDO: 1735 case IDC_CONTENT_CONTEXT_REDO:
1752 rvh->Redo(); 1736 rvh->Redo();
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 source_web_contents_->GetRenderViewHost()-> 1986 source_web_contents_->GetRenderViewHost()->
2003 ExecuteMediaPlayerActionAtLocation(location, action); 1987 ExecuteMediaPlayerActionAtLocation(location, action);
2004 } 1988 }
2005 1989
2006 void RenderViewContextMenu::PluginActionAt( 1990 void RenderViewContextMenu::PluginActionAt(
2007 const gfx::Point& location, 1991 const gfx::Point& location,
2008 const WebPluginAction& action) { 1992 const WebPluginAction& action) {
2009 source_web_contents_->GetRenderViewHost()-> 1993 source_web_contents_->GetRenderViewHost()->
2010 ExecutePluginActionAtLocation(location, action); 1994 ExecutePluginActionAtLocation(location, action);
2011 } 1995 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698