Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Unified Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 518693002: Fix a crash when saving a <canvas> or <img> image which is large. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CONTENT_EXPORT Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 2d6a8525dc8db413d538853b7750a0566493380d..3b8d311585124e0049b6ea59cb33164eaa6a70af 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,7 @@ 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());
+ return params_.has_image_contents;
}
// The images shown in the most visited thumbnails can't be opened or
@@ -1345,11 +1341,14 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
case IDC_CONTENT_CONTEXT_SAVEAVAS:
case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
- if (params_.media_type == WebContextMenuData::MediaTypeCanvas) {
+ bool is_large_data_url = params_.has_image_contents &&
+ params_.src_url.is_empty();
+ if (params_.media_type == WebContextMenuData::MediaTypeCanvas ||
+ (params_.media_type == WebContextMenuData::MediaTypeImage &&
+ is_large_data_url)) {
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_);

Powered by Google App Engine
This is Rietveld 408576698