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

Unified Diff: chrome/browser/download/download_commands.cc

Issue 2219953004: Refactor download image-MIME-type-detection code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add more tests Created 4 years, 4 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
« no previous file with comments | « chrome/browser/chromeos/note_taking_app_utils.cc ('k') | chrome/browser/download/download_item_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_commands.cc
diff --git a/chrome/browser/download/download_commands.cc b/chrome/browser/download/download_commands.cc
index 0f2417e1a7b7e17e8d1468b54b442cfba6853114..eb2ca17f41fc95f65bae1c66bb1afb81a30e522c 100644
--- a/chrome/browser/download/download_commands.cc
+++ b/chrome/browser/download/download_commands.cc
@@ -27,7 +27,6 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/google/core/browser/google_util.h"
-#include "components/mime_util/mime_util.h"
#include "grit/theme_resources.h"
#include "net/base/url_util.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
@@ -383,23 +382,11 @@ bool DownloadCommands::CanOpenPdfInSystemViewer() const {
void DownloadCommands::CopyFileAsImageToClipboard() const {
if (download_item_->GetState() != content::DownloadItem::COMPLETE ||
download_item_->GetReceivedBytes() > kMaxImageClipboardSize) {
- return;
+ return;
}
- // TODO(yoshiki): Refine the code by combining the common logic with the
- // preview in DownloadItemNotification.
- std::string mime = download_item_->GetMimeType();
- if (!mime_util::IsSupportedImageMimeType(mime)) {
- base::FilePath::StringType extension_with_dot =
- download_item_->GetTargetFilePath().FinalExtension();
- if (extension_with_dot.empty() ||
- !net::GetWellKnownMimeTypeFromExtension(extension_with_dot.substr(1),
- &mime) ||
- !mime_util::IsSupportedImageMimeType(mime)) {
- // It seems a non-image file.
- return;
- }
- }
+ if (!DownloadItemModel(download_item_).HasSupportedImageMimeType())
+ return;
base::FilePath file_path = download_item_->GetFullPath();
ImageClipboardCopyManager::Start(file_path);
« no previous file with comments | « chrome/browser/chromeos/note_taking_app_utils.cc ('k') | chrome/browser/download/download_item_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698