| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tab_contents/render_view_context_menu.h" | 5 #include "chrome/browser/tab_contents/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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 #include "chrome/common/render_messages.h" | 65 #include "chrome/common/render_messages.h" |
| 66 #include "chrome/common/spellcheck_messages.h" | 66 #include "chrome/common/spellcheck_messages.h" |
| 67 #include "chrome/common/url_constants.h" | 67 #include "chrome/common/url_constants.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/download_save_info.h" | 70 #include "content/public/browser/download_save_info.h" |
| 71 #include "content/public/browser/download_url_parameters.h" | 71 #include "content/public/browser/download_url_parameters.h" |
| 72 #include "content/public/browser/navigation_details.h" | 72 #include "content/public/browser/navigation_details.h" |
| 73 #include "content/public/browser/navigation_entry.h" | 73 #include "content/public/browser/navigation_entry.h" |
| 74 #include "content/public/browser/notification_service.h" | 74 #include "content/public/browser/notification_service.h" |
| 75 #include "content/public/browser/render_frame_host.h" |
| 75 #include "content/public/browser/render_process_host.h" | 76 #include "content/public/browser/render_process_host.h" |
| 76 #include "content/public/browser/render_view_host.h" | 77 #include "content/public/browser/render_view_host.h" |
| 77 #include "content/public/browser/render_widget_host_view.h" | 78 #include "content/public/browser/render_widget_host_view.h" |
| 78 #include "content/public/browser/user_metrics.h" | 79 #include "content/public/browser/user_metrics.h" |
| 79 #include "content/public/browser/web_contents.h" | 80 #include "content/public/browser/web_contents.h" |
| 80 #include "content/public/common/menu_item.h" | 81 #include "content/public/common/menu_item.h" |
| 81 #include "content/public/common/ssl_status.h" | 82 #include "content/public/common/ssl_status.h" |
| 82 #include "content/public/common/url_utils.h" | 83 #include "content/public/common/url_utils.h" |
| 83 #include "extensions/browser/extension_system.h" | 84 #include "extensions/browser/extension_system.h" |
| 84 #include "extensions/browser/view_type_utils.h" | 85 #include "extensions/browser/view_type_utils.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 113 using blink::WebPluginAction; | 114 using blink::WebPluginAction; |
| 114 using blink::WebString; | 115 using blink::WebString; |
| 115 using blink::WebURL; | 116 using blink::WebURL; |
| 116 using content::BrowserContext; | 117 using content::BrowserContext; |
| 117 using content::ChildProcessSecurityPolicy; | 118 using content::ChildProcessSecurityPolicy; |
| 118 using content::DownloadManager; | 119 using content::DownloadManager; |
| 119 using content::DownloadUrlParameters; | 120 using content::DownloadUrlParameters; |
| 120 using content::NavigationController; | 121 using content::NavigationController; |
| 121 using content::NavigationEntry; | 122 using content::NavigationEntry; |
| 122 using content::OpenURLParams; | 123 using content::OpenURLParams; |
| 124 using content::RenderFrameHost; |
| 123 using content::RenderViewHost; | 125 using content::RenderViewHost; |
| 124 using content::SSLStatus; | 126 using content::SSLStatus; |
| 125 using content::WebContents; | 127 using content::WebContents; |
| 126 using extensions::Extension; | 128 using extensions::Extension; |
| 127 using extensions::MenuItem; | 129 using extensions::MenuItem; |
| 128 using extensions::MenuManager; | 130 using extensions::MenuManager; |
| 129 | 131 |
| 130 namespace { | 132 namespace { |
| 131 | 133 |
| 132 const int kImageSearchThumbnailMinSize = 300 * 300; | 134 const int kImageSearchThumbnailMinSize = 300 * 300; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // static | 390 // static |
| 389 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) { | 391 bool RenderViewContextMenu::IsInternalResourcesURL(const GURL& url) { |
| 390 if (!url.SchemeIs(chrome::kChromeUIScheme)) | 392 if (!url.SchemeIs(chrome::kChromeUIScheme)) |
| 391 return false; | 393 return false; |
| 392 return url.host() == chrome::kChromeUISyncResourcesHost; | 394 return url.host() == chrome::kChromeUISyncResourcesHost; |
| 393 } | 395 } |
| 394 | 396 |
| 395 static const int kSpellcheckRadioGroup = 1; | 397 static const int kSpellcheckRadioGroup = 1; |
| 396 | 398 |
| 397 RenderViewContextMenu::RenderViewContextMenu( | 399 RenderViewContextMenu::RenderViewContextMenu( |
| 398 WebContents* web_contents, | 400 content::RenderFrameHost* render_frame_host, |
| 399 const content::ContextMenuParams& params) | 401 const content::ContextMenuParams& params) |
| 400 : params_(params), | 402 : params_(params), |
| 401 source_web_contents_(web_contents), | 403 source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)), |
| 402 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), | 404 render_process_id_(render_frame_host->GetProcess()->GetID()), |
| 405 render_frame_id_(render_frame_host->GetRoutingID()), |
| 406 profile_(Profile::FromBrowserContext( |
| 407 source_web_contents_->GetBrowserContext())), |
| 403 menu_model_(this), | 408 menu_model_(this), |
| 404 extension_items_(profile_, this, &menu_model_, | 409 extension_items_(profile_, this, &menu_model_, |
| 405 base::Bind(MenuItemMatchesParams, params_)), | 410 base::Bind(MenuItemMatchesParams, params_)), |
| 406 speech_input_submenu_model_(this), | 411 speech_input_submenu_model_(this), |
| 407 protocol_handler_submenu_model_(this), | 412 protocol_handler_submenu_model_(this), |
| 408 protocol_handler_registry_( | 413 protocol_handler_registry_( |
| 409 ProtocolHandlerRegistryFactory::GetForProfile(profile_)), | 414 ProtocolHandlerRegistryFactory::GetForProfile(profile_)), |
| 410 command_executed_(false), | 415 command_executed_(false), |
| 411 is_guest_(false) { | 416 is_guest_(false) { |
| 412 RenderViewHost* rvh = source_web_contents_->GetRenderViewHost(); | 417 RenderViewHost* rvh = source_web_contents_->GetRenderViewHost(); |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | 1512 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && |
| 1508 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { | 1513 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { |
| 1509 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; | 1514 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; |
| 1510 const content::CustomContextMenuContext& context = params_.custom_context; | 1515 const content::CustomContextMenuContext& context = params_.custom_context; |
| 1511 #if defined(ENABLE_PLUGINS) | 1516 #if defined(ENABLE_PLUGINS) |
| 1512 if (context.request_id && !context.is_pepper_menu) { | 1517 if (context.request_id && !context.is_pepper_menu) { |
| 1513 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( | 1518 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
| 1514 source_web_contents_, false, std::string()); | 1519 source_web_contents_, false, std::string()); |
| 1515 } | 1520 } |
| 1516 #endif | 1521 #endif |
| 1517 rvh->ExecuteCustomContextMenuCommand(action, context); | 1522 RenderFrameHost* render_frame_host = |
| 1523 RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 1524 if (render_frame_host) |
| 1525 render_frame_host->ExecuteCustomContextMenuCommand(action, context); |
| 1518 return; | 1526 return; |
| 1519 } | 1527 } |
| 1520 | 1528 |
| 1521 // Process extension menu items. | 1529 // Process extension menu items. |
| 1522 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && | 1530 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| 1523 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { | 1531 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { |
| 1524 extension_items_.ExecuteCommand(id, source_web_contents_, params_); | 1532 extension_items_.ExecuteCommand(id, source_web_contents_, params_); |
| 1525 return; | 1533 return; |
| 1526 } | 1534 } |
| 1527 | 1535 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 | 1996 |
| 1989 void RenderViewContextMenu::MenuClosed(ui::SimpleMenuModel* source) { | 1997 void RenderViewContextMenu::MenuClosed(ui::SimpleMenuModel* source) { |
| 1990 // Ignore notifications from submenus. | 1998 // Ignore notifications from submenus. |
| 1991 if (source != &menu_model_) | 1999 if (source != &menu_model_) |
| 1992 return; | 2000 return; |
| 1993 | 2001 |
| 1994 content::RenderWidgetHostView* view = | 2002 content::RenderWidgetHostView* view = |
| 1995 source_web_contents_->GetRenderWidgetHostView(); | 2003 source_web_contents_->GetRenderWidgetHostView(); |
| 1996 if (view) | 2004 if (view) |
| 1997 view->SetShowingContextMenu(false); | 2005 view->SetShowingContextMenu(false); |
| 1998 RenderViewHost* rvh = source_web_contents_->GetRenderViewHost(); | 2006 RenderFrameHost* render_frame_host = |
| 1999 if (rvh) { | 2007 RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 2000 rvh->NotifyContextMenuClosed(params_.custom_context); | 2008 if (render_frame_host) |
| 2001 } | 2009 render_frame_host->NotifyContextMenuClosed(params_.custom_context); |
| 2002 | 2010 |
| 2003 if (!command_executed_) { | 2011 if (!command_executed_) { |
| 2004 FOR_EACH_OBSERVER(RenderViewContextMenuObserver, | 2012 FOR_EACH_OBSERVER(RenderViewContextMenuObserver, |
| 2005 observers_, | 2013 observers_, |
| 2006 OnMenuCancel()); | 2014 OnMenuCancel()); |
| 2007 } | 2015 } |
| 2008 } | 2016 } |
| 2009 | 2017 |
| 2010 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { | 2018 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { |
| 2011 if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT || | 2019 if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT || |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 source_web_contents_->GetRenderViewHost()-> | 2106 source_web_contents_->GetRenderViewHost()-> |
| 2099 ExecuteMediaPlayerActionAtLocation(location, action); | 2107 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2100 } | 2108 } |
| 2101 | 2109 |
| 2102 void RenderViewContextMenu::PluginActionAt( | 2110 void RenderViewContextMenu::PluginActionAt( |
| 2103 const gfx::Point& location, | 2111 const gfx::Point& location, |
| 2104 const WebPluginAction& action) { | 2112 const WebPluginAction& action) { |
| 2105 source_web_contents_->GetRenderViewHost()-> | 2113 source_web_contents_->GetRenderViewHost()-> |
| 2106 ExecutePluginActionAtLocation(location, action); | 2114 ExecutePluginActionAtLocation(location, action); |
| 2107 } | 2115 } |
| OLD | NEW |