summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc15
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h5
-rw-r--r--chrome/browser/views/location_bar/icon_label_bubble_view.cc4
-rw-r--r--chrome/browser/views/location_bar/icon_label_bubble_view.h3
-rw-r--r--chrome/browser/views/location_bar/location_bar_view.cc15
5 files changed, 39 insertions, 3 deletions
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
index 17d243c..45a10bf 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -153,7 +153,7 @@ class AutocompleteResultView : public views::View {
ResultViewState GetState() const;
- SkBitmap* GetIcon() const;
+ const SkBitmap* GetIcon() const;
// Draws the specified |text| into the canvas, using highlighting provided by
// |classifications|. If |force_dim| is true, ACMatchClassification::DIM is
@@ -339,7 +339,11 @@ ResultViewState AutocompleteResultView::GetState() const {
return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL;
}
-SkBitmap* AutocompleteResultView::GetIcon() const {
+const SkBitmap* AutocompleteResultView::GetIcon() const {
+ const SkBitmap* bitmap = model_->GetSpecialIcon(model_index_);
+ if (bitmap)
+ return bitmap;
+
int icon = match_.starred ?
IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type);
if (model_->IsSelectedIndex(model_index_)) {
@@ -740,6 +744,13 @@ bool AutocompletePopupContentsView::IsHoveredIndex(size_t index) const {
return HasMatchAt(index) ? index == model_->hovered_line() : false;
}
+const SkBitmap* AutocompletePopupContentsView::GetSpecialIcon(
+ size_t index) const {
+ if (!HasMatchAt(index))
+ return NULL;
+ return model_->GetSpecialIconForMatch(GetMatchAtIndex(index));
+}
+
////////////////////////////////////////////////////////////////////////////////
// AutocompletePopupContentsView, AnimationDelegate implementation:
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
index d814206..80704cd 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
@@ -33,6 +33,10 @@ class AutocompleteResultViewModel {
// Returns true if the index is hovered.
virtual bool IsHoveredIndex(size_t index) const = 0;
+
+ // Returns the special-case icon we should use for the given index, or NULL
+ // if we should use the default icon.
+ virtual const SkBitmap* GetSpecialIcon(size_t index) const = 0;
};
// A view representing the contents of the autocomplete popup.
@@ -63,6 +67,7 @@ class AutocompletePopupContentsView : public views::View,
// Overridden from AutocompleteResultViewModel:
virtual bool IsSelectedIndex(size_t index) const;
virtual bool IsHoveredIndex(size_t index) const;
+ virtual const SkBitmap* GetSpecialIcon(size_t index) const;
// Overridden from AnimationDelegate:
virtual void AnimationProgressed(const Animation* animation);
diff --git a/chrome/browser/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/views/location_bar/icon_label_bubble_view.cc
index 729c9a1..4e92ac0 100644
--- a/chrome/browser/views/location_bar/icon_label_bubble_view.cc
+++ b/chrome/browser/views/location_bar/icon_label_bubble_view.cc
@@ -43,6 +43,10 @@ void IconLabelBubbleView::SetLabel(const std::wstring& label) {
label_->SetText(label);
}
+void IconLabelBubbleView::SetImage(const SkBitmap& bitmap) {
+ image_->SetImage(bitmap);
+}
+
void IconLabelBubbleView::Paint(gfx::Canvas* canvas) {
int y_offset = (GetParent()->height() - height()) / 2;
canvas->TranslateInt(0, y_offset);
diff --git a/chrome/browser/views/location_bar/icon_label_bubble_view.h b/chrome/browser/views/location_bar/icon_label_bubble_view.h
index 53b0b33..dd5b196 100644
--- a/chrome/browser/views/location_bar/icon_label_bubble_view.h
+++ b/chrome/browser/views/location_bar/icon_label_bubble_view.h
@@ -20,6 +20,8 @@ class ImageView;
class Label;
}
+class SkBitmap;
+
// View used to draw a bubble to the left of the address, containing an icon and
// a label. We use this as a base for the classes that handle the EV bubble and
// tab-to-search UI.
@@ -32,6 +34,7 @@ class IconLabelBubbleView : public views::View {
void SetFont(const gfx::Font& font);
void SetLabel(const std::wstring& label);
+ void SetImage(const SkBitmap& bitmap);
virtual void Paint(gfx::Canvas* canvas);
virtual gfx::Size GetPreferredSize();
diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc
index 8ed874d..4dffa4e 100644
--- a/chrome/browser/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/views/location_bar/location_bar_view.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/view_ids.h"
#include "chrome/browser/views/browser_dialogs.h"
#include "chrome/browser/views/location_bar/content_setting_image_view.h"
@@ -457,8 +458,20 @@ void LocationBarView::Layout() {
selected_keyword_view_->SetVisible(show_selected_keyword);
keyword_hint_view_->SetVisible(show_keyword_hint);
if (show_selected_keyword) {
- if (selected_keyword_view_->keyword() != keyword)
+ if (selected_keyword_view_->keyword() != keyword) {
selected_keyword_view_->SetKeyword(keyword);
+
+ const TemplateURL* template_url =
+ profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ if (template_url && template_url->IsExtensionKeyword()) {
+ const SkBitmap& bitmap = profile_->GetExtensionsService()->
+ GetOmniboxIcon(template_url->GetExtensionId());
+ selected_keyword_view_->SetImage(bitmap);
+ } else {
+ selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance().
+ GetBitmapNamed(IDR_OMNIBOX_SEARCH));
+ }
+ }
} else if (show_keyword_hint) {
if (keyword_hint_view_->keyword() != keyword)
keyword_hint_view_->SetKeyword(keyword);