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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 ProfileIOData::IsHandledProtocol(params_.link_url.scheme()); 1079 ProfileIOData::IsHandledProtocol(params_.link_url.scheme());
1080 } 1080 }
1081 1081
1082 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { 1082 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
1083 PrefService* local_state = g_browser_process->local_state(); 1083 PrefService* local_state = g_browser_process->local_state();
1084 DCHECK(local_state); 1084 DCHECK(local_state);
1085 // Test if file-selection dialogs are forbidden by policy. 1085 // Test if file-selection dialogs are forbidden by policy.
1086 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) 1086 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs))
1087 return false; 1087 return false;
1088 1088
1089 if (params_.media_type == WebContextMenuData::MediaTypeCanvas) 1089 return params_.src_url.is_empty() ||
Avi (use Gerrit) 2014/09/02 22:33:12 Can you comment that "is_empty" means canvas? (It
zino 2014/09/03 01:45:58 I added comments. Thank you.
1090 return true; 1090 (params_.src_url.is_valid() &&
1091 1091 ProfileIOData::IsHandledProtocol(params_.src_url.scheme()));
1092 return params_.src_url.is_valid() &&
1093 ProfileIOData::IsHandledProtocol(params_.src_url.scheme());
1094 } 1092 }
1095 1093
1096 // The images shown in the most visited thumbnails can't be opened or 1094 // The images shown in the most visited thumbnails can't be opened or
1097 // searched for conventionally. 1095 // searched for conventionally.
1098 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: 1096 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB:
1099 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: 1097 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE:
1100 return params_.src_url.is_valid() && 1098 return params_.src_url.is_valid() &&
1101 (params_.src_url.scheme() != content::kChromeUIScheme); 1099 (params_.src_url.scheme() != content::kChromeUIScheme);
1102 1100
1103 case IDC_CONTENT_CONTEXT_COPYIMAGE: 1101 case IDC_CONTENT_CONTEXT_COPYIMAGE:
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 dl_params->set_referrer(referrer); 1336 dl_params->set_referrer(referrer);
1339 dl_params->set_referrer_encoding(params_.frame_charset); 1337 dl_params->set_referrer_encoding(params_.frame_charset);
1340 dl_params->set_suggested_name(params_.suggested_filename); 1338 dl_params->set_suggested_name(params_.suggested_filename);
1341 dl_params->set_prompt(true); 1339 dl_params->set_prompt(true);
1342 dlm->DownloadUrl(dl_params.Pass()); 1340 dlm->DownloadUrl(dl_params.Pass());
1343 break; 1341 break;
1344 } 1342 }
1345 1343
1346 case IDC_CONTENT_CONTEXT_SAVEAVAS: 1344 case IDC_CONTENT_CONTEXT_SAVEAVAS:
1347 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { 1345 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
1348 if (params_.media_type == WebContextMenuData::MediaTypeCanvas) { 1346 if (params_.media_type == WebContextMenuData::MediaTypeCanvas ||
1347 (params_.media_type == WebContextMenuData::MediaTypeImage &&
1348 params_.src_url.is_empty())) {
1349 source_web_contents_->GetRenderViewHost()->SaveImageAt( 1349 source_web_contents_->GetRenderViewHost()->SaveImageAt(
1350 params_.x, params_.y); 1350 params_.x, params_.y);
1351 } else { 1351 } else {
1352 // TODO(zino): We can use SaveImageAt() like a case of canvas.
1353 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); 1352 RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU);
1354 const GURL& url = params_.src_url; 1353 const GURL& url = params_.src_url;
1355 content::Referrer referrer = CreateSaveAsReferrer(url, params_); 1354 content::Referrer referrer = CreateSaveAsReferrer(url, params_);
1356 source_web_contents_->SaveFrame(url, referrer); 1355 source_web_contents_->SaveFrame(url, referrer);
1357 } 1356 }
1358 break; 1357 break;
1359 } 1358 }
1360 1359
1361 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1360 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
1362 WriteURLToClipboard(params_.unfiltered_link_url); 1361 WriteURLToClipboard(params_.unfiltered_link_url);
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 source_web_contents_->GetRenderViewHost()-> 1770 source_web_contents_->GetRenderViewHost()->
1772 ExecuteMediaPlayerActionAtLocation(location, action); 1771 ExecuteMediaPlayerActionAtLocation(location, action);
1773 } 1772 }
1774 1773
1775 void RenderViewContextMenu::PluginActionAt( 1774 void RenderViewContextMenu::PluginActionAt(
1776 const gfx::Point& location, 1775 const gfx::Point& location,
1777 const WebPluginAction& action) { 1776 const WebPluginAction& action) {
1778 source_web_contents_->GetRenderViewHost()-> 1777 source_web_contents_->GetRenderViewHost()->
1779 ExecutePluginActionAtLocation(location, action); 1778 ExecutePluginActionAtLocation(location, action);
1780 } 1779 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698