Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1082)

Side by Side Diff: chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc

Issue 2973006: Use the extension icon for extension omnibox results instead of the generic (Closed)
Patch Set: fixed mac Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
6 6
7 #include "app/bidi_line_iterator.h" 7 #include "app/bidi_line_iterator.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "app/theme_provider.h" 10 #include "app/theme_provider.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // in logical order. 146 // in logical order.
147 }; 147 };
148 typedef std::vector<RunData> Runs; 148 typedef std::vector<RunData> Runs;
149 149
150 // Predicate functions for use when sorting the runs. 150 // Predicate functions for use when sorting the runs.
151 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); 151 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs);
152 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); 152 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs);
153 153
154 ResultViewState GetState() const; 154 ResultViewState GetState() const;
155 155
156 SkBitmap* GetIcon() const; 156 const SkBitmap* GetIcon() const;
157 157
158 // Draws the specified |text| into the canvas, using highlighting provided by 158 // Draws the specified |text| into the canvas, using highlighting provided by
159 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is 159 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is
160 // added to all of the classifications. Returns the x position to the right 160 // added to all of the classifications. Returns the x position to the right
161 // of the string. 161 // of the string.
162 int DrawString(gfx::Canvas* canvas, 162 int DrawString(gfx::Canvas* canvas,
163 const std::wstring& text, 163 const std::wstring& text,
164 const ACMatchClassifications& classifications, 164 const ACMatchClassifications& classifications,
165 bool force_dim, 165 bool force_dim,
166 int x, 166 int x,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 const RunData& rhs) { 332 const RunData& rhs) {
333 return lhs.visual_order < rhs.visual_order; 333 return lhs.visual_order < rhs.visual_order;
334 } 334 }
335 335
336 ResultViewState AutocompleteResultView::GetState() const { 336 ResultViewState AutocompleteResultView::GetState() const {
337 if (model_->IsSelectedIndex(model_index_)) 337 if (model_->IsSelectedIndex(model_index_))
338 return SELECTED; 338 return SELECTED;
339 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; 339 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL;
340 } 340 }
341 341
342 SkBitmap* AutocompleteResultView::GetIcon() const { 342 const SkBitmap* AutocompleteResultView::GetIcon() const {
343 const SkBitmap* bitmap = model_->GetSpecialIcon(model_index_);
344 if (bitmap)
345 return bitmap;
346
343 int icon = match_.starred ? 347 int icon = match_.starred ?
344 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type); 348 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type);
345 if (model_->IsSelectedIndex(model_index_)) { 349 if (model_->IsSelectedIndex(model_index_)) {
346 switch (icon) { 350 switch (icon) {
347 case IDR_OMNIBOX_HTTP: icon = IDR_OMNIBOX_HTTP_SELECTED; break; 351 case IDR_OMNIBOX_HTTP: icon = IDR_OMNIBOX_HTTP_SELECTED; break;
348 case IDR_OMNIBOX_HISTORY: icon = IDR_OMNIBOX_HISTORY_SELECTED; break; 352 case IDR_OMNIBOX_HISTORY: icon = IDR_OMNIBOX_HISTORY_SELECTED; break;
349 case IDR_OMNIBOX_SEARCH: icon = IDR_OMNIBOX_SEARCH_SELECTED; break; 353 case IDR_OMNIBOX_SEARCH: icon = IDR_OMNIBOX_SEARCH_SELECTED; break;
350 case IDR_OMNIBOX_MORE: icon = IDR_OMNIBOX_MORE_SELECTED; break; 354 case IDR_OMNIBOX_MORE: icon = IDR_OMNIBOX_MORE_SELECTED; break;
351 case IDR_OMNIBOX_STAR: icon = IDR_OMNIBOX_STAR_SELECTED; break; 355 case IDR_OMNIBOX_STAR: icon = IDR_OMNIBOX_STAR_SELECTED; break;
352 default: NOTREACHED(); break; 356 default: NOTREACHED(); break;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 // AutocompletePopupContentsView, AutocompleteResultViewModel implementation: 737 // AutocompletePopupContentsView, AutocompleteResultViewModel implementation:
734 738
735 bool AutocompletePopupContentsView::IsSelectedIndex(size_t index) const { 739 bool AutocompletePopupContentsView::IsSelectedIndex(size_t index) const {
736 return HasMatchAt(index) ? index == model_->selected_line() : false; 740 return HasMatchAt(index) ? index == model_->selected_line() : false;
737 } 741 }
738 742
739 bool AutocompletePopupContentsView::IsHoveredIndex(size_t index) const { 743 bool AutocompletePopupContentsView::IsHoveredIndex(size_t index) const {
740 return HasMatchAt(index) ? index == model_->hovered_line() : false; 744 return HasMatchAt(index) ? index == model_->hovered_line() : false;
741 } 745 }
742 746
747 const SkBitmap* AutocompletePopupContentsView::GetSpecialIcon(
748 size_t index) const {
749 if (!HasMatchAt(index))
750 return NULL;
751 return model_->GetSpecialIconForMatch(GetMatchAtIndex(index));
752 }
753
743 //////////////////////////////////////////////////////////////////////////////// 754 ////////////////////////////////////////////////////////////////////////////////
744 // AutocompletePopupContentsView, AnimationDelegate implementation: 755 // AutocompletePopupContentsView, AnimationDelegate implementation:
745 756
746 void AutocompletePopupContentsView::AnimationProgressed( 757 void AutocompletePopupContentsView::AnimationProgressed(
747 const Animation* animation) { 758 const Animation* animation) {
748 // We should only be running the animation when the popup is already visible. 759 // We should only be running the animation when the popup is already visible.
749 DCHECK(popup_ != NULL); 760 DCHECK(popup_ != NULL);
750 popup_->SetBounds(GetPopupBounds()); 761 popup_->SetBounds(GetPopupBounds());
751 } 762 }
752 763
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 DCHECK(nb_match <= GetChildViewCount()); 975 DCHECK(nb_match <= GetChildViewCount());
965 for (int i = 0; i < nb_match; ++i) { 976 for (int i = 0; i < nb_match; ++i) {
966 views::View* child = GetChildViewAt(i); 977 views::View* child = GetChildViewAt(i);
967 gfx::Point point_in_child_coords(point); 978 gfx::Point point_in_child_coords(point);
968 View::ConvertPointToView(this, child, &point_in_child_coords); 979 View::ConvertPointToView(this, child, &point_in_child_coords);
969 if (child->HitTest(point_in_child_coords)) 980 if (child->HitTest(point_in_child_coords))
970 return i; 981 return i;
971 } 982 }
972 return AutocompletePopupModel::kNoMatch; 983 return AutocompletePopupModel::kNoMatch;
973 } 984 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698