| 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 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 23 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
| 26 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 26 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 27 #include "chrome/browser/devtools/devtools_window.h" | 27 #include "chrome/browser/devtools/devtools_window.h" |
| 28 #include "chrome/browser/download/download_service.h" | 28 #include "chrome/browser/download/download_service.h" |
| 29 #include "chrome/browser/download/download_service_factory.h" | 29 #include "chrome/browser/download/download_service_factory.h" |
| 30 #include "chrome/browser/download/download_stats.h" | 30 #include "chrome/browser/download/download_stats.h" |
| 31 #include "chrome/browser/extensions/devtools_util.h" | 31 #include "chrome/browser/extensions/devtools_util.h" |
| 32 #include "chrome/browser/extensions/extension_service.h" | 32 #include "chrome/browser/extensions/extension_service.h" |
| 33 #include "chrome/browser/media/router/media_router_dialog_controller.h" | 33 #include "chrome/browser/media/router/media_router_feature.h" |
| 34 #include "chrome/browser/media/router/media_router_metrics.h" | |
| 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 36 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
| 37 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 36 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 38 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 37 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 39 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 38 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 40 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
| 41 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 40 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 42 #include "chrome/browser/profiles/profile_info_cache.h" | 41 #include "chrome/browser/profiles/profile_info_cache.h" |
| 43 #include "chrome/browser/profiles/profile_io_data.h" | 42 #include "chrome/browser/profiles/profile_io_data.h" |
| 44 #include "chrome/browser/profiles/profile_manager.h" | 43 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 #if defined(ENABLE_PRINT_PREVIEW) | 127 #if defined(ENABLE_PRINT_PREVIEW) |
| 129 #include "chrome/browser/printing/print_preview_context_menu_observer.h" | 128 #include "chrome/browser/printing/print_preview_context_menu_observer.h" |
| 130 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 129 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 131 #endif // defined(ENABLE_PRINT_PREVIEW) | 130 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 132 #endif // defined(ENABLE_PRINTING) | 131 #endif // defined(ENABLE_PRINTING) |
| 133 | 132 |
| 134 #if defined(OS_CHROMEOS) | 133 #if defined(OS_CHROMEOS) |
| 135 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 134 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 136 #endif | 135 #endif |
| 137 | 136 |
| 137 #if defined(ENABLE_MEDIA_ROUTER) |
| 138 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
| 139 #include "chrome/browser/media/router/media_router_metrics.h" |
| 140 #endif |
| 141 |
| 138 using base::UserMetricsAction; | 142 using base::UserMetricsAction; |
| 139 using blink::WebContextMenuData; | 143 using blink::WebContextMenuData; |
| 140 using blink::WebMediaPlayerAction; | 144 using blink::WebMediaPlayerAction; |
| 141 using blink::WebPluginAction; | 145 using blink::WebPluginAction; |
| 142 using blink::WebString; | 146 using blink::WebString; |
| 143 using blink::WebURL; | 147 using blink::WebURL; |
| 144 using content::BrowserContext; | 148 using content::BrowserContext; |
| 145 using content::ChildProcessSecurityPolicy; | 149 using content::ChildProcessSecurityPolicy; |
| 146 using content::DownloadManager; | 150 using content::DownloadManager; |
| 147 using content::DownloadUrlParameters; | 151 using content::DownloadUrlParameters; |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 | 1064 |
| 1061 void RenderViewContextMenu::AppendPrintItem() { | 1065 void RenderViewContextMenu::AppendPrintItem() { |
| 1062 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && | 1066 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && |
| 1063 (params_.media_type == WebContextMenuData::MediaTypeNone || | 1067 (params_.media_type == WebContextMenuData::MediaTypeNone || |
| 1064 params_.media_flags & WebContextMenuData::MediaCanPrint)) { | 1068 params_.media_flags & WebContextMenuData::MediaCanPrint)) { |
| 1065 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); | 1069 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); |
| 1066 } | 1070 } |
| 1067 } | 1071 } |
| 1068 | 1072 |
| 1069 void RenderViewContextMenu::AppendMediaRouterItem() { | 1073 void RenderViewContextMenu::AppendMediaRouterItem() { |
| 1070 if (switches::MediaRouterEnabled() && !browser_context_->IsOffTheRecord()) | 1074 if (media_router::MediaRouterEnabled() && |
| 1075 !browser_context_->IsOffTheRecord()) { |
| 1071 menu_model_.AddItemWithStringId(IDC_ROUTE_MEDIA, | 1076 menu_model_.AddItemWithStringId(IDC_ROUTE_MEDIA, |
| 1072 IDS_MEDIA_ROUTER_MENU_ITEM_TITLE); | 1077 IDS_MEDIA_ROUTER_MENU_ITEM_TITLE); |
| 1078 } |
| 1073 } | 1079 } |
| 1074 | 1080 |
| 1075 void RenderViewContextMenu::AppendRotationItems() { | 1081 void RenderViewContextMenu::AppendRotationItems() { |
| 1076 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { | 1082 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { |
| 1077 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 1083 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| 1078 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, | 1084 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, |
| 1079 IDS_CONTENT_CONTEXT_ROTATECW); | 1085 IDS_CONTENT_CONTEXT_ROTATECW); |
| 1080 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, | 1086 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, |
| 1081 IDS_CONTENT_CONTEXT_ROTATECCW); | 1087 IDS_CONTENT_CONTEXT_ROTATECCW); |
| 1082 } | 1088 } |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 return true; | 1533 return true; |
| 1528 #endif | 1534 #endif |
| 1529 | 1535 |
| 1530 case IDC_SPELLCHECK_MENU: | 1536 case IDC_SPELLCHECK_MENU: |
| 1531 case IDC_CONTENT_CONTEXT_OPENLINKWITH: | 1537 case IDC_CONTENT_CONTEXT_OPENLINKWITH: |
| 1532 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: | 1538 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: |
| 1533 case IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD: | 1539 case IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD: |
| 1534 return true; | 1540 return true; |
| 1535 | 1541 |
| 1536 case IDC_ROUTE_MEDIA: { | 1542 case IDC_ROUTE_MEDIA: { |
| 1537 DCHECK(switches::MediaRouterEnabled()); | 1543 DCHECK(media_router::MediaRouterEnabled()); |
| 1538 | 1544 |
| 1539 // Disable the command if there is an active modal dialog. | 1545 // Disable the command if there is an active modal dialog. |
| 1540 Browser* browser = | 1546 Browser* browser = |
| 1541 chrome::FindBrowserWithWebContents(source_web_contents_); | 1547 chrome::FindBrowserWithWebContents(source_web_contents_); |
| 1542 if (!browser || browser->profile()->IsOffTheRecord()) | 1548 if (!browser || browser->profile()->IsOffTheRecord()) |
| 1543 return false; | 1549 return false; |
| 1544 | 1550 |
| 1545 WebContents* web_contents = | 1551 WebContents* web_contents = |
| 1546 browser->tab_strip_model()->GetActiveWebContents(); | 1552 browser->tab_strip_model()->GetActiveWebContents(); |
| 1547 if (!web_contents) | 1553 if (!web_contents) |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 | 1851 |
| 1846 printing::StartPrint( | 1852 printing::StartPrint( |
| 1847 source_web_contents_, | 1853 source_web_contents_, |
| 1848 GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled), | 1854 GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled), |
| 1849 !params_.selection_text.empty()); | 1855 !params_.selection_text.empty()); |
| 1850 #endif // ENABLE_PRINTING | 1856 #endif // ENABLE_PRINTING |
| 1851 break; | 1857 break; |
| 1852 } | 1858 } |
| 1853 | 1859 |
| 1854 case IDC_ROUTE_MEDIA: { | 1860 case IDC_ROUTE_MEDIA: { |
| 1855 DCHECK(switches::MediaRouterEnabled()); | 1861 DCHECK(media_router::MediaRouterEnabled()); |
| 1856 | 1862 #if defined(ENABLE_MEDIA_ROUTER) |
| 1857 Browser* browser = | 1863 Browser* browser = |
| 1858 chrome::FindBrowserWithWebContents(source_web_contents_); | 1864 chrome::FindBrowserWithWebContents(source_web_contents_); |
| 1859 DCHECK(browser && !browser->profile()->IsOffTheRecord()); | 1865 DCHECK(browser && !browser->profile()->IsOffTheRecord()); |
| 1860 | 1866 |
| 1861 media_router::MediaRouterDialogController* dialog_controller = | 1867 media_router::MediaRouterDialogController* dialog_controller = |
| 1862 media_router::MediaRouterDialogController::GetOrCreateForWebContents( | 1868 media_router::MediaRouterDialogController::GetOrCreateForWebContents( |
| 1863 source_web_contents_); | 1869 source_web_contents_); |
| 1864 | |
| 1865 if (!dialog_controller) | 1870 if (!dialog_controller) |
| 1866 return; | 1871 return; |
| 1867 | 1872 |
| 1868 dialog_controller->ShowMediaRouterDialog(); | 1873 dialog_controller->ShowMediaRouterDialog(); |
| 1869 | |
| 1870 media_router::MediaRouterMetrics::RecordMediaRouterDialogOrigin( | 1874 media_router::MediaRouterMetrics::RecordMediaRouterDialogOrigin( |
| 1871 media_router::CONTEXTUAL_MENU); | 1875 media_router::CONTEXTUAL_MENU); |
| 1872 | 1876 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 1873 break; | 1877 break; |
| 1874 } | 1878 } |
| 1875 | 1879 |
| 1876 case IDC_VIEW_SOURCE: | 1880 case IDC_VIEW_SOURCE: |
| 1877 embedder_web_contents_->ViewSource(); | 1881 embedder_web_contents_->ViewSource(); |
| 1878 break; | 1882 break; |
| 1879 | 1883 |
| 1880 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: | 1884 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
| 1881 Inspect(params_.x, params_.y); | 1885 Inspect(params_.x, params_.y); |
| 1882 break; | 1886 break; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2134 source_web_contents_->GetRenderViewHost()-> | 2138 source_web_contents_->GetRenderViewHost()-> |
| 2135 ExecuteMediaPlayerActionAtLocation(location, action); | 2139 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2136 } | 2140 } |
| 2137 | 2141 |
| 2138 void RenderViewContextMenu::PluginActionAt( | 2142 void RenderViewContextMenu::PluginActionAt( |
| 2139 const gfx::Point& location, | 2143 const gfx::Point& location, |
| 2140 const WebPluginAction& action) { | 2144 const WebPluginAction& action) { |
| 2141 source_web_contents_->GetRenderViewHost()-> | 2145 source_web_contents_->GetRenderViewHost()-> |
| 2142 ExecutePluginActionAtLocation(location, action); | 2146 ExecutePluginActionAtLocation(location, action); |
| 2143 } | 2147 } |
| OLD | NEW |