Chromium Code Reviews| 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::FromWebContents(source_web_contents_))), | |
|
Fady Samuel
2014/03/04 01:56:46
What if the webview is deleted while the context m
lazyboy
2014/03/04 16:11:31
I've changed this so we pass in the view_instance_
| |
| 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 const WebViewGuest* guest, | |
| 506 const extensions::MenuItem* item) { | 513 const extensions::MenuItem* item) { |
| 514 int webview_instance_id = guest ? guest->view_instance_id() : 0; | |
| 515 | |
| 516 if (webview_instance_id || item->id().webview_instance_id) { | |
| 517 if (webview_instance_id != item->id().webview_instance_id) | |
| 518 return false; | |
| 519 } | |
| 520 | |
| 507 bool match = ExtensionContextAndPatternMatch(params, item->contexts(), | 521 bool match = ExtensionContextAndPatternMatch(params, item->contexts(), |
| 508 item->target_url_patterns()); | 522 item->target_url_patterns()); |
| 509 if (!match) | 523 if (!match) |
| 510 return false; | 524 return false; |
| 511 | 525 |
| 512 const GURL& document_url = GetDocumentURL(params); | 526 const GURL& document_url = GetDocumentURL(params); |
| 513 return ExtensionPatternMatch(item->document_url_patterns(), document_url); | 527 return ExtensionPatternMatch(item->document_url_patterns(), document_url); |
| 514 } | 528 } |
| 515 | 529 |
| 516 void RenderViewContextMenu::AppendAllExtensionItems() { | 530 void RenderViewContextMenu::AppendAllExtensionItems() { |
| (...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2045 source_web_contents_->GetRenderViewHost()-> | 2059 source_web_contents_->GetRenderViewHost()-> |
| 2046 ExecuteMediaPlayerActionAtLocation(location, action); | 2060 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2047 } | 2061 } |
| 2048 | 2062 |
| 2049 void RenderViewContextMenu::PluginActionAt( | 2063 void RenderViewContextMenu::PluginActionAt( |
| 2050 const gfx::Point& location, | 2064 const gfx::Point& location, |
| 2051 const WebPluginAction& action) { | 2065 const WebPluginAction& action) { |
| 2052 source_web_contents_->GetRenderViewHost()-> | 2066 source_web_contents_->GetRenderViewHost()-> |
| 2053 ExecutePluginActionAtLocation(location, action); | 2067 ExecutePluginActionAtLocation(location, action); |
| 2054 } | 2068 } |
| OLD | NEW |