| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/ui/autofill/autofill_popup_layout_model.h" | 5 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 11 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| 12 #include "chrome/browser/ui/autofill/popup_constants.h" | 12 #include "chrome/browser/ui/autofill/popup_constants.h" |
| 13 #include "components/autofill/core/browser/autofill_experiments.h" | 13 #include "components/autofill/core/browser/autofill_experiments.h" |
| 14 #include "components/autofill/core/browser/popup_item_ids.h" | 14 #include "components/autofill/core/browser/popup_item_ids.h" |
| 15 #include "components/autofill/core/browser/suggestion.h" | 15 #include "components/autofill/core/browser/suggestion.h" |
| 16 #include "components/autofill/core/common/autofill_util.h" | 16 #include "components/autofill/core/common/autofill_util.h" |
| 17 #include "components/grit/components_scaled_resources.h" | 17 #include "components/grit/components_scaled_resources.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/color_palette.h" | 20 #include "ui/gfx/color_palette.h" |
| 21 #include "ui/gfx/color_utils.h" | 21 #include "ui/gfx/color_utils.h" |
| 22 #include "ui/gfx/font_list.h" | 22 #include "ui/gfx/font_list.h" |
| 23 #include "ui/gfx/geometry/rect_conversions.h" | 23 #include "ui/gfx/geometry/rect_conversions.h" |
| 24 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
| 25 #include "ui/gfx/paint_vector_icon.h" | 25 #include "ui/gfx/paint_vector_icon.h" |
| 26 #include "ui/gfx/vector_icons_public.h" | 26 |
| 27 #if !defined(OS_ANDROID) |
| 28 #include "components/toolbar/vector_icons.h" // nogncheck |
| 29 #endif |
| 27 | 30 |
| 28 namespace autofill { | 31 namespace autofill { |
| 29 | 32 |
| 30 namespace { | 33 namespace { |
| 31 | 34 |
| 32 // The vertical height of each row in pixels. | 35 // The vertical height of each row in pixels. |
| 33 const size_t kRowHeight = 24; | 36 const size_t kRowHeight = 24; |
| 34 | 37 |
| 35 // The vertical height of a separator in pixels. | 38 // The vertical height of a separator in pixels. |
| 36 const size_t kSeparatorHeight = 1; | 39 const size_t kSeparatorHeight = 1; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return ui::NativeTheme::kColorId_ResultsTableNormalDimmedText; | 204 return ui::NativeTheme::kColorId_ResultsTableNormalDimmedText; |
| 202 default: | 205 default: |
| 203 return ui::NativeTheme::kColorId_ResultsTableNormalText; | 206 return ui::NativeTheme::kColorId_ResultsTableNormalText; |
| 204 } | 207 } |
| 205 } | 208 } |
| 206 | 209 |
| 207 gfx::ImageSkia AutofillPopupLayoutModel::GetIconImage(size_t index) const { | 210 gfx::ImageSkia AutofillPopupLayoutModel::GetIconImage(size_t index) const { |
| 208 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); | 211 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); |
| 209 const base::string16& icon_str = suggestions[index].icon; | 212 const base::string16& icon_str = suggestions[index].icon; |
| 210 | 213 |
| 211 // For http warning message, get icon images from VectorIconId, which is the | 214 // For http warning message, get icon images from VectorIcon, which is the |
| 212 // same as security indicator icons in location bar. | 215 // same as security indicator icons in location bar. |
| 213 if (suggestions[index].frontend_id == | 216 if (suggestions[index].frontend_id == |
| 214 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) { | 217 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) { |
| 215 if (icon_str == base::ASCIIToUTF16("httpWarning")) { | 218 if (icon_str == base::ASCIIToUTF16("httpWarning")) { |
| 216 return gfx::CreateVectorIcon(gfx::VectorIconId::LOCATION_BAR_HTTP, | 219 return gfx::CreateVectorIcon(toolbar::kHttpIcon, kHttpWarningIconWidth, |
| 217 kHttpWarningIconWidth, gfx::kChromeIconGrey); | 220 gfx::kChromeIconGrey); |
| 218 } | 221 } |
| 219 DCHECK_EQ(icon_str, base::ASCIIToUTF16("httpsInvalid")); | 222 DCHECK_EQ(icon_str, base::ASCIIToUTF16("httpsInvalid")); |
| 220 return gfx::CreateVectorIcon(gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID, | 223 return gfx::CreateVectorIcon(toolbar::kHttpsInvalidIcon, |
| 221 kHttpWarningIconWidth, gfx::kGoogleRed700); | 224 kHttpWarningIconWidth, gfx::kGoogleRed700); |
| 222 } | 225 } |
| 223 | 226 |
| 224 // For other suggestion entries, get icon from PNG files. | 227 // For other suggestion entries, get icon from PNG files. |
| 225 int icon_id = GetIconResourceID(icon_str); | 228 int icon_id = GetIconResourceID(icon_str); |
| 226 DCHECK_NE(-1, icon_id); | 229 DCHECK_NE(-1, icon_id); |
| 227 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id); | 230 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id); |
| 228 } | 231 } |
| 229 #endif | 232 #endif |
| 230 | 233 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 unsigned int AutofillPopupLayoutModel::GetDropdownItemHeight() const { | 294 unsigned int AutofillPopupLayoutModel::GetDropdownItemHeight() const { |
| 292 return GetPopupDropdownItemHeight(); | 295 return GetPopupDropdownItemHeight(); |
| 293 } | 296 } |
| 294 | 297 |
| 295 bool AutofillPopupLayoutModel::IsIconAtStart(int frontend_id) const { | 298 bool AutofillPopupLayoutModel::IsIconAtStart(int frontend_id) const { |
| 296 return frontend_id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE || | 299 return frontend_id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE || |
| 297 (is_credit_card_popup_ && IsIconInCreditCardPopupAtStart()); | 300 (is_credit_card_popup_ && IsIconInCreditCardPopupAtStart()); |
| 298 } | 301 } |
| 299 | 302 |
| 300 } // namespace autofill | 303 } // namespace autofill |
| OLD | NEW |