2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
- #include " content/nw/src/browser /autofill_popup_view_views.h"
5
+ #include " chrome/browser/ui/views/autofill /autofill_popup_view_views.h"
6
6
7
- #include " content/nw/src/browser /autofill_popup_controller.h"
7
+ #include " chrome/browser/ui/autofill /autofill_popup_controller.h"
8
8
#include " components/autofill/core/browser/popup_item_ids.h"
9
+ #include " components/autofill/core/browser/suggestion.h"
9
10
#include " ui/base/resource/resource_bundle.h"
10
11
#include " ui/events/keycodes/keyboard_codes.h"
11
12
#include " ui/gfx/canvas.h"
12
- #include " ui/gfx/image/image.h"
13
- #include " ui/gfx/native_widget_types.h"
14
13
#include " ui/gfx/geometry/point.h"
15
14
#include " ui/gfx/geometry/rect.h"
15
+ #include " ui/gfx/image/image.h"
16
+ #include " ui/gfx/native_widget_types.h"
16
17
#include " ui/gfx/text_utils.h"
17
18
#include " ui/views/border.h"
18
19
#include " ui/views/widget/widget.h"
@@ -48,10 +49,11 @@ void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
48
49
canvas->DrawColor (kPopupBackground );
49
50
OnPaintBorder (canvas);
50
51
51
- for (size_t i = 0 ; i < controller_->names (). size (); ++i) {
52
+ for (size_t i = 0 ; i < controller_->GetLineCount (); ++i) {
52
53
gfx::Rect line_rect = controller_->GetRowBounds (i);
53
54
54
- if (controller_->identifiers ()[i] == POPUP_ITEM_ID_SEPARATOR) {
55
+ if (controller_->GetSuggestionAt (i).frontend_id ==
56
+ POPUP_ITEM_ID_SEPARATOR) {
55
57
canvas->FillRect (line_rect, kItemTextColor );
56
58
} else {
57
59
DrawAutofillEntry (canvas, i, line_rect);
@@ -71,14 +73,14 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
71
73
72
74
const bool is_rtl = controller_->IsRTL ();
73
75
const int value_text_width =
74
- gfx::GetStringWidth (controller_->names ()[ index] ,
75
- controller_->GetNameFontListForRow (index));
76
+ gfx::GetStringWidth (controller_->GetElidedValueAt ( index) ,
77
+ controller_->GetValueFontListForRow (index));
76
78
const int value_content_x = is_rtl ?
77
79
entry_rect.width () - value_text_width - kEndPadding : kEndPadding ;
78
80
79
81
canvas->DrawStringRectWithFlags (
80
- controller_->names ()[ index] ,
81
- controller_->GetNameFontListForRow (index),
82
+ controller_->GetElidedValueAt ( index) ,
83
+ controller_->GetValueFontListForRow (index),
82
84
controller_->IsWarning (index) ? kWarningTextColor : kValueTextColor ,
83
85
gfx::Rect (value_content_x,
84
86
entry_rect.y (),
@@ -92,8 +94,9 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
92
94
// Draw the Autofill icon, if one exists
93
95
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance ();
94
96
int row_height = controller_->GetRowBounds (index).height ();
95
- if (!controller_->icons ()[index].empty ()) {
96
- int icon = controller_->GetIconResourceID (controller_->icons ()[index]);
97
+ if (!controller_->GetSuggestionAt (index).icon .empty ()) {
98
+ int icon = controller_->GetIconResourceID (
99
+ controller_->GetSuggestionAt (index).icon );
97
100
DCHECK_NE (-1 , icon);
98
101
const gfx::ImageSkia* image = rb.GetImageSkiaNamed (icon);
99
102
int icon_y = entry_rect.y () + (row_height - image->height ()) / 2 ;
@@ -105,20 +108,20 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
105
108
x_align_left += is_rtl ? image->width () + kIconPadding : -kIconPadding ;
106
109
}
107
110
108
- // Draw the name text.
109
- const int subtext_width =
110
- gfx::GetStringWidth (controller_->subtexts ()[ index] ,
111
- controller_->subtext_font_list ());
111
+ // Draw the label text.
112
+ const int label_width =
113
+ gfx::GetStringWidth (controller_->GetElidedLabelAt ( index) ,
114
+ controller_->GetLabelFontList ());
112
115
if (!is_rtl)
113
- x_align_left -= subtext_width ;
116
+ x_align_left -= label_width ;
114
117
115
118
canvas->DrawStringRectWithFlags (
116
- controller_->subtexts ()[ index] ,
117
- controller_->subtext_font_list (),
119
+ controller_->GetElidedLabelAt ( index) ,
120
+ controller_->GetLabelFontList (),
118
121
kItemTextColor ,
119
122
gfx::Rect (x_align_left,
120
123
entry_rect.y (),
121
- subtext_width ,
124
+ label_width ,
122
125
entry_rect.height ()),
123
126
gfx::Canvas::TEXT_ALIGN_CENTER);
124
127
}
0 commit comments