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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_result_view.cc

Issue 1418543002: Vectorize omnibox dropdown icons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: notreached Created 5 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // For WinDDK ATL compatibility, these ATL headers must come first. 5 // For WinDDK ATL compatibility, these ATL headers must come first.
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <atlbase.h> // NOLINT 8 #include <atlbase.h> // NOLINT
9 #include <atlwin.h> // NOLINT 9 #include <atlwin.h> // NOLINT
10 #endif 10 #endif
(...skipping 12 matching lines...) Expand all
23 #include "components/omnibox/browser/omnibox_popup_model.h" 23 #include "components/omnibox/browser/omnibox_popup_model.h"
24 #include "grit/components_scaled_resources.h" 24 #include "grit/components_scaled_resources.h"
25 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
26 #include "third_party/skia/include/core/SkColor.h" 26 #include "third_party/skia/include/core/SkColor.h"
27 #include "ui/accessibility/ax_view_state.h" 27 #include "ui/accessibility/ax_view_state.h"
28 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/base/resource/material_design/material_design_controller.h" 29 #include "ui/base/resource/material_design/material_design_controller.h"
30 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/base/theme_provider.h" 31 #include "ui/base/theme_provider.h"
32 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
33 #include "ui/gfx/color_palette.h"
33 #include "ui/gfx/color_utils.h" 34 #include "ui/gfx/color_utils.h"
34 #include "ui/gfx/image/image.h" 35 #include "ui/gfx/image/image.h"
36 #include "ui/gfx/paint_vector_icon.h"
35 #include "ui/gfx/range/range.h" 37 #include "ui/gfx/range/range.h"
36 #include "ui/gfx/render_text.h" 38 #include "ui/gfx/render_text.h"
37 #include "ui/gfx/text_utils.h" 39 #include "ui/gfx/text_utils.h"
40 #include "ui/gfx/vector_icons_public.h"
38 41
39 using ui::NativeTheme; 42 using ui::NativeTheme;
40 43
41 namespace { 44 namespace {
42 45
43 // A mapping from OmniboxResultView's ResultViewState/ColorKind types to 46 // A mapping from OmniboxResultView's ResultViewState/ColorKind types to
44 // NativeTheme colors. 47 // NativeTheme colors.
45 struct TranslationTable { 48 struct TranslationTable {
46 ui::NativeTheme::ColorId id; 49 ui::NativeTheme::ColorId id;
47 OmniboxResultView::ResultViewState state; 50 OmniboxResultView::ResultViewState state;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 563
561 const char* OmniboxResultView::GetClassName() const { 564 const char* OmniboxResultView::GetClassName() const {
562 return "OmniboxResultView"; 565 return "OmniboxResultView";
563 } 566 }
564 567
565 gfx::ImageSkia OmniboxResultView::GetIcon() const { 568 gfx::ImageSkia OmniboxResultView::GetIcon() const {
566 const gfx::Image image = model_->GetIconIfExtensionMatch(model_index_); 569 const gfx::Image image = model_->GetIconIfExtensionMatch(model_index_);
567 if (!image.IsEmpty()) 570 if (!image.IsEmpty())
568 return image.AsImageSkia(); 571 return image.AsImageSkia();
569 572
573 if (ui::MaterialDesignController::IsModeMaterial())
574 return GetMaterialIcon();
Peter Kasting 2015/10/20 01:02:59 Nit: I dunno if separating this into its own helpe
Evan Stade 2015/10/20 01:12:09 Done.
575
570 int icon = model_->IsStarredMatch(match_) ? 576 int icon = model_->IsStarredMatch(match_) ?
571 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type); 577 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type);
572 if (GetState() == SELECTED && 578 if (GetState() == SELECTED) {
573 !ui::MaterialDesignController::IsModeMaterial()) {
574 switch (icon) { 579 switch (icon) {
575 case IDR_OMNIBOX_CALCULATOR: 580 case IDR_OMNIBOX_CALCULATOR:
576 icon = IDR_OMNIBOX_CALCULATOR_SELECTED; 581 icon = IDR_OMNIBOX_CALCULATOR_SELECTED;
577 break; 582 break;
578 case IDR_OMNIBOX_EXTENSION_APP: 583 case IDR_OMNIBOX_EXTENSION_APP:
579 icon = IDR_OMNIBOX_EXTENSION_APP_SELECTED; 584 icon = IDR_OMNIBOX_EXTENSION_APP_SELECTED;
580 break; 585 break;
581 case IDR_OMNIBOX_HTTP: 586 case IDR_OMNIBOX_HTTP:
582 icon = IDR_OMNIBOX_HTTP_SELECTED; 587 icon = IDR_OMNIBOX_HTTP_SELECTED;
583 break; 588 break;
584 case IDR_OMNIBOX_SEARCH: 589 case IDR_OMNIBOX_SEARCH:
585 icon = IDR_OMNIBOX_SEARCH_SELECTED; 590 icon = IDR_OMNIBOX_SEARCH_SELECTED;
586 break; 591 break;
587 case IDR_OMNIBOX_STAR: 592 case IDR_OMNIBOX_STAR:
588 icon = IDR_OMNIBOX_STAR_SELECTED; 593 icon = IDR_OMNIBOX_STAR_SELECTED;
589 break; 594 break;
590 default: 595 default:
591 NOTREACHED(); 596 NOTREACHED();
592 break; 597 break;
593 } 598 }
594 } 599 }
595 return *(location_bar_view_->GetThemeProvider()->GetImageSkiaNamed(icon)); 600 return *(location_bar_view_->GetThemeProvider()->GetImageSkiaNamed(icon));
596 } 601 }
597 602
603 gfx::ImageSkia OmniboxResultView::GetMaterialIcon() const {
604 gfx::VectorIconId icon_id = model_->IsStarredMatch(match_) ?
605 gfx::VectorIconId::OMNIBOX_STAR :
606 AutocompleteMatch::TypeToVectorIcon(match_.type);
607 return gfx::CreateVectorIcon(icon_id, 16, gfx::kChromeIconGrey);
Peter Kasting 2015/10/20 01:02:59 Using grey here will be problematic for dropdowns
Evan Stade 2015/10/20 01:12:09 I didn't even realize the dropdown could change. I
Peter Kasting 2015/10/20 01:39:18 Yes. It's supposed to use the system window color
608 }
609
598 const gfx::ImageSkia* OmniboxResultView::GetKeywordIcon() const { 610 const gfx::ImageSkia* OmniboxResultView::GetKeywordIcon() const {
599 // NOTE: If we ever begin returning icons of varying size, then callers need 611 // NOTE: If we ever begin returning icons of varying size, then callers need
600 // to ensure that |keyword_icon_| is resized each time its image is reset. 612 // to ensure that |keyword_icon_| is resized each time its image is reset.
601 int icon = IDR_OMNIBOX_TTS; 613 int icon = IDR_OMNIBOX_TTS;
602 if (GetState() == SELECTED && !ui::MaterialDesignController::IsModeMaterial()) 614 if (GetState() == SELECTED && !ui::MaterialDesignController::IsModeMaterial())
603 icon = IDR_OMNIBOX_TTS_SELECTED; 615 icon = IDR_OMNIBOX_TTS_SELECTED;
604 616
605 return location_bar_view_->GetThemeProvider()->GetImageSkiaNamed(icon); 617 return location_bar_view_->GetThemeProvider()->GetImageSkiaNamed(icon);
606 } 618 }
607 619
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 815
804 int OmniboxResultView::StartMargin() const { 816 int OmniboxResultView::StartMargin() const {
805 return ui::MaterialDesignController::IsModeMaterial() ? 817 return ui::MaterialDesignController::IsModeMaterial() ?
806 model_->start_margin() : 0; 818 model_->start_margin() : 0;
807 } 819 }
808 820
809 int OmniboxResultView::EndMargin() const { 821 int OmniboxResultView::EndMargin() const {
810 return ui::MaterialDesignController::IsModeMaterial() ? 822 return ui::MaterialDesignController::IsModeMaterial() ?
811 model_->end_margin() : 0; 823 model_->end_margin() : 0;
812 } 824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698