Chromium Code Reviews| 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 b9cd2a9eecedfce55048cba489800e61eb14f447..73441fbd1eb71d7fe7494c4ee833c8a32a569d4d 100644 |
| --- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc |
| +++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc |
| @@ -1086,11 +1086,12 @@ 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()); |
| + // If |params_.src_url| is empty, it might be a large data url. |
|
Avi (use Gerrit)
2014/09/03 15:21:05
The word "might" here makes me uncomfortable. Two
Ken Russell (switch to Gerrit)
2014/09/04 00:23:26
Agree with Avi's comments; if the changes I sugges
zino
2014/09/05 03:47:47
Done. It is better to use has_image_contents inste
|
| + // In that case, we should enable the context menu and use |
| + // RenderViewHost::SaveImageAt() method to save a image. |
| + return params_.src_url.is_empty() || |
| + (params_.src_url.is_valid() && |
| + ProfileIOData::IsHandledProtocol(params_.src_url.scheme())); |
| } |
| // The images shown in the most visited thumbnails can't be opened or |
| @@ -1345,11 +1346,12 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { |
| case IDC_CONTENT_CONTEXT_SAVEAVAS: |
| case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { |
| - if (params_.media_type == WebContextMenuData::MediaTypeCanvas) { |
| + if (params_.media_type == WebContextMenuData::MediaTypeCanvas || |
| + (params_.media_type == WebContextMenuData::MediaTypeImage && |
| + params_.src_url.is_empty())) { |
| source_web_contents_->GetRenderViewHost()->SaveImageAt( |
| params_.x, params_.y); |
| } else { |
| - // TODO(zino): We can use SaveImageAt() like a case of canvas. |
| RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); |
| const GURL& url = params_.src_url; |
| content::Referrer referrer = CreateSaveAsReferrer(url, params_); |