summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/autocomplete
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 19:19:35 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 19:19:35 +0000
commit08a4bf01ec877a26560c1f5b6c932cb9a961be48 (patch)
tree2e925208e879b51d315fc25e03511b092b9fd6d3 /chrome/browser/views/autocomplete
parent9f673e17d7167f222503df2b5ee2c966f3fafc5f (diff)
downloadchromium_src-08a4bf01ec877a26560c1f5b6c932cb9a961be48.zip
chromium_src-08a4bf01ec877a26560c1f5b6c932cb9a961be48.tar.gz
chromium_src-08a4bf01ec877a26560c1f5b6c932cb9a961be48.tar.bz2
Add star icon for bookmarked results in the omnibox2 popup view.
No, I'm not adding any more ternaries. Review URL: http://codereview.chromium.org/115336 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16090 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/autocomplete')
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc12
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h12
2 files changed, 18 insertions, 6 deletions
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
index e7eadd6..ffeee23 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -397,10 +397,14 @@ SkBitmap* AutocompleteResultView::GetIcon() const {
case AutocompleteMatch::URL_WHAT_YOU_TYPED:
case AutocompleteMatch::HISTORY_URL:
case AutocompleteMatch::NAVSUGGEST:
+ if (model_->IsBookmarkedIndex(model_index_))
+ return selected ? icon_star_selected_ : icon_star_;
return selected ? icon_url_selected_ : icon_url_;
case AutocompleteMatch::HISTORY_TITLE:
case AutocompleteMatch::HISTORY_BODY:
case AutocompleteMatch::HISTORY_KEYWORD:
+ if (model_->IsBookmarkedIndex(model_index_))
+ return selected ? icon_star_selected_ : icon_star_;
return selected ? icon_history_selected_ : icon_history_;
case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED:
case AutocompleteMatch::SEARCH_HISTORY:
@@ -724,12 +728,16 @@ AutocompletePopupModel* AutocompletePopupContentsView::GetModel() {
////////////////////////////////////////////////////////////////////////////////
// AutocompletePopupContentsView, AutocompleteResultViewModel implementation:
-bool AutocompletePopupContentsView::IsSelectedIndex(size_t index) {
+bool AutocompletePopupContentsView::IsSelectedIndex(size_t index) const {
return index == model_->selected_line();
}
+bool AutocompletePopupContentsView::IsBookmarkedIndex(size_t index) const {
+ return GetMatchAtIndex(index).starred;
+}
+
const AutocompleteMatch& AutocompletePopupContentsView::GetMatchAtIndex(
- size_t index) {
+ size_t index) const {
return model_->result().match_at(index);
}
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
index 6b39c79..19323eb 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
@@ -22,10 +22,13 @@ class Profile;
class AutocompleteResultViewModel {
public:
// Returns true if the index is selected.
- virtual bool IsSelectedIndex(size_t index) = 0;
+ virtual bool IsSelectedIndex(size_t index) const = 0;
+
+ // Returns true if the index is bookmarked.
+ virtual bool IsBookmarkedIndex(size_t index) const = 0;
// Returns the type of match that the row corresponds to.
- virtual const AutocompleteMatch& GetMatchAtIndex(size_t index) = 0;
+ virtual const AutocompleteMatch& GetMatchAtIndex(size_t index) const = 0;
// Called when the line at the specified index should be opened with the
// provided disposition.
@@ -66,8 +69,9 @@ class AutocompletePopupContentsView : public views::View,
virtual AutocompletePopupModel* GetModel();
// Overridden from AutocompleteResultViewModel:
- virtual bool IsSelectedIndex(size_t index);
- virtual const AutocompleteMatch& GetMatchAtIndex(size_t index);
+ virtual bool IsSelectedIndex(size_t index) const;
+ virtual bool IsBookmarkedIndex(size_t index) const;
+ virtual const AutocompleteMatch& GetMatchAtIndex(size_t index) const;
virtual void OpenIndex(size_t index, WindowOpenDisposition disposition);
virtual void SetHoveredLine(size_t index);
virtual void SetSelectedLine(size_t index, bool revert_to_default);