summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-15 21:13:47 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-15 21:13:47 +0000
commitb671760bb1967f74d584c7790af86a5aee6fd43c (patch)
tree293ed23ee335c9300dbf72b679cbaf083b41bb4f /chrome/browser/gtk
parentf9a2b2fe071c001a6864e527fd7035489a985243 (diff)
downloadchromium_src-b671760bb1967f74d584c7790af86a5aee6fd43c.zip
chromium_src-b671760bb1967f74d584c7790af86a5aee6fd43c.tar.gz
chromium_src-b671760bb1967f74d584c7790af86a5aee6fd43c.tar.bz2
Use the extension icon for extension omnibox results instead of the generic
search icon. I refactored the extension menu manager to separate the icon-specific bits. BUG=46479 TEST=load the chrome search extension at src/chrome/common/extensions/docs/examples/extensions/chrome_search/ and type "src foo" into the omnibox. You should see the extension icon instead of the magnifying glass. Switch back and forth between the "src" keyword result, other results, and other keywords and the icons should update properly. Review URL: http://codereview.chromium.org/2973006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52535 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc22
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.h4
2 files changed, 24 insertions, 2 deletions
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index 601586b..24c7151 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -208,9 +208,9 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
tab_to_search_partial_label_, FALSE, FALSE, 0);
GtkWidget* tab_to_search_hbox = gtk_hbox_new(FALSE, 0);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- GtkWidget* tab_to_search_lens = gtk_image_new_from_pixbuf(
+ tab_to_search_magnifier_ = gtk_image_new_from_pixbuf(
rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH));
- gtk_box_pack_start(GTK_BOX(tab_to_search_hbox), tab_to_search_lens,
+ gtk_box_pack_start(GTK_BOX(tab_to_search_hbox), tab_to_search_magnifier_,
FALSE, FALSE, 0);
gtk_util::CenterWidgetInHBox(tab_to_search_hbox, tab_to_search_label_hbox,
false, 0);
@@ -875,6 +875,24 @@ void LocationBarViewGtk::SetKeywordLabel(const std::wstring& keyword) {
WideToUTF8(full_name).c_str());
gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_),
WideToUTF8(partial_name).c_str());
+
+ if (last_keyword_ != keyword) {
+ last_keyword_ = keyword;
+
+ if (is_extension_keyword) {
+ const TemplateURL* template_url =
+ profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ const SkBitmap& bitmap = profile_->GetExtensionsService()->
+ 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);
+ } else {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_),
+ rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH));
+ }
+ }
}
void LocationBarViewGtk::SetKeywordHintLabel(const std::wstring& keyword) {
diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h
index da87cdc..870e415 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.h
+++ b/chrome/browser/gtk/location_bar_view_gtk.h
@@ -362,6 +362,7 @@ class LocationBarViewGtk : public AutocompleteEditController,
// Area on the left shown when in tab to search mode.
GtkWidget* tab_to_search_box_;
+ GtkWidget* tab_to_search_magnifier_;
GtkWidget* tab_to_search_full_label_;
GtkWidget* tab_to_search_partial_label_;
@@ -417,6 +418,9 @@ class LocationBarViewGtk : public AutocompleteEditController,
// Indicate if |tab_to_search_hint_| should be shown.
bool show_keyword_hint_;
+ // The last search keyword that was shown via the |tab_to_search_box_|.
+ std::wstring last_keyword_;
+
DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk);
};