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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_layout_model.cc

Issue 2531223003: Expanded Autofill Credit Card Popup Layout Experiment in Android. (Closed)
Patch Set: Fix merge error in AutofillSuggestion.java Created 4 years 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) 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/popup_item_ids.h" 14 #include "components/autofill/core/browser/popup_item_ids.h"
14 #include "components/autofill/core/browser/suggestion.h" 15 #include "components/autofill/core/browser/suggestion.h"
15 #include "components/autofill/core/common/autofill_util.h" 16 #include "components/autofill/core/common/autofill_util.h"
16 #include "components/grit/components_scaled_resources.h" 17 #include "components/grit/components_scaled_resources.h"
18 #include "third_party/skia/include/core/SkColor.h"
17 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/color_palette.h" 20 #include "ui/gfx/color_palette.h"
19 #include "ui/gfx/font_list.h" 21 #include "ui/gfx/font_list.h"
20 #include "ui/gfx/geometry/rect_conversions.h" 22 #include "ui/gfx/geometry/rect_conversions.h"
21 23
22 namespace autofill { 24 namespace autofill {
23 25
24 namespace { 26 namespace {
25 27
26 // The vertical height of each row in pixels. 28 // The vertical height of each row in pixels.
(...skipping 27 matching lines...) Expand all
54 int GetRowHeightFromId(int identifier) { 56 int GetRowHeightFromId(int identifier) {
55 if (identifier == POPUP_ITEM_ID_SEPARATOR) 57 if (identifier == POPUP_ITEM_ID_SEPARATOR)
56 return kSeparatorHeight; 58 return kSeparatorHeight;
57 59
58 return kRowHeight; 60 return kRowHeight;
59 } 61 }
60 62
61 } // namespace 63 } // namespace
62 64
63 AutofillPopupLayoutModel::AutofillPopupLayoutModel( 65 AutofillPopupLayoutModel::AutofillPopupLayoutModel(
64 AutofillPopupViewDelegate* delegate) 66 AutofillPopupViewDelegate* delegate, bool is_credit_card_popup)
65 : delegate_(delegate) { 67 : delegate_(delegate), is_credit_card_popup_(is_credit_card_popup) {
66 #if !defined(OS_ANDROID) 68 #if !defined(OS_ANDROID)
67 smaller_font_list_ = 69 smaller_font_list_ =
68 normal_font_list_.DeriveWithSizeDelta(kSmallerFontSizeDelta); 70 normal_font_list_.DeriveWithSizeDelta(kSmallerFontSizeDelta);
69 bold_font_list_ = normal_font_list_.DeriveWithWeight(gfx::Font::Weight::BOLD); 71 bold_font_list_ = normal_font_list_.DeriveWithWeight(gfx::Font::Weight::BOLD);
70 #if defined(OS_MACOSX) 72 #if defined(OS_MACOSX)
71 // There is no italic version of the system font. 73 // There is no italic version of the system font.
72 warning_font_list_ = normal_font_list_; 74 warning_font_list_ = normal_font_list_;
73 #else 75 #else
74 warning_font_list_ = normal_font_list_.DeriveWithStyle(gfx::Font::ITALIC); 76 warning_font_list_ = normal_font_list_.DeriveWithStyle(gfx::Font::ITALIC);
75 #endif 77 #endif
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 result = IDR_AUTOFILL_CC_SCAN_NEW_KEYBOARD_ACCESSORY; 239 result = IDR_AUTOFILL_CC_SCAN_NEW_KEYBOARD_ACCESSORY;
238 #endif 240 #endif
239 241
240 return result; 242 return result;
241 } 243 }
242 244
243 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const { 245 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const {
244 return gfx::ToEnclosingRect(delegate_->element_bounds()); 246 return gfx::ToEnclosingRect(delegate_->element_bounds());
245 } 247 }
246 248
249 bool AutofillPopupLayoutModel::IsPopupLayoutExperimentEnabled() const {
250 return is_credit_card_popup_ &&
251 IsAutofillCreditCardPopupLayoutExperimentEnabled();
252 }
253
254 SkColor AutofillPopupLayoutModel::GetBackgroundColor() const {
255 return is_credit_card_popup_ ?
256 GetCreditCardPopupBackgroundColor() : SK_ColorTRANSPARENT;
Ilya Sherman 2016/12/03 00:02:18 Should this be checking for IsPopupLayoutExperimen
csashi 2016/12/03 00:40:07 GetCreditCardPopupBackgroundColor checks if the po
257 }
258
259 SkColor AutofillPopupLayoutModel::GetDividerColor() const {
260 return is_credit_card_popup_ ?
261 GetCreditCardPopupDividerColor() : SK_ColorTRANSPARENT;
262 }
263
264 unsigned int AutofillPopupLayoutModel::GetDropdownItemHeight() const {
265 return is_credit_card_popup_ ? GetCreditCardPopupDropdownItemHeight() : 0;
266 }
267
268 bool AutofillPopupLayoutModel::IsIconAtStart() const {
269 return is_credit_card_popup_ && IsCreditCardIconInPopupAtStart();
270 }
271
247 } // namespace autofill 272 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698