summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 00:19:18 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 00:19:18 +0000
commit66ee443252fd759c5e20cb93be1e90a732da0ebe (patch)
tree5ee39c6ee0c62c8feba5103836a36d28203b7b54 /chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
parentcbadedd7a2cdc20a745ff8b51922b2533169f7b0 (diff)
downloadchromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.zip
chromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.tar.gz
chromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.tar.bz2
Show the location bar icon (almost) all the time, and have its contents match what the user is doing.
There are a couple major moving parts here: * Change AutocompletePopupModel::URLsForCurrentText() to InfoForCurrentText() and have it return an AutocompleteMatch, which callers can use to parse out whatever they want. I needed to get at the match type for the current text and found the proliferation of arguments here ridiculous. This had major ripple effects throughout the codebase, including changing the name and location of SearchVersusNavigateClassifier as it no longer had an "is_search" parameter directly, so the name became misleading and too narrow. I also ended up adding a null constructor for AutocompleteMatch because it was too cumbersome otherwise. * Change the name of the "SecurityImageView" (or similar) to reflect its broader purpose, and plumb it to the edit to get an icon instead of to the toolbar model. * Add an AutocompleteMatch::Type to icon mapping function, and use it not only in the new code but also to simplify showing the popup contents. BUG=27570,39725 TEST=An icon should appear next to the address at all times. It should be a globe on non-secure pages, a magnifying glass on the NTP, and a match for whatever the user is typing as he types. Review URL: http://codereview.chromium.org/1457002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43025 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc52
1 files changed, 13 insertions, 39 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
index 84538e0f..024d7d0 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
@@ -165,47 +165,21 @@ void SetupLayoutForMatch(PangoLayout* layout,
}
GdkPixbuf* IconForMatch(const AutocompleteMatch& match, bool selected) {
+ int icon = match.starred ?
+ IDR_O2_STAR : AutocompleteMatch::TypeToIcon(match.type);
+ if (selected) {
+ switch (icon) {
+ case IDR_O2_GLOBE: icon = IDR_O2_GLOBE_SELECTED; break;
+ case IDR_O2_HISTORY: icon = IDR_O2_HISTORY_SELECTED; break;
+ case IDR_O2_SEARCH: icon = IDR_O2_SEARCH_SELECTED; break;
+ case IDR_O2_MORE: icon = IDR_O2_MORE_SELECTED; break;
+ case IDR_O2_STAR: icon = IDR_O2_STAR_SELECTED; break;
+ default: NOTREACHED(); break;
+ }
+ }
// TODO(deanm): These would be better as pixmaps someday.
// TODO(estade): Do we want to flip these for RTL? (Windows doesn't).
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- static GdkPixbuf* o2_globe = rb.GetPixbufNamed(IDR_O2_GLOBE);
- static GdkPixbuf* o2_globe_s = rb.GetPixbufNamed(IDR_O2_GLOBE_SELECTED_DARK);
- static GdkPixbuf* o2_history = rb.GetPixbufNamed(IDR_O2_HISTORY);
- static GdkPixbuf* o2_history_s =
- rb.GetPixbufNamed(IDR_O2_HISTORY_SELECTED_DARK);
- static GdkPixbuf* o2_more = rb.GetPixbufNamed(IDR_O2_MORE);
- static GdkPixbuf* o2_more_s = rb.GetPixbufNamed(IDR_O2_MORE_SELECTED_DARK);
- static GdkPixbuf* o2_search = rb.GetPixbufNamed(IDR_O2_SEARCH);
- static GdkPixbuf* o2_search_s =
- rb.GetPixbufNamed(IDR_O2_SEARCH_SELECTED_DARK);
- static GdkPixbuf* o2_star = rb.GetPixbufNamed(IDR_O2_STAR);
- static GdkPixbuf* o2_star_s = rb.GetPixbufNamed(IDR_O2_STAR_SELECTED_DARK);
-
- if (match.starred)
- return selected ? o2_star_s : o2_star;
-
- switch (match.type) {
- case AutocompleteMatch::URL_WHAT_YOU_TYPED:
- case AutocompleteMatch::NAVSUGGEST:
- return selected ? o2_globe_s : o2_globe;
- case AutocompleteMatch::HISTORY_URL:
- case AutocompleteMatch::HISTORY_TITLE:
- case AutocompleteMatch::HISTORY_BODY:
- case AutocompleteMatch::HISTORY_KEYWORD:
- return selected ? o2_history_s : o2_history;
- case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED:
- case AutocompleteMatch::SEARCH_HISTORY:
- case AutocompleteMatch::SEARCH_SUGGEST:
- case AutocompleteMatch::SEARCH_OTHER_ENGINE:
- return selected ? o2_search_s : o2_search;
- case AutocompleteMatch::OPEN_HISTORY_PAGE:
- return selected ? o2_more_s : o2_more;
- default:
- NOTREACHED();
- break;
- }
-
- return NULL;
+ return ResourceBundle::GetSharedInstance().GetPixbufNamed(icon);
}
} // namespace