summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-20 20:27:59 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-20 20:27:59 +0000
commite8476c99df7b4c6fb544f5891c537bc585d0b2c6 (patch)
tree302143adc01a9bb27fffff0c8d9949c39cba3e64
parentf4f7a6ef4a5c5abccf9982839edfce8c0a7333bf (diff)
downloadchromium_src-e8476c99df7b4c6fb544f5891c537bc585d0b2c6.zip
chromium_src-e8476c99df7b4c6fb544f5891c537bc585d0b2c6.tar.gz
chromium_src-e8476c99df7b4c6fb544f5891c537bc585d0b2c6.tar.bz2
Make search icon in omnibox results hidpi
Review URL: https://chromiumcodereview.appspot.com/10829370 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152379 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_service.cc8
-rw-r--r--chrome/browser/extensions/extension_service.h4
-rw-r--r--chrome/browser/ui/ash/app_list/search_builder.cc3
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm6
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm6
-rw-r--r--chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc4
-rw-r--r--chrome/browser/ui/gtk/gtk_util.cc4
-rw-r--r--chrome/browser/ui/gtk/gtk_util.h2
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc7
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc21
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h11
-rw-r--r--chrome/browser/ui/omnibox/omnibox_popup_model.cc10
-rw-r--r--chrome/browser/ui/omnibox/omnibox_popup_model.h9
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc7
-rw-r--r--chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.cc4
-rw-r--r--chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.h2
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc5
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h2
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_result_view.cc18
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_result_view.h2
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_result_view_model.h8
21 files changed, 67 insertions, 76 deletions
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 51ec084..dfb3530 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2250,14 +2250,14 @@ bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) {
extension->location() == Extension::COMPONENT);
}
-const SkBitmap& ExtensionService::GetOmniboxIcon(
+gfx::Image ExtensionService::GetOmniboxIcon(
const std::string& extension_id) {
- return omnibox_icon_manager_.GetIcon(extension_id);
+ return gfx::Image(omnibox_icon_manager_.GetIcon(extension_id));
}
-const SkBitmap& ExtensionService::GetOmniboxPopupIcon(
+gfx::Image ExtensionService::GetOmniboxPopupIcon(
const std::string& extension_id) {
- return omnibox_popup_icon_manager_.GetIcon(extension_id);
+ return gfx::Image(omnibox_popup_icon_manager_.GetIcon(extension_id));
}
bool ExtensionService::OnExternalExtensionFileFound(
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 71ee1c2..e28cd90 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -382,11 +382,11 @@ class ExtensionService
bool ExtensionBindingsAllowed(const GURL& url);
// Returns the icon to display in the omnibox for the given extension.
- const SkBitmap& GetOmniboxIcon(const std::string& extension_id);
+ gfx::Image GetOmniboxIcon(const std::string& extension_id);
// Returns the icon to display in the omnibox popup window for the given
// extension.
- const SkBitmap& GetOmniboxPopupIcon(const std::string& extension_id);
+ gfx::Image GetOmniboxPopupIcon(const std::string& extension_id);
// Called when the initial extensions load has completed.
virtual void OnLoadedInstalledExtensions();
diff --git a/chrome/browser/ui/ash/app_list/search_builder.cc b/chrome/browser/ui/ash/app_list/search_builder.cc
index f9d9602..0005072 100644
--- a/chrome/browser/ui/ash/app_list/search_builder.cc
+++ b/chrome/browser/ui/ash/app_list/search_builder.cc
@@ -161,7 +161,8 @@ class SearchBuilderResult : public app_list::SearchResult,
return;
}
- SetIcon(profile_->GetExtensionService()->GetOmniboxPopupIcon(extension_id));
+ SetIcon(profile_->GetExtensionService()->GetOmniboxPopupIcon(extension_id).
+ AsImageSkia());
}
Profile* profile_;
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
index 1110aab..ca7c8b5 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
@@ -64,7 +64,6 @@
#include "grit/theme_resources.h"
#include "net/base/net_util.h"
#include "skia/ext/skia_utils_mac.h"
-#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
@@ -545,9 +544,8 @@ NSImage* LocationBarViewMac::GetKeywordImage(const string16& keyword) {
const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile(
profile_)->GetTemplateURLForKeyword(keyword);
if (template_url && template_url->IsExtensionKeyword()) {
- const SkBitmap& bitmap = profile_->GetExtensionService()->
- GetOmniboxIcon(template_url->GetExtensionId());
- return gfx::SkBitmapToNSImage(bitmap);
+ return profile_->GetExtensionService()->GetOmniboxIcon(
+ template_url->GetExtensionId()).AsNSImage();
}
return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH);
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
index 95bc264..3b25366 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
@@ -399,9 +399,9 @@ void OmniboxPopupViewMac::PositionPopup(const CGFloat matrixHeight) {
}
NSImage* OmniboxPopupViewMac::ImageForMatch(const AutocompleteMatch& match) {
- const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(match);
- if (bitmap)
- return gfx::SkBitmapToNSImage(*bitmap);
+ gfx::Image image = model_->GetIconIfExtensionMatch(match);
+ if (!image.IsEmpty())
+ return image.AsNSImage();
const int resource_id = match.starred ?
IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match.type);
diff --git a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
index 5aba774..856d0c7 100644
--- a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
+++ b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
@@ -350,7 +350,7 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
gtk_util::DrawFullImage(
cairo_context,
window_,
- delete_icon,
+ *delete_icon,
x_align_left,
entry_rect.y() + ((kRowHeight - kDeleteIconHeight) / 2));
cairo_restore(cairo_context);
@@ -370,7 +370,7 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
cairo_save(cairo_context);
gtk_util::DrawFullImage(cairo_context,
window_,
- theme_service_->GetImageNamed(icon),
+ *theme_service_->GetImageNamed(icon),
x_align_left,
icon_y);
cairo_restore(cairo_context);
diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc
index 91c7e08..66ba633 100644
--- a/chrome/browser/ui/gtk/gtk_util.cc
+++ b/chrome/browser/ui/gtk/gtk_util.cc
@@ -744,10 +744,10 @@ void DrawThemedToolbarBackground(GtkWidget* widget,
void DrawFullImage(cairo_t* cr,
GtkWidget* widget,
- const gfx::Image* image,
+ const gfx::Image& image,
gint dest_x,
gint dest_y) {
- gfx::CairoCachedSurface* surface = image->ToCairo();
+ gfx::CairoCachedSurface* surface = image.ToCairo();
surface->SetSource(cr, widget, dest_x, dest_y);
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
cairo_rectangle(cr, dest_x, dest_y, surface->Width(), surface->Height());
diff --git a/chrome/browser/ui/gtk/gtk_util.h b/chrome/browser/ui/gtk/gtk_util.h
index 9b5f4a5..90f4f5c 100644
--- a/chrome/browser/ui/gtk/gtk_util.h
+++ b/chrome/browser/ui/gtk/gtk_util.h
@@ -207,7 +207,7 @@ void DrawThemedToolbarBackground(GtkWidget* widget,
// Draw an entire pixbuf without dithering.
void DrawFullImage(cairo_t* cr,
GtkWidget* widget,
- const gfx::Image* image,
+ const gfx::Image& image,
gint dest_x,
gint dest_y);
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 554d6ff..bc9d5595 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -1322,11 +1322,10 @@ void LocationBarViewGtk::SetKeywordLabel(const string16& keyword) {
if (is_extension_keyword) {
const TemplateURL* template_url =
template_url_service->GetTemplateURLForKeyword(keyword);
- const SkBitmap& bitmap = profile->GetExtensionService()->
+ gfx::Image image = profile->GetExtensionService()->
GetOmniboxIcon(template_url->GetExtensionId());
- GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap);
- gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf);
- g_object_unref(pixbuf);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_),
+ image.ToGdkPixbuf());
} else {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_),
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
index 0693f67..96cc14d 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
@@ -336,9 +336,6 @@ OmniboxPopupViewGtk::~OmniboxPopupViewGtk() {
model_.reset();
g_object_unref(layout_);
gtk_widget_destroy(window_);
-
- for (ImageMap::iterator it = images_.begin(); it != images_.end(); ++it)
- delete it->second;
}
bool OmniboxPopupViewGtk::IsOpen() const {
@@ -483,19 +480,13 @@ void OmniboxPopupViewGtk::AcceptLine(size_t line,
omnibox_view_->OpenMatch(match, disposition, GURL(), line);
}
-const gfx::Image* OmniboxPopupViewGtk::IconForMatch(
+gfx::Image OmniboxPopupViewGtk::IconForMatch(
const AutocompleteMatch& match,
bool selected,
bool is_selected_keyword) {
- const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(match);
- if (bitmap) {
- if (!ContainsKey(images_, bitmap)) {
- // gfx::Image wants ownership of bitmaps given to it, and we might as
- // well make the bitmap copy a format that will be used.
- images_[bitmap] = new gfx::Image(gfx::GdkPixbufFromSkBitmap(*bitmap));
- }
- return images_[bitmap];
- }
+ const gfx::Image image = model_->GetIconIfExtensionMatch(match);
+ if (!image.IsEmpty())
+ return image;
int icon;
if (is_selected_keyword)
@@ -528,7 +519,7 @@ const gfx::Image* OmniboxPopupViewGtk::IconForMatch(
}
}
- return theme_service_->GetImageNamed(icon);
+ return *theme_service_->GetImageNamed(icon);
}
void OmniboxPopupViewGtk::GetVisibleMatchForInput(
@@ -727,7 +718,7 @@ gboolean OmniboxPopupViewGtk::HandleExpose(GtkWidget* widget,
kIconLeftPadding;
// Draw the icon for this result.
gtk_util::DrawFullImage(cr, widget,
- theme_service_->GetImageNamed(
+ *theme_service_->GetImageNamed(
is_selected ? IDR_OMNIBOX_TTS_DARK :
IDR_OMNIBOX_TTS),
icon_start_x, line_rect.y() + kIconTopPadding);
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h
index c6245be..442bfd7 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h
@@ -82,9 +82,9 @@ class OmniboxPopupViewGtk : public OmniboxPopupView,
// Accept a line of the results, for example, when the user clicks a line.
void AcceptLine(size_t line, WindowOpenDisposition disposition);
- const gfx::Image* IconForMatch(const AutocompleteMatch& match,
- bool selected,
- bool is_selected_keyword);
+ gfx::Image IconForMatch(const AutocompleteMatch& match,
+ bool selected,
+ bool is_selected_keyword);
// Returns the |index|th element of match, unless we're selected and showing
// the associated keyword match.
@@ -122,11 +122,6 @@ class OmniboxPopupViewGtk : public OmniboxPopupView,
// |font|.
gfx::Font font_;
- // Used to cache GdkPixbufs and map them from the SkBitmaps they were created
- // from.
- typedef std::map<const SkBitmap*, gfx::Image*> ImageMap;
- ImageMap images_;
-
// A list of colors which we should use for drawing the popup. These change
// between gtk and normal mode.
GdkColor border_color_;
diff --git a/chrome/browser/ui/omnibox/omnibox_popup_model.cc b/chrome/browser/ui/omnibox/omnibox_popup_model.cc
index 6492eb9..467a903 100644
--- a/chrome/browser/ui/omnibox/omnibox_popup_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_popup_model.cc
@@ -193,13 +193,15 @@ void OmniboxPopupModel::TryDeletingCurrentItem() {
}
}
-const SkBitmap* OmniboxPopupModel::GetIconIfExtensionMatch(
+gfx::Image OmniboxPopupModel::GetIconIfExtensionMatch(
const AutocompleteMatch& match) const {
Profile* profile = edit_model_->profile();
const TemplateURL* template_url = match.GetTemplateURL(profile);
- return (template_url && template_url->IsExtensionKeyword()) ?
- &profile->GetExtensionService()->GetOmniboxPopupIcon(
- template_url->GetExtensionId()) : NULL;
+ if (template_url && template_url->IsExtensionKeyword()) {
+ return profile->GetExtensionService()->GetOmniboxPopupIcon(
+ template_url->GetExtensionId());
+ }
+ return gfx::Image();
}
void OmniboxPopupModel::OnResultChanged() {
diff --git a/chrome/browser/ui/omnibox/omnibox_popup_model.h b/chrome/browser/ui/omnibox/omnibox_popup_model.h
index f4b4b23..85934b4 100644
--- a/chrome/browser/ui/omnibox/omnibox_popup_model.h
+++ b/chrome/browser/ui/omnibox/omnibox_popup_model.h
@@ -11,7 +11,10 @@
#include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
class OmniboxPopupView;
-class SkBitmap;
+
+namespace gfx {
+class Image;
+}
class OmniboxPopupModel {
public:
@@ -81,8 +84,8 @@ class OmniboxPopupModel {
void TryDeletingCurrentItem();
// If |match| is from an extension, returns the extension icon; otherwise
- // returns NULL.
- const SkBitmap* GetIconIfExtensionMatch(const AutocompleteMatch& match) const;
+ // returns an empty Image.
+ gfx::Image GetIconIfExtensionMatch(const AutocompleteMatch& match) const;
// The match the user has manually chosen, if any.
const AutocompleteResult::Selection& manually_selected_match() const {
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 8e9f3b3..9a48285 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -717,10 +717,9 @@ void LocationBarView::Layout() {
TemplateURLServiceFactory::GetForProfile(profile_)->
GetTemplateURLForKeyword(keyword);
if (template_url && template_url->IsExtensionKeyword()) {
- const SkBitmap& bitmap =
- profile_->GetExtensionService()->GetOmniboxIcon(
- template_url->GetExtensionId());
- selected_keyword_view_->SetImage(bitmap);
+ gfx::Image image = profile_->GetExtensionService()->GetOmniboxIcon(
+ template_url->GetExtensionId());
+ selected_keyword_view_->SetImage(image.AsImageSkia());
selected_keyword_view_->set_is_extension_icon(true);
} else {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
diff --git a/chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.cc b/chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.cc
index 33fbf74..a6eb50a 100644
--- a/chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.cc
+++ b/chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.cc
@@ -203,10 +203,10 @@ bool InlineOmniboxPopupView::IsHoveredIndex(size_t index) const {
return index == model_->hovered_line();
}
-const SkBitmap* InlineOmniboxPopupView::GetIconIfExtensionMatch(
+gfx::Image InlineOmniboxPopupView::GetIconIfExtensionMatch(
size_t index) const {
if (!HasMatchAt(index))
- return NULL;
+ return gfx::Image();
return model_->GetIconIfExtensionMatch(GetMatchAtIndex(index));
}
diff --git a/chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.h b/chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.h
index 2f9f2e6..e396d94 100644
--- a/chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.h
+++ b/chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.h
@@ -55,7 +55,7 @@ class InlineOmniboxPopupView : public views::View,
// Overridden from OmniboxResultViewModel:
virtual bool IsSelectedIndex(size_t index) const OVERRIDE;
virtual bool IsHoveredIndex(size_t index) const OVERRIDE;
- virtual const SkBitmap* GetIconIfExtensionMatch(size_t index) const OVERRIDE;
+ virtual gfx::Image GetIconIfExtensionMatch(size_t index) const OVERRIDE;
// Overridden from ui::AnimationDelegate:
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
diff --git a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc
index 92c40ee..726b4ca 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/ui/views/omnibox/touch_omnibox_popup_contents_view.h"
#include "ui/base/theme_provider.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/image/image.h"
#include "ui/gfx/path.h"
#include "ui/views/widget/widget.h"
@@ -275,10 +276,10 @@ bool OmniboxPopupContentsView::IsHoveredIndex(size_t index) const {
return index == model_->hovered_line();
}
-const SkBitmap* OmniboxPopupContentsView::GetIconIfExtensionMatch(
+gfx::Image OmniboxPopupContentsView::GetIconIfExtensionMatch(
size_t index) const {
if (!HasMatchAt(index))
- return NULL;
+ return gfx::Image();
return model_->GetIconIfExtensionMatch(GetMatchAtIndex(index));
}
diff --git a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h
index 760dd6a..5026034 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h
+++ b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h
@@ -55,7 +55,7 @@ class OmniboxPopupContentsView : public views::View,
// Overridden from OmniboxResultViewModel:
virtual bool IsSelectedIndex(size_t index) const OVERRIDE;
virtual bool IsHoveredIndex(size_t index) const OVERRIDE;
- virtual const SkBitmap* GetIconIfExtensionMatch(size_t index) const OVERRIDE;
+ virtual gfx::Image GetIconIfExtensionMatch(size_t index) const OVERRIDE;
// Overridden from ui::AnimationDelegate:
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
diff --git a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc
index 5a1e989..d6ec40e 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc
@@ -277,10 +277,10 @@ bool OmniboxResultView::SortRunsVisually(const RunData& lhs,
// static
int OmniboxResultView::default_icon_size_ = 0;
-const SkBitmap* OmniboxResultView::GetIcon() const {
- const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(model_index_);
- if (bitmap)
- return bitmap;
+gfx::ImageSkia OmniboxResultView::GetIcon() const {
+ const gfx::Image image = model_->GetIconIfExtensionMatch(model_index_);
+ if (!image.IsEmpty())
+ return image.AsImageSkia();
int icon = match_.starred ?
IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type);
@@ -303,7 +303,7 @@ const SkBitmap* OmniboxResultView::GetIcon() const {
break;
}
}
- return ui::ResourceBundle::GetSharedInstance().GetBitmapNamed(icon);
+ return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon);
}
const gfx::ImageSkia* OmniboxResultView::GetKeywordIcon() const {
@@ -561,12 +561,12 @@ void OmniboxResultView::Elide(Runs* runs, int remaining_width) const {
}
void OmniboxResultView::Layout() {
- const SkBitmap* icon = GetIcon();
+ const gfx::ImageSkia icon = GetIcon();
icon_bounds_.SetRect(edge_item_padding_ +
- ((icon->width() == default_icon_size_) ?
+ ((icon.width() == default_icon_size_) ?
0 : LocationBarView::kIconInternalPadding),
- (height() - icon->height()) / 2, icon->width(), icon->height());
+ (height() - icon.height()) / 2, icon.width(), icon.height());
int text_x = edge_item_padding_ + default_icon_size_ + item_padding_;
int text_height = GetTextHeight();
@@ -605,7 +605,7 @@ void OmniboxResultView::OnPaint(gfx::Canvas* canvas) {
if (!match_.associated_keyword.get() ||
keyword_icon_->x() > icon_bounds_.right()) {
// Paint the icon.
- canvas->DrawImageInt(*GetIcon(), GetMirroredXForRect(icon_bounds_),
+ canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_),
icon_bounds_.y());
// Paint the text.
diff --git a/chrome/browser/ui/views/omnibox/omnibox_result_view.h b/chrome/browser/ui/views/omnibox/omnibox_result_view.h
index f784845..c5d5b78 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_result_view.h
+++ b/chrome/browser/ui/views/omnibox/omnibox_result_view.h
@@ -102,7 +102,7 @@ class OmniboxResultView : public views::View,
static bool SortRunsLogically(const RunData& lhs, const RunData& rhs);
static bool SortRunsVisually(const RunData& lhs, const RunData& rhs);
- const SkBitmap* GetIcon() const;
+ gfx::ImageSkia GetIcon() const;
const gfx::ImageSkia* GetKeywordIcon() const;
// Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in
diff --git a/chrome/browser/ui/views/omnibox/omnibox_result_view_model.h b/chrome/browser/ui/views/omnibox/omnibox_result_view_model.h
index 630945c..0a1db3d 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_result_view_model.h
+++ b/chrome/browser/ui/views/omnibox/omnibox_result_view_model.h
@@ -5,7 +5,9 @@
#ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_MODEL_H_
#define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_MODEL_H_
-class SkBitmap;
+namespace gfx {
+class Image;
+}
// An interface implemented by an object that provides data to populate
// individual result views.
@@ -18,8 +20,8 @@ class OmniboxResultViewModel {
virtual bool IsHoveredIndex(size_t index) const = 0;
// If |index| is a match from an extension, returns the extension icon;
- // otherwise returns NULL.
- virtual const SkBitmap* GetIconIfExtensionMatch(size_t index) const = 0;
+ // otherwise returns an empty gfx::Image.
+ virtual gfx::Image GetIconIfExtensionMatch(size_t index) const = 0;
};
#endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_MODEL_H_