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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
623 ContextMenuContentType::ITEM_GROUP_MEDIA_VIDEO)) { | 623 ContextMenuContentType::ITEM_GROUP_MEDIA_VIDEO)) { |
624 AppendVideoItems(); | 624 AppendVideoItems(); |
625 } | 625 } |
626 | 626 |
627 if (content_type_->SupportsGroup( | 627 if (content_type_->SupportsGroup( |
628 ContextMenuContentType::ITEM_GROUP_MEDIA_AUDIO)) { | 628 ContextMenuContentType::ITEM_GROUP_MEDIA_AUDIO)) { |
629 AppendAudioItems(); | 629 AppendAudioItems(); |
630 } | 630 } |
631 | 631 |
632 if (content_type_->SupportsGroup( | 632 if (content_type_->SupportsGroup( |
633 ContextMenuContentType::ITEM_GROUP_MEDIA_CANVAS)) { | |
634 AppendCanvasItems(); | |
635 } | |
636 | |
637 if (content_type_->SupportsGroup( | |
633 ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { | 638 ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { |
634 AppendPluginItems(); | 639 AppendPluginItems(); |
635 } | 640 } |
636 | 641 |
637 // ITEM_GROUP_MEDIA_FILE has no specific items. | 642 // ITEM_GROUP_MEDIA_FILE has no specific items. |
638 | 643 |
639 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_EDITABLE)) | 644 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_EDITABLE)) |
640 AppendEditableItems(); | 645 AppendEditableItems(); |
641 | 646 |
642 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_COPY)) { | 647 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_COPY)) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 AppendMediaItems(); | 841 AppendMediaItems(); |
837 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 842 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
838 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, | 843 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, |
839 IDS_CONTENT_CONTEXT_SAVEAUDIOAS); | 844 IDS_CONTENT_CONTEXT_SAVEAUDIOAS); |
840 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, | 845 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, |
841 IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION); | 846 IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION); |
842 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, | 847 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, |
843 IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB); | 848 IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB); |
844 } | 849 } |
845 | 850 |
851 void RenderViewContextMenu::AppendCanvasItems() { | |
852 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, | |
853 IDS_CONTENT_CONTEXT_SAVEIMAGEAS); | |
854 | |
855 // FIXME: We should support 'copy image' for canvas. | |
Avi (use Gerrit)
2014/04/30 14:52:28
Chromium style is:
// TODO(zino): We should suppo
Justin Novosad
2014/04/30 15:07:16
You should also file a bug for this so we don't fo
| |
856 } | |
857 | |
846 void RenderViewContextMenu::AppendVideoItems() { | 858 void RenderViewContextMenu::AppendVideoItems() { |
847 AppendMediaItems(); | 859 AppendMediaItems(); |
848 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 860 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
849 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, | 861 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, |
850 IDS_CONTENT_CONTEXT_SAVEVIDEOAS); | 862 IDS_CONTENT_CONTEXT_SAVEVIDEOAS); |
851 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, | 863 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, |
852 IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION); | 864 IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION); |
853 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, | 865 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, |
854 IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB); | 866 IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB); |
855 } | 867 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1218 ProfileIOData::IsHandledProtocol(params_.link_url.scheme()); | 1230 ProfileIOData::IsHandledProtocol(params_.link_url.scheme()); |
1219 } | 1231 } |
1220 | 1232 |
1221 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { | 1233 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { |
1222 PrefService* local_state = g_browser_process->local_state(); | 1234 PrefService* local_state = g_browser_process->local_state(); |
1223 DCHECK(local_state); | 1235 DCHECK(local_state); |
1224 // Test if file-selection dialogs are forbidden by policy. | 1236 // Test if file-selection dialogs are forbidden by policy. |
1225 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1237 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
1226 return false; | 1238 return false; |
1227 | 1239 |
1240 if (params_.media_type == WebContextMenuData::MediaTypeCanvas) | |
1241 return true; | |
1242 | |
1228 return params_.src_url.is_valid() && | 1243 return params_.src_url.is_valid() && |
1229 ProfileIOData::IsHandledProtocol(params_.src_url.scheme()); | 1244 ProfileIOData::IsHandledProtocol(params_.src_url.scheme()); |
1230 } | 1245 } |
1231 | 1246 |
1232 // The images shown in the most visited thumbnails can't be opened or | 1247 // The images shown in the most visited thumbnails can't be opened or |
1233 // searched for conventionally. | 1248 // searched for conventionally. |
1234 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: | 1249 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: |
1235 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: | 1250 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: |
1236 return params_.src_url.is_valid() && | 1251 return params_.src_url.is_valid() && |
1237 (params_.src_url.scheme() != content::kChromeUIScheme); | 1252 (params_.src_url.scheme() != content::kChromeUIScheme); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1530 dl_params->set_referrer( | 1545 dl_params->set_referrer( |
1531 content::Referrer(referrer, params_.referrer_policy)); | 1546 content::Referrer(referrer, params_.referrer_policy)); |
1532 dl_params->set_referrer_encoding(params_.frame_charset); | 1547 dl_params->set_referrer_encoding(params_.frame_charset); |
1533 dl_params->set_prompt(true); | 1548 dl_params->set_prompt(true); |
1534 dlm->DownloadUrl(dl_params.Pass()); | 1549 dlm->DownloadUrl(dl_params.Pass()); |
1535 break; | 1550 break; |
1536 } | 1551 } |
1537 | 1552 |
1538 case IDC_CONTENT_CONTEXT_SAVEAVAS: | 1553 case IDC_CONTENT_CONTEXT_SAVEAVAS: |
1539 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { | 1554 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { |
1540 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); | 1555 if (params_.media_type == WebContextMenuData::MediaTypeCanvas) { |
1541 const GURL& referrer = | 1556 source_web_contents_->GetRenderViewHost()->SaveImageAt( |
1542 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; | 1557 params_.x, params_.y); |
1543 const GURL& url = params_.src_url; | 1558 } else { |
1544 source_web_contents_->SaveFrame(url, content::Referrer( | 1559 // FIXME: We can use SaveImageAt() like a case of canvas. |
Avi (use Gerrit)
2014/04/30 14:52:28
TODO again. And I do look forward to your fix to m
| |
1545 referrer, params_.referrer_policy)); | 1560 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); |
1561 const GURL& referrer = | |
1562 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; | |
1563 const GURL& url = params_.src_url; | |
1564 source_web_contents_->SaveFrame(url, content::Referrer( | |
1565 referrer, params_.referrer_policy)); | |
1566 } | |
1546 break; | 1567 break; |
1547 } | 1568 } |
1548 | 1569 |
1549 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: | 1570 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: |
1550 WriteURLToClipboard(params_.unfiltered_link_url); | 1571 WriteURLToClipboard(params_.unfiltered_link_url); |
1551 break; | 1572 break; |
1552 | 1573 |
1553 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: | 1574 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: |
1554 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: | 1575 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: |
1555 WriteURLToClipboard(params_.src_url); | 1576 WriteURLToClipboard(params_.src_url); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2021 source_web_contents_->GetRenderViewHost()-> | 2042 source_web_contents_->GetRenderViewHost()-> |
2022 ExecuteMediaPlayerActionAtLocation(location, action); | 2043 ExecuteMediaPlayerActionAtLocation(location, action); |
2023 } | 2044 } |
2024 | 2045 |
2025 void RenderViewContextMenu::PluginActionAt( | 2046 void RenderViewContextMenu::PluginActionAt( |
2026 const gfx::Point& location, | 2047 const gfx::Point& location, |
2027 const WebPluginAction& action) { | 2048 const WebPluginAction& action) { |
2028 source_web_contents_->GetRenderViewHost()-> | 2049 source_web_contents_->GetRenderViewHost()-> |
2029 ExecutePluginActionAtLocation(location, action); | 2050 ExecutePluginActionAtLocation(location, action); |
2030 } | 2051 } |
OLD | NEW |