| 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 b47c48a5ad1b79496a762c6f8f09a1efdb2f4952..3aaccd800d1467c1c59bb6c833a11ca78836d7d6 100644
|
| --- a/chrome/browser/extensions/api/downloads/downloads_api.cc
|
| +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
|
| @@ -64,11 +64,10 @@
|
| #include "content/public/browser/notification_source.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/render_view_host.h"
|
| +#include "content/public/browser/render_widget_host_view.h"
|
| #include "content/public/browser/resource_context.h"
|
| #include "content/public/browser/resource_dispatcher_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| -#include "content/public/browser/web_contents.h"
|
| -#include "content/public/browser/web_contents_view.h"
|
| #include "content/public/browser/web_contents_view.h"
|
| #include "extensions/browser/event_router.h"
|
| #include "extensions/common/extension.h"
|
| @@ -79,6 +78,7 @@
|
| #include "net/url_request/url_request.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| #include "ui/base/webui/web_ui_util.h"
|
| +#include "ui/gfx/image/image_skia.h"
|
|
|
| using content::BrowserContext;
|
| using content::BrowserThread;
|
| @@ -301,19 +301,23 @@ class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor {
|
| virtual ~DownloadFileIconExtractorImpl() {}
|
|
|
| virtual bool ExtractIconURLForPath(const base::FilePath& path,
|
| + float scale,
|
| IconLoader::IconSize icon_size,
|
| IconURLCallback callback) OVERRIDE;
|
| private:
|
| void OnIconLoadComplete(gfx::Image* icon);
|
|
|
| CancelableTaskTracker cancelable_task_tracker_;
|
| + float scale_;
|
| IconURLCallback callback_;
|
| };
|
|
|
| bool DownloadFileIconExtractorImpl::ExtractIconURLForPath(
|
| const base::FilePath& path,
|
| + float scale,
|
| IconLoader::IconSize icon_size,
|
| IconURLCallback callback) {
|
| + scale_ = scale;
|
| callback_ = callback;
|
| IconManager* im = g_browser_process->icon_manager();
|
| // The contents of the file at |path| may have changed since a previous
|
| @@ -329,10 +333,8 @@ bool DownloadFileIconExtractorImpl::ExtractIconURLForPath(
|
|
|
| void DownloadFileIconExtractorImpl::OnIconLoadComplete(gfx::Image* icon) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - std::string url;
|
| - if (icon)
|
| - url = webui::GetBitmapDataUrl(icon->AsBitmap());
|
| - callback_.Run(url);
|
| + callback_.Run(!icon ? std::string() : webui::GetBitmapDataUrl(
|
| + icon->ToImageSkia()->GetRepresentation(scale_).sk_bitmap()));
|
| }
|
|
|
| IconLoader::IconSize IconLoaderSizeFromPixelSize(int pixel_size) {
|
| @@ -1498,8 +1500,16 @@ bool DownloadsGetFileIconFunction::RunImpl() {
|
| // found, so use GetTargetFilePath() instead.
|
| DCHECK(icon_extractor_.get());
|
| DCHECK(icon_size == 16 || icon_size == 32);
|
| + float scale = 1.0;
|
| + content::WebContents* web_contents =
|
| + dispatcher()->delegate()->GetVisibleWebContents();
|
| + if (web_contents) {
|
| + scale = ui::GetImageScale(ui::GetScaleFactorForNativeView(
|
| + web_contents->GetRenderWidgetHostView()->GetNativeView()));
|
| + }
|
| EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath(
|
| download_item->GetTargetFilePath(),
|
| + scale,
|
| IconLoaderSizeFromPixelSize(icon_size),
|
| base::Bind(&DownloadsGetFileIconFunction::OnIconURLExtracted, this)));
|
| return true;
|
|
|