OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
31 #include "chrome/browser/devtools/devtools_window.h" | 31 #include "chrome/browser/devtools/devtools_window.h" |
32 #include "chrome/browser/download/download_service.h" | 32 #include "chrome/browser/download/download_service.h" |
33 #include "chrome/browser/download/download_service_factory.h" | 33 #include "chrome/browser/download/download_service_factory.h" |
34 #include "chrome/browser/download/download_stats.h" | 34 #include "chrome/browser/download/download_stats.h" |
35 #include "chrome/browser/extensions/devtools_util.h" | 35 #include "chrome/browser/extensions/devtools_util.h" |
36 #include "chrome/browser/extensions/extension_host.h" | 36 #include "chrome/browser/extensions/extension_host.h" |
37 #include "chrome/browser/extensions/extension_service.h" | 37 #include "chrome/browser/extensions/extension_service.h" |
38 #include "chrome/browser/google/google_util.h" | 38 #include "chrome/browser/google/google_util.h" |
| 39 #include "chrome/browser/guestview/webview/webview_guest.h" |
39 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 40 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
40 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 41 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
41 #include "chrome/browser/profiles/profile.h" | 42 #include "chrome/browser/profiles/profile.h" |
42 #include "chrome/browser/profiles/profile_io_data.h" | 43 #include "chrome/browser/profiles/profile_io_data.h" |
43 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory
.h" | 44 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory
.h" |
44 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h" | 45 #include "chrome/browser/renderer_context_menu/spellchecker_submenu_observer.h" |
45 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" | 46 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" |
46 #include "chrome/browser/search/search.h" | 47 #include "chrome/browser/search/search.h" |
47 #include "chrome/browser/search_engines/search_terms_data.h" | 48 #include "chrome/browser/search_engines/search_terms_data.h" |
48 #include "chrome/browser/search_engines/template_url.h" | 49 #include "chrome/browser/search_engines/template_url.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 RenderViewContextMenu::RenderViewContextMenu( | 403 RenderViewContextMenu::RenderViewContextMenu( |
403 content::RenderFrameHost* render_frame_host, | 404 content::RenderFrameHost* render_frame_host, |
404 const content::ContextMenuParams& params) | 405 const content::ContextMenuParams& params) |
405 : params_(params), | 406 : params_(params), |
406 source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)), | 407 source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)), |
407 render_process_id_(render_frame_host->GetProcess()->GetID()), | 408 render_process_id_(render_frame_host->GetProcess()->GetID()), |
408 render_frame_id_(render_frame_host->GetRoutingID()), | 409 render_frame_id_(render_frame_host->GetRoutingID()), |
409 profile_(Profile::FromBrowserContext( | 410 profile_(Profile::FromBrowserContext( |
410 source_web_contents_->GetBrowserContext())), | 411 source_web_contents_->GetBrowserContext())), |
411 menu_model_(this), | 412 menu_model_(this), |
412 extension_items_(profile_, this, &menu_model_, | 413 extension_items_( |
413 base::Bind(MenuItemMatchesParams, params_)), | 414 profile_, |
| 415 this, |
| 416 &menu_model_, |
| 417 base::Bind(MenuItemMatchesParams, |
| 418 params_, |
| 419 WebViewGuest::GetViewInstanceId(source_web_contents_))), |
414 speech_input_submenu_model_(this), | 420 speech_input_submenu_model_(this), |
415 protocol_handler_submenu_model_(this), | 421 protocol_handler_submenu_model_(this), |
416 protocol_handler_registry_( | 422 protocol_handler_registry_( |
417 ProtocolHandlerRegistryFactory::GetForProfile(profile_)), | 423 ProtocolHandlerRegistryFactory::GetForProfile(profile_)), |
418 command_executed_(false) { | 424 command_executed_(false) { |
419 content_type_.reset(ContextMenuContentTypeFactory::Create( | 425 content_type_.reset(ContextMenuContentTypeFactory::Create( |
420 source_web_contents_, | 426 source_web_contents_, |
421 render_frame_host, params)); | 427 render_frame_host, params)); |
422 } | 428 } |
423 | 429 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 contexts.Contains(MenuItem::PAGE)) | 499 contexts.Contains(MenuItem::PAGE)) |
494 return true; | 500 return true; |
495 | 501 |
496 return false; | 502 return false; |
497 } | 503 } |
498 | 504 |
499 static const GURL& GetDocumentURL(const content::ContextMenuParams& params) { | 505 static const GURL& GetDocumentURL(const content::ContextMenuParams& params) { |
500 return params.frame_url.is_empty() ? params.page_url : params.frame_url; | 506 return params.frame_url.is_empty() ? params.page_url : params.frame_url; |
501 } | 507 } |
502 | 508 |
503 // static | 509 // static. |
504 bool RenderViewContextMenu::MenuItemMatchesParams( | 510 bool RenderViewContextMenu::MenuItemMatchesParams( |
505 const content::ContextMenuParams& params, | 511 const content::ContextMenuParams& params, |
| 512 int webview_instance_id, |
506 const extensions::MenuItem* item) { | 513 const extensions::MenuItem* item) { |
| 514 if (webview_instance_id || item->id().webview_instance_id) { |
| 515 if (webview_instance_id != item->id().webview_instance_id) |
| 516 return false; |
| 517 } |
| 518 |
507 bool match = ExtensionContextAndPatternMatch(params, item->contexts(), | 519 bool match = ExtensionContextAndPatternMatch(params, item->contexts(), |
508 item->target_url_patterns()); | 520 item->target_url_patterns()); |
509 if (!match) | 521 if (!match) |
510 return false; | 522 return false; |
511 | 523 |
512 const GURL& document_url = GetDocumentURL(params); | 524 const GURL& document_url = GetDocumentURL(params); |
513 return ExtensionPatternMatch(item->document_url_patterns(), document_url); | 525 return ExtensionPatternMatch(item->document_url_patterns(), document_url); |
514 } | 526 } |
515 | 527 |
516 void RenderViewContextMenu::AppendAllExtensionItems() { | 528 void RenderViewContextMenu::AppendAllExtensionItems() { |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 source_web_contents_->GetRenderViewHost()-> | 2057 source_web_contents_->GetRenderViewHost()-> |
2046 ExecuteMediaPlayerActionAtLocation(location, action); | 2058 ExecuteMediaPlayerActionAtLocation(location, action); |
2047 } | 2059 } |
2048 | 2060 |
2049 void RenderViewContextMenu::PluginActionAt( | 2061 void RenderViewContextMenu::PluginActionAt( |
2050 const gfx::Point& location, | 2062 const gfx::Point& location, |
2051 const WebPluginAction& action) { | 2063 const WebPluginAction& action) { |
2052 source_web_contents_->GetRenderViewHost()-> | 2064 source_web_contents_->GetRenderViewHost()-> |
2053 ExecutePluginActionAtLocation(location, action); | 2065 ExecutePluginActionAtLocation(location, action); |
2054 } | 2066 } |
OLD | NEW |