Index: chrome/browser/renderer_context_menu/render_view_context_menu.cc |
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc |
index 0fb672f10eccc55dca97fa6e50b02d63dafd3065..ec511dbaa28b51ad1fa48233ff7d4dbf2b699fb5 100644 |
--- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc |
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc |
@@ -630,6 +630,11 @@ void RenderViewContextMenu::InitMenu() { |
} |
if (content_type_->SupportsGroup( |
+ ContextMenuContentType::ITEM_GROUP_MEDIA_CANVAS)) { |
+ AppendCanvasItems(); |
+ } |
+ |
+ if (content_type_->SupportsGroup( |
ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { |
AppendPluginItems(); |
} |
@@ -843,6 +848,13 @@ void RenderViewContextMenu::AppendAudioItems() { |
IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB); |
} |
+void RenderViewContextMenu::AppendCanvasItems() { |
+ menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, |
+ IDS_CONTENT_CONTEXT_SAVEIMAGEAS); |
+ |
+ // 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
|
+} |
+ |
void RenderViewContextMenu::AppendVideoItems() { |
AppendMediaItems(); |
menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
@@ -1225,6 +1237,9 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { |
if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
return false; |
+ if (params_.media_type == WebContextMenuData::MediaTypeCanvas) |
+ return true; |
+ |
return params_.src_url.is_valid() && |
ProfileIOData::IsHandledProtocol(params_.src_url.scheme()); |
} |
@@ -1537,12 +1552,18 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { |
case IDC_CONTENT_CONTEXT_SAVEAVAS: |
case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { |
- RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); |
- const GURL& referrer = |
- params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; |
- const GURL& url = params_.src_url; |
- source_web_contents_->SaveFrame(url, content::Referrer( |
- referrer, params_.referrer_policy)); |
+ if (params_.media_type == WebContextMenuData::MediaTypeCanvas) { |
+ source_web_contents_->GetRenderViewHost()->SaveImageAt( |
+ params_.x, params_.y); |
+ } else { |
+ // 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
|
+ RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); |
+ const GURL& referrer = |
+ params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; |
+ const GURL& url = params_.src_url; |
+ source_web_contents_->SaveFrame(url, content::Referrer( |
+ referrer, params_.referrer_policy)); |
+ } |
break; |
} |