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 return false; | |
msw
2015/10/23 20:18:42
nit: add NOTREACHED(); in this block?
imcheng
2015/10/23 21:39:26
Done.
| |
1446 #endif // defined(ENABLE_MEDIA_ROUTER) | |
1435 } | 1447 } |
1436 | 1448 |
1437 default: | 1449 default: |
1438 NOTREACHED(); | 1450 NOTREACHED(); |
1439 return false; | 1451 return false; |
1440 } | 1452 } |
1441 } | 1453 } |
1442 | 1454 |
1443 bool RenderViewContextMenu::IsCommandIdChecked(int id) const { | 1455 bool RenderViewContextMenu::IsCommandIdChecked(int id) const { |
1444 if (RenderViewContextMenuBase::IsCommandIdChecked(id)) | 1456 if (RenderViewContextMenuBase::IsCommandIdChecked(id)) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1706 | 1718 |
1707 printing::StartPrint( | 1719 printing::StartPrint( |
1708 source_web_contents_, | 1720 source_web_contents_, |
1709 GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled), | 1721 GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled), |
1710 !params_.selection_text.empty()); | 1722 !params_.selection_text.empty()); |
1711 #endif // ENABLE_PRINTING | 1723 #endif // ENABLE_PRINTING |
1712 break; | 1724 break; |
1713 } | 1725 } |
1714 | 1726 |
1715 case IDC_ROUTE_MEDIA: { | 1727 case IDC_ROUTE_MEDIA: { |
1716 DCHECK(switches::MediaRouterEnabled()); | 1728 #if defined(ENABLE_MEDIA_ROUTER) |
1729 DCHECK(media_router::MediaRouterEnabled()); | |
1717 | 1730 |
1718 Browser* browser = | 1731 Browser* browser = |
1719 chrome::FindBrowserWithWebContents(source_web_contents_); | 1732 chrome::FindBrowserWithWebContents(source_web_contents_); |
1720 DCHECK(browser && !browser->profile()->IsOffTheRecord()); | 1733 DCHECK(browser && !browser->profile()->IsOffTheRecord()); |
1721 | 1734 |
1722 media_router::MediaRouterDialogController* dialog_controller = | 1735 media_router::MediaRouterDialogController* dialog_controller = |
1723 media_router::MediaRouterDialogController::GetOrCreateForWebContents( | 1736 media_router::MediaRouterDialogController::GetOrCreateForWebContents( |
1724 source_web_contents_); | 1737 source_web_contents_); |
1725 | 1738 |
1726 if (!dialog_controller) | 1739 if (!dialog_controller) |
1727 return; | 1740 return; |
1728 | 1741 |
1729 dialog_controller->ShowMediaRouterDialog(); | 1742 dialog_controller->ShowMediaRouterDialog(); |
1743 #endif // defined(ENABLE_MEDIA_ROUTER) | |
msw
2015/10/23 20:18:43
nit: add an else block with NOTREACHED();?
imcheng
2015/10/23 21:39:26
Done.
| |
1730 break; | 1744 break; |
1731 } | 1745 } |
1732 | 1746 |
1733 case IDC_VIEW_SOURCE: | 1747 case IDC_VIEW_SOURCE: |
1734 embedder_web_contents_->ViewSource(); | 1748 embedder_web_contents_->ViewSource(); |
1735 break; | 1749 break; |
1736 | 1750 |
1737 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: | 1751 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
1738 Inspect(params_.x, params_.y); | 1752 Inspect(params_.x, params_.y); |
1739 break; | 1753 break; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1995 source_web_contents_->GetRenderViewHost()-> | 2009 source_web_contents_->GetRenderViewHost()-> |
1996 ExecuteMediaPlayerActionAtLocation(location, action); | 2010 ExecuteMediaPlayerActionAtLocation(location, action); |
1997 } | 2011 } |
1998 | 2012 |
1999 void RenderViewContextMenu::PluginActionAt( | 2013 void RenderViewContextMenu::PluginActionAt( |
2000 const gfx::Point& location, | 2014 const gfx::Point& location, |
2001 const WebPluginAction& action) { | 2015 const WebPluginAction& action) { |
2002 source_web_contents_->GetRenderViewHost()-> | 2016 source_web_contents_->GetRenderViewHost()-> |
2003 ExecutePluginActionAtLocation(location, action); | 2017 ExecutePluginActionAtLocation(location, action); |
2004 } | 2018 } |
OLD | NEW |