| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 #if defined(ENABLE_PRINTING) | 116 #if defined(ENABLE_PRINTING) |
| 117 #include "chrome/browser/printing/print_view_manager_common.h" | 117 #include "chrome/browser/printing/print_view_manager_common.h" |
| 118 #include "components/printing/common/print_messages.h" | 118 #include "components/printing/common/print_messages.h" |
| 119 | 119 |
| 120 #if defined(ENABLE_PRINT_PREVIEW) | 120 #if defined(ENABLE_PRINT_PREVIEW) |
| 121 #include "chrome/browser/printing/print_preview_context_menu_observer.h" | 121 #include "chrome/browser/printing/print_preview_context_menu_observer.h" |
| 122 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 122 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 123 #endif // defined(ENABLE_PRINT_PREVIEW) | 123 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 124 #endif // defined(ENABLE_PRINTING) | 124 #endif // defined(ENABLE_PRINTING) |
| 125 | 125 |
| 126 #if defined(ENABLE_MEDIA_ROUTER) |
| 127 #include "chrome/browser/media/router/media_router_feature.h" |
| 128 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 129 |
| 126 using base::UserMetricsAction; | 130 using base::UserMetricsAction; |
| 127 using blink::WebContextMenuData; | 131 using blink::WebContextMenuData; |
| 128 using blink::WebMediaPlayerAction; | 132 using blink::WebMediaPlayerAction; |
| 129 using blink::WebPluginAction; | 133 using blink::WebPluginAction; |
| 130 using blink::WebString; | 134 using blink::WebString; |
| 131 using blink::WebURL; | 135 using blink::WebURL; |
| 132 using content::BrowserContext; | 136 using content::BrowserContext; |
| 133 using content::ChildProcessSecurityPolicy; | 137 using content::ChildProcessSecurityPolicy; |
| 134 using content::DownloadManager; | 138 using content::DownloadManager; |
| 135 using content::DownloadUrlParameters; | 139 using content::DownloadUrlParameters; |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 | 951 |
| 948 void RenderViewContextMenu::AppendPrintItem() { | 952 void RenderViewContextMenu::AppendPrintItem() { |
| 949 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && | 953 if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && |
| 950 (params_.media_type == WebContextMenuData::MediaTypeNone || | 954 (params_.media_type == WebContextMenuData::MediaTypeNone || |
| 951 params_.media_flags & WebContextMenuData::MediaCanPrint)) { | 955 params_.media_flags & WebContextMenuData::MediaCanPrint)) { |
| 952 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); | 956 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); |
| 953 } | 957 } |
| 954 } | 958 } |
| 955 | 959 |
| 956 void RenderViewContextMenu::AppendMediaRouterItem() { | 960 void RenderViewContextMenu::AppendMediaRouterItem() { |
| 957 if (switches::MediaRouterEnabled() && !browser_context_->IsOffTheRecord()) | 961 #if defined(ENABLE_MEDIA_ROUTER) |
| 962 if (media_router::MediaRouterEnabled() && |
| 963 !browser_context_->IsOffTheRecord()) { |
| 958 menu_model_.AddItemWithStringId(IDC_ROUTE_MEDIA, | 964 menu_model_.AddItemWithStringId(IDC_ROUTE_MEDIA, |
| 959 IDS_MEDIA_ROUTER_MENU_ITEM_TITLE); | 965 IDS_MEDIA_ROUTER_MENU_ITEM_TITLE); |
| 966 } |
| 967 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 960 } | 968 } |
| 961 | 969 |
| 962 void RenderViewContextMenu::AppendRotationItems() { | 970 void RenderViewContextMenu::AppendRotationItems() { |
| 963 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { | 971 if (params_.media_flags & WebContextMenuData::MediaCanRotate) { |
| 964 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 972 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| 965 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, | 973 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, |
| 966 IDS_CONTENT_CONTEXT_ROTATECW); | 974 IDS_CONTENT_CONTEXT_ROTATECW); |
| 967 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, | 975 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, |
| 968 IDS_CONTENT_CONTEXT_ROTATECCW); | 976 IDS_CONTENT_CONTEXT_ROTATECCW); |
| 969 } | 977 } |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 return true; | 1416 return true; |
| 1409 #endif | 1417 #endif |
| 1410 | 1418 |
| 1411 case IDC_SPELLCHECK_MENU: | 1419 case IDC_SPELLCHECK_MENU: |
| 1412 case IDC_CONTENT_CONTEXT_OPENLINKWITH: | 1420 case IDC_CONTENT_CONTEXT_OPENLINKWITH: |
| 1413 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: | 1421 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: |
| 1414 case IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD: | 1422 case IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD: |
| 1415 return true; | 1423 return true; |
| 1416 | 1424 |
| 1417 case IDC_ROUTE_MEDIA: { | 1425 case IDC_ROUTE_MEDIA: { |
| 1418 DCHECK(switches::MediaRouterEnabled()); | 1426 #if defined(ENABLE_MEDIA_ROUTER) |
| 1427 DCHECK(media_router::MediaRouterEnabled()); |
| 1419 | 1428 |
| 1420 // Disable the command if there is an active modal dialog. | 1429 // Disable the command if there is an active modal dialog. |
| 1421 Browser* browser = | 1430 Browser* browser = |
| 1422 chrome::FindBrowserWithWebContents(source_web_contents_); | 1431 chrome::FindBrowserWithWebContents(source_web_contents_); |
| 1423 if (!browser || browser->profile()->IsOffTheRecord()) | 1432 if (!browser || browser->profile()->IsOffTheRecord()) |
| 1424 return false; | 1433 return false; |
| 1425 | 1434 |
| 1426 WebContents* web_contents = | 1435 WebContents* web_contents = |
| 1427 browser->tab_strip_model()->GetActiveWebContents(); | 1436 browser->tab_strip_model()->GetActiveWebContents(); |
| 1428 if (!web_contents) | 1437 if (!web_contents) |
| 1429 return false; | 1438 return false; |
| 1430 | 1439 |
| 1431 const web_modal::WebContentsModalDialogManager* manager = | 1440 const web_modal::WebContentsModalDialogManager* manager = |
| 1432 web_modal::WebContentsModalDialogManager::FromWebContents( | 1441 web_modal::WebContentsModalDialogManager::FromWebContents( |
| 1433 web_contents); | 1442 web_contents); |
| 1434 return !manager || !manager->IsDialogActive(); | 1443 return !manager || !manager->IsDialogActive(); |
| 1444 #else |
| 1445 NOTREACHED(); |
| 1446 return false; |
| 1447 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 1435 } | 1448 } |
| 1436 | 1449 |
| 1437 default: | 1450 default: |
| 1438 NOTREACHED(); | 1451 NOTREACHED(); |
| 1439 return false; | 1452 return false; |
| 1440 } | 1453 } |
| 1441 } | 1454 } |
| 1442 | 1455 |
| 1443 bool RenderViewContextMenu::IsCommandIdChecked(int id) const { | 1456 bool RenderViewContextMenu::IsCommandIdChecked(int id) const { |
| 1444 if (RenderViewContextMenuBase::IsCommandIdChecked(id)) | 1457 if (RenderViewContextMenuBase::IsCommandIdChecked(id)) |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 | 1719 |
| 1707 printing::StartPrint( | 1720 printing::StartPrint( |
| 1708 source_web_contents_, | 1721 source_web_contents_, |
| 1709 GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled), | 1722 GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled), |
| 1710 !params_.selection_text.empty()); | 1723 !params_.selection_text.empty()); |
| 1711 #endif // ENABLE_PRINTING | 1724 #endif // ENABLE_PRINTING |
| 1712 break; | 1725 break; |
| 1713 } | 1726 } |
| 1714 | 1727 |
| 1715 case IDC_ROUTE_MEDIA: { | 1728 case IDC_ROUTE_MEDIA: { |
| 1716 DCHECK(switches::MediaRouterEnabled()); | 1729 #if defined(ENABLE_MEDIA_ROUTER) |
| 1730 DCHECK(media_router::MediaRouterEnabled()); |
| 1717 | 1731 |
| 1718 Browser* browser = | 1732 Browser* browser = |
| 1719 chrome::FindBrowserWithWebContents(source_web_contents_); | 1733 chrome::FindBrowserWithWebContents(source_web_contents_); |
| 1720 DCHECK(browser && !browser->profile()->IsOffTheRecord()); | 1734 DCHECK(browser && !browser->profile()->IsOffTheRecord()); |
| 1721 | 1735 |
| 1722 media_router::MediaRouterDialogController* dialog_controller = | 1736 media_router::MediaRouterDialogController* dialog_controller = |
| 1723 media_router::MediaRouterDialogController::GetOrCreateForWebContents( | 1737 media_router::MediaRouterDialogController::GetOrCreateForWebContents( |
| 1724 source_web_contents_); | 1738 source_web_contents_); |
| 1725 | 1739 |
| 1726 if (!dialog_controller) | 1740 if (!dialog_controller) |
| 1727 return; | 1741 return; |
| 1728 | 1742 |
| 1729 dialog_controller->ShowMediaRouterDialog(); | 1743 dialog_controller->ShowMediaRouterDialog(); |
| 1744 #else |
| 1745 NOTREACHED(); |
| 1746 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 1730 break; | 1747 break; |
| 1731 } | 1748 } |
| 1732 | 1749 |
| 1733 case IDC_VIEW_SOURCE: | 1750 case IDC_VIEW_SOURCE: |
| 1734 embedder_web_contents_->ViewSource(); | 1751 embedder_web_contents_->ViewSource(); |
| 1735 break; | 1752 break; |
| 1736 | 1753 |
| 1737 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: | 1754 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
| 1738 Inspect(params_.x, params_.y); | 1755 Inspect(params_.x, params_.y); |
| 1739 break; | 1756 break; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 source_web_contents_->GetRenderViewHost()-> | 2012 source_web_contents_->GetRenderViewHost()-> |
| 1996 ExecuteMediaPlayerActionAtLocation(location, action); | 2013 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1997 } | 2014 } |
| 1998 | 2015 |
| 1999 void RenderViewContextMenu::PluginActionAt( | 2016 void RenderViewContextMenu::PluginActionAt( |
| 2000 const gfx::Point& location, | 2017 const gfx::Point& location, |
| 2001 const WebPluginAction& action) { | 2018 const WebPluginAction& action) { |
| 2002 source_web_contents_->GetRenderViewHost()-> | 2019 source_web_contents_->GetRenderViewHost()-> |
| 2003 ExecutePluginActionAtLocation(location, action); | 2020 ExecutePluginActionAtLocation(location, action); |
| 2004 } | 2021 } |
| OLD | NEW |