diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-03 15:50:07 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-03 15:50:07 +0000 |
commit | 66171abedad9f817901db48328fdc417ecf56c7a (patch) | |
tree | 59ebd2a67731072f9326f08fa3fcce32cc1c5866 /chrome/browser/ui/views | |
parent | 7aebaf878d8ec781f8fcc5f2932d67a9f6afb966 (diff) | |
download | chromium_src-66171abedad9f817901db48328fdc417ecf56c7a.zip chromium_src-66171abedad9f817901db48328fdc417ecf56c7a.tar.gz chromium_src-66171abedad9f817901db48328fdc417ecf56c7a.tar.bz2 |
Convert IconLoader and IconManager to deal with gfx::Image rather than SkBitmap.
This allows loading of icons in the platform format, avoiding unnecessary
conversions if the image is going to be used with the platform toolkit. In other
cases, this just pushes image conversion to the callsite rather than the actual
image load.
BUG=19685
TEST=unit_tests and visual inspection of icons in the download shelf
Review URL: http://codereview.chromium.org/6597043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views')
-rw-r--r-- | chrome/browser/ui/views/download_item_view.cc | 18 | ||||
-rw-r--r-- | chrome/browser/ui/views/download_item_view.h | 8 |
2 files changed, 18 insertions, 8 deletions
diff --git a/chrome/browser/ui/views/download_item_view.cc b/chrome/browser/ui/views/download_item_view.cc index b6098de..1783b16 100644 --- a/chrome/browser/ui/views/download_item_view.cc +++ b/chrome/browser/ui/views/download_item_view.cc @@ -26,6 +26,7 @@ #include "ui/base/text/text_elider.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/color_utils.h" +#include "ui/gfx/image.h" #include "views/controls/button/native_button.h" #include "views/controls/menu/menu_2.h" #include "views/widget/root_view.h" @@ -652,10 +653,15 @@ void DownloadItemView::OnPaint(gfx::Canvas* canvas) { mirrored_x, y, kTextWidth, font_.GetHeight()); } - // Paint the icon. + // Load the icon. IconManager* im = g_browser_process->icon_manager(); - SkBitmap* icon = IsDangerousMode() ? warning_icon_ : - im->LookupIcon(download_->GetUserVerifiedFilePath(), IconLoader::SMALL); + gfx::Image* image = im->LookupIcon(download_->GetUserVerifiedFilePath(), + IconLoader::SMALL); + const SkBitmap* icon = NULL; + if (IsDangerousMode()) + icon = warning_icon_; + else if (image) + icon = *image; // We count on the fact that the icon manager will cache the icons and if one // is available, it will be cached here. We *don't* want to request the icon @@ -868,8 +874,8 @@ bool DownloadItemView::OnMouseDragged(const views::MouseEvent& event) { if (dragging_) { if (download_->state() == DownloadItem::COMPLETE) { IconManager* im = g_browser_process->icon_manager(); - SkBitmap* icon = im->LookupIcon(download_->GetUserVerifiedFilePath(), - IconLoader::SMALL); + gfx::Image* icon = im->LookupIcon(download_->GetUserVerifiedFilePath(), + IconLoader::SMALL); if (icon) { views::Widget* widget = GetWidget(); download_util::DragDownload(download_, icon, @@ -971,7 +977,7 @@ void DownloadItemView::OpenDownload() { } void DownloadItemView::OnExtractIconComplete(IconManager::Handle handle, - SkBitmap* icon_bitmap) { + gfx::Image* icon_bitmap) { if (icon_bitmap) parent()->SchedulePaint(); } diff --git a/chrome/browser/ui/views/download_item_view.h b/chrome/browser/ui/views/download_item_view.h index a2357c9..e8f427a 100644 --- a/chrome/browser/ui/views/download_item_view.h +++ b/chrome/browser/ui/views/download_item_view.h @@ -38,6 +38,10 @@ class DownloadShelfView; class SkBitmap; class DownloadShelfContextMenuWin; +namespace gfx { +class Image; +} + namespace ui { class SlideAnimation; } @@ -88,7 +92,7 @@ class DownloadItemView : public views::ButtonListener, void StopDownloadProgress(); // IconManager::Client interface. - void OnExtractIconComplete(IconManager::Handle handle, SkBitmap* icon_bitmap); + void OnExtractIconComplete(IconManager::Handle handle, gfx::Image* icon); // Returns the DownloadItem model object belonging to this item. DownloadItem* download() const { return download_; } @@ -179,7 +183,7 @@ class DownloadItemView : public views::ButtonListener, DropDownImageSet pushed_drop_down_image_set_; // The warning icon showns for dangerous downloads. - SkBitmap* warning_icon_; + const SkBitmap* warning_icon_; // The model we query for display information DownloadItem* download_; |