Chromium Code Reviews| 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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_.has_image_contents; |
| 1090 return true; | |
| 1091 | |
| 1092 return params_.src_url.is_valid() && | |
| 1093 ProfileIOData::IsHandledProtocol(params_.src_url.scheme()); | |
| 1094 } | 1090 } |
| 1095 | 1091 |
| 1096 // The images shown in the most visited thumbnails can't be opened or | 1092 // The images shown in the most visited thumbnails can't be opened or |
| 1097 // searched for conventionally. | 1093 // searched for conventionally. |
| 1098 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: | 1094 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: |
| 1099 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: | 1095 case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: |
| 1100 return params_.src_url.is_valid() && | 1096 return params_.src_url.is_valid() && |
| 1101 (params_.src_url.scheme() != content::kChromeUIScheme); | 1097 (params_.src_url.scheme() != content::kChromeUIScheme); |
| 1102 | 1098 |
| 1103 case IDC_CONTENT_CONTEXT_COPYIMAGE: | 1099 case IDC_CONTENT_CONTEXT_COPYIMAGE: |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1338 dl_params->set_referrer(referrer); | 1334 dl_params->set_referrer(referrer); |
| 1339 dl_params->set_referrer_encoding(params_.frame_charset); | 1335 dl_params->set_referrer_encoding(params_.frame_charset); |
| 1340 dl_params->set_suggested_name(params_.suggested_filename); | 1336 dl_params->set_suggested_name(params_.suggested_filename); |
| 1341 dl_params->set_prompt(true); | 1337 dl_params->set_prompt(true); |
| 1342 dlm->DownloadUrl(dl_params.Pass()); | 1338 dlm->DownloadUrl(dl_params.Pass()); |
| 1343 break; | 1339 break; |
| 1344 } | 1340 } |
| 1345 | 1341 |
| 1346 case IDC_CONTENT_CONTEXT_SAVEAVAS: | 1342 case IDC_CONTENT_CONTEXT_SAVEAVAS: |
| 1347 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { | 1343 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { |
| 1348 if (params_.media_type == WebContextMenuData::MediaTypeCanvas) { | 1344 bool is_large_data_url = params_.has_image_contents && |
| 1345 params_.src_url.is_empty(); | |
| 1346 if (params_.media_type == WebContextMenuData::MediaTypeCanvas || | |
| 1347 (params_.media_type == WebContextMenuData::MediaTypeImage && | |
| 1348 is_large_data_url)) { | |
|
Ken Russell (switch to Gerrit)
2014/09/11 00:38:53
nit: fix indentation.
zino
2014/09/12 09:38:27
Done.
| |
| 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 Loading... | |
| 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 } |
| OLD | NEW |