| Index: chrome/browser/ui/autofill/autofill_popup_layout_model.cc
|
| diff --git a/chrome/browser/ui/autofill/autofill_popup_layout_model.cc b/chrome/browser/ui/autofill/autofill_popup_layout_model.cc
|
| index 1b24397deb34abe28169891bfd150173fe235080..976def11d2e7e18834b590eb494088b5dcf6390d 100644
|
| --- a/chrome/browser/ui/autofill/autofill_popup_layout_model.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_popup_layout_model.cc
|
| @@ -10,10 +10,12 @@
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/ui/autofill/autofill_popup_view.h"
|
| #include "chrome/browser/ui/autofill/popup_constants.h"
|
| +#include "components/autofill/core/browser/autofill_experiments.h"
|
| #include "components/autofill/core/browser/popup_item_ids.h"
|
| #include "components/autofill/core/browser/suggestion.h"
|
| #include "components/autofill/core/common/autofill_util.h"
|
| #include "components/grit/components_scaled_resources.h"
|
| +#include "third_party/skia/include/core/SkColor.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/gfx/color_palette.h"
|
| #include "ui/gfx/font_list.h"
|
| @@ -34,10 +36,12 @@ const size_t kSeparatorHeight = 1;
|
| const int kSmallerFontSizeDelta = -1;
|
| #endif
|
|
|
| -const struct {
|
| +struct data_resource {
|
| const char* name;
|
| int id;
|
| -} kDataResources[] = {
|
| +};
|
| +
|
| +static const data_resource kDataResources[] = {
|
| {"americanExpressCC", IDR_AUTOFILL_CC_AMEX},
|
| {"dinersCC", IDR_AUTOFILL_CC_GENERIC},
|
| {"discoverCC", IDR_AUTOFILL_CC_DISCOVER},
|
| @@ -51,6 +55,20 @@ const struct {
|
| #endif
|
| };
|
|
|
| +static const data_resource kLargeDataResources[] = {
|
| + {"americanExpressCC", IDR_AUTOFILL_LARGE_CC_AMEX},
|
| + {"dinersCC", IDR_AUTOFILL_LARGE_CC_GENERIC},
|
| + {"discoverCC", IDR_AUTOFILL_LARGE_CC_DISCOVER},
|
| + {"genericCC", IDR_AUTOFILL_LARGE_CC_GENERIC},
|
| + {"jcbCC", IDR_AUTOFILL_LARGE_CC_GENERIC},
|
| + {"masterCardCC", IDR_AUTOFILL_LARGE_CC_MASTERCARD},
|
| + {"visaCC", IDR_AUTOFILL_LARGE_CC_VISA},
|
| +#if defined(OS_ANDROID)
|
| + {"scanCreditCardIcon", IDR_AUTOFILL_CC_SCAN_NEW},
|
| + {"settings", IDR_AUTOFILL_SETTINGS},
|
| +#endif
|
| +};
|
| +
|
| int GetRowHeightFromId(int identifier) {
|
| if (identifier == POPUP_ITEM_ID_SEPARATOR)
|
| return kSeparatorHeight;
|
| @@ -61,8 +79,8 @@ int GetRowHeightFromId(int identifier) {
|
| } // namespace
|
|
|
| AutofillPopupLayoutModel::AutofillPopupLayoutModel(
|
| - AutofillPopupViewDelegate* delegate)
|
| - : delegate_(delegate) {
|
| + AutofillPopupViewDelegate* delegate, bool is_credit_card_field)
|
| + : delegate_(delegate), is_credit_card_field_(is_credit_card_field) {
|
| #if !defined(OS_ANDROID)
|
| smaller_font_list_ =
|
| normal_font_list_.DeriveWithSizeDelta(kSmallerFontSizeDelta);
|
| @@ -225,9 +243,15 @@ gfx::Rect AutofillPopupLayoutModel::GetRowBounds(size_t index) const {
|
| int AutofillPopupLayoutModel::GetIconResourceID(
|
| const base::string16& resource_name) const {
|
| int result = -1;
|
| - for (size_t i = 0; i < arraysize(kDataResources); ++i) {
|
| - if (resource_name == base::ASCIIToUTF16(kDataResources[i].name)) {
|
| - result = kDataResources[i].id;
|
| + const bool is_popup_layout_experiment_enabled =
|
| + IsPopupLayoutExperimentEnabled();
|
| + const size_t num_data_resources = is_popup_layout_experiment_enabled ?
|
| + arraysize(kLargeDataResources) : arraysize(kDataResources);
|
| + const data_resource *resources =
|
| + is_popup_layout_experiment_enabled ? kLargeDataResources : kDataResources;
|
| + for (size_t i = 0; i < num_data_resources; ++i) {
|
| + if (resource_name == base::ASCIIToUTF16(resources[i].name)) {
|
| + result = resources[i].id;
|
| break;
|
| }
|
| }
|
| @@ -244,4 +268,27 @@ const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const {
|
| return gfx::ToEnclosingRect(delegate_->element_bounds());
|
| }
|
|
|
| +bool AutofillPopupLayoutModel::IsPopupLayoutExperimentEnabled() const {
|
| + return is_credit_card_field_ ?
|
| + IsAutofillCreditCardPopupLayoutExperimentEnabled() : false;
|
| +}
|
| +
|
| +SkColor AutofillPopupLayoutModel::GetBackgroundColor() const {
|
| + return is_credit_card_field_ ?
|
| + GetCreditCardPopupBackgroundColor() : SK_ColorTRANSPARENT;
|
| +}
|
| +
|
| +SkColor AutofillPopupLayoutModel::GetDividerColor() const {
|
| + return is_credit_card_field_ ?
|
| + GetCreditCardPopupDividerColor() : SK_ColorTRANSPARENT;
|
| +}
|
| +
|
| +int AutofillPopupLayoutModel::GetDropdownItemHeight() const {
|
| + return is_credit_card_field_ ? GetCreditCardPopupDropdownItemHeight() : -1;
|
| +}
|
| +
|
| +bool AutofillPopupLayoutModel::IsIconAtLeft() const {
|
| + return is_credit_card_field_ ? IsCreditCardIconInPopupAtLeft() : -1;
|
| +}
|
| +
|
| } // namespace autofill
|
|
|