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

Unified Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r158560 Created 8 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/extensions/api/downloads/downloads_api.cc
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
index f2394a1a2efe6e2a8332ff74a435bd29fe3d9d9f..7b10c9eb7b049cc91f3ca43e5172538f010bea94 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -860,22 +860,18 @@ bool DownloadsGetFileIconFunction::RunImpl() {
DownloadItem* download_item = manager->GetDownload(params->download_id);
if (!download_item && incognito_manager)
download_item = incognito_manager->GetDownload(params->download_id);
- if (!download_item) {
- // The DownloadItem is is added to history when the path is determined. If
- // the download is not in history, then we don't have a path / final
- // filename and no icon.
+ if (!download_item || download_item->GetTargetFilePath().empty()) {
error_ = download_extension_errors::kInvalidOperationError;
return false;
}
// In-progress downloads return the intermediate filename for GetFullPath()
// which doesn't have the final extension. Therefore we won't be able to
// derive a good file icon for it. So we use GetTargetFilePath() instead.
- FilePath path = download_item->GetTargetFilePath();
- DCHECK(!path.empty());
DCHECK(icon_extractor_.get());
DCHECK(icon_size == 16 || icon_size == 32);
EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath(
- path, IconLoaderSizeFromPixelSize(icon_size),
+ download_item->GetTargetFilePath(),
+ IconLoaderSizeFromPixelSize(icon_size),
base::Bind(&DownloadsGetFileIconFunction::OnIconURLExtracted, this)));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698