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

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: add gyp dependency 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
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_result_view.h ('k') | components/omnibox.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 gfx::VectorIconId icon_id = model_->IsStarredMatch(match_) ?
575 gfx::VectorIconId::OMNIBOX_STAR :
576 AutocompleteMatch::TypeToVectorIcon(match_.type);
577 return gfx::CreateVectorIcon(icon_id, 16, gfx::kChromeIconGrey);
578 }
579
570 int icon = model_->IsStarredMatch(match_) ? 580 int icon = model_->IsStarredMatch(match_) ?
571 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type); 581 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type);
572 if (GetState() == SELECTED && 582 if (GetState() == SELECTED) {
573 !ui::MaterialDesignController::IsModeMaterial()) {
574 switch (icon) { 583 switch (icon) {
575 case IDR_OMNIBOX_CALCULATOR: 584 case IDR_OMNIBOX_CALCULATOR:
576 icon = IDR_OMNIBOX_CALCULATOR_SELECTED; 585 icon = IDR_OMNIBOX_CALCULATOR_SELECTED;
577 break; 586 break;
578 case IDR_OMNIBOX_EXTENSION_APP: 587 case IDR_OMNIBOX_EXTENSION_APP:
579 icon = IDR_OMNIBOX_EXTENSION_APP_SELECTED; 588 icon = IDR_OMNIBOX_EXTENSION_APP_SELECTED;
580 break; 589 break;
581 case IDR_OMNIBOX_HTTP: 590 case IDR_OMNIBOX_HTTP:
582 icon = IDR_OMNIBOX_HTTP_SELECTED; 591 icon = IDR_OMNIBOX_HTTP_SELECTED;
583 break; 592 break;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 812
804 int OmniboxResultView::StartMargin() const { 813 int OmniboxResultView::StartMargin() const {
805 return ui::MaterialDesignController::IsModeMaterial() ? 814 return ui::MaterialDesignController::IsModeMaterial() ?
806 model_->start_margin() : 0; 815 model_->start_margin() : 0;
807 } 816 }
808 817
809 int OmniboxResultView::EndMargin() const { 818 int OmniboxResultView::EndMargin() const {
810 return ui::MaterialDesignController::IsModeMaterial() ? 819 return ui::MaterialDesignController::IsModeMaterial() ?
811 model_->end_margin() : 0; 820 model_->end_margin() : 0;
812 } 821 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_result_view.h ('k') | components/omnibox.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698