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

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: Fixes compile error. 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/color_utils.h" 21 #include "ui/gfx/color_utils.h"
20 #include "ui/gfx/font_list.h" 22 #include "ui/gfx/font_list.h"
21 #include "ui/gfx/geometry/rect_conversions.h" 23 #include "ui/gfx/geometry/rect_conversions.h"
22 #include "ui/gfx/image/image_skia.h" 24 #include "ui/gfx/image/image_skia.h"
23 #include "ui/gfx/paint_vector_icon.h" 25 #include "ui/gfx/paint_vector_icon.h"
24 #include "ui/gfx/vector_icons_public.h" 26 #include "ui/gfx/vector_icons_public.h"
25 27
26 namespace autofill { 28 namespace autofill {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 int GetRowHeightFromId(int identifier) { 65 int GetRowHeightFromId(int identifier) {
64 if (identifier == POPUP_ITEM_ID_SEPARATOR) 66 if (identifier == POPUP_ITEM_ID_SEPARATOR)
65 return kSeparatorHeight; 67 return kSeparatorHeight;
66 68
67 return kRowHeight; 69 return kRowHeight;
68 } 70 }
69 71
70 } // namespace 72 } // namespace
71 73
72 AutofillPopupLayoutModel::AutofillPopupLayoutModel( 74 AutofillPopupLayoutModel::AutofillPopupLayoutModel(
73 AutofillPopupViewDelegate* delegate) 75 AutofillPopupViewDelegate* delegate, bool is_credit_card_popup)
74 : delegate_(delegate) { 76 : delegate_(delegate), is_credit_card_popup_(is_credit_card_popup) {
75 #if !defined(OS_ANDROID) 77 #if !defined(OS_ANDROID)
76 smaller_font_list_ = 78 smaller_font_list_ =
77 normal_font_list_.DeriveWithSizeDelta(kSmallerFontSizeDelta); 79 normal_font_list_.DeriveWithSizeDelta(kSmallerFontSizeDelta);
78 bold_font_list_ = normal_font_list_.DeriveWithWeight(gfx::Font::Weight::BOLD); 80 bold_font_list_ = normal_font_list_.DeriveWithWeight(gfx::Font::Weight::BOLD);
79 #if defined(OS_MACOSX) 81 #if defined(OS_MACOSX)
80 // There is no italic version of the system font. 82 // There is no italic version of the system font.
81 warning_font_list_ = normal_font_list_; 83 warning_font_list_ = normal_font_list_;
82 #else 84 #else
83 warning_font_list_ = normal_font_list_.DeriveWithStyle(gfx::Font::ITALIC); 85 warning_font_list_ = normal_font_list_.DeriveWithStyle(gfx::Font::ITALIC);
84 #endif 86 #endif
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 result = IDR_AUTOFILL_CC_SCAN_NEW_KEYBOARD_ACCESSORY; 277 result = IDR_AUTOFILL_CC_SCAN_NEW_KEYBOARD_ACCESSORY;
276 #endif 278 #endif
277 279
278 return result; 280 return result;
279 } 281 }
280 282
281 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const { 283 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const {
282 return gfx::ToEnclosingRect(delegate_->element_bounds()); 284 return gfx::ToEnclosingRect(delegate_->element_bounds());
283 } 285 }
284 286
287 bool AutofillPopupLayoutModel::IsPopupLayoutExperimentEnabled() const {
288 return is_credit_card_popup_ &&
289 IsAutofillCreditCardPopupLayoutExperimentEnabled();
290 }
291
292 SkColor AutofillPopupLayoutModel::GetBackgroundColor() const {
293 return is_credit_card_popup_ ?
294 GetCreditCardPopupBackgroundColor() : SK_ColorTRANSPARENT;
295 }
296
297 SkColor AutofillPopupLayoutModel::GetDividerColor() const {
298 return is_credit_card_popup_ ?
299 GetCreditCardPopupDividerColor() : SK_ColorTRANSPARENT;
300 }
301
302 unsigned int AutofillPopupLayoutModel::GetDropdownItemHeight() const {
303 return GetPopupDropdownItemHeight();
304 }
305
306 bool AutofillPopupLayoutModel::IsIconAtStart(int frontend_id) const {
307 return frontend_id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE ||
308 (is_credit_card_popup_ && IsIconInCreditCardPopupAtStart());
309 }
310
285 } // namespace autofill 311 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698