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

Unified Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 772253003: Create an autofill Suggestion class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm ('k') | components/autofill.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
index 71fb41a030bcafecda1a87ebd1929ee325ef9b13..0b37edd28caeba1a7107346085737f36557bc883 100644
--- a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "components/autofill/core/browser/popup_item_ids.h"
+#include "components/autofill/core/browser/suggestion.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
@@ -48,10 +49,11 @@ void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
canvas->DrawColor(kPopupBackground);
OnPaintBorder(canvas);
- for (size_t i = 0; i < controller_->names().size(); ++i) {
+ for (size_t i = 0; i < controller_->GetLineCount(); ++i) {
gfx::Rect line_rect = controller_->GetRowBounds(i);
- if (controller_->identifiers()[i] == POPUP_ITEM_ID_SEPARATOR) {
+ if (controller_->GetSuggestionAt(i).frontend_id ==
+ POPUP_ITEM_ID_SEPARATOR) {
canvas->FillRect(line_rect, kItemTextColor);
} else {
DrawAutofillEntry(canvas, i, line_rect);
@@ -71,14 +73,14 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
const bool is_rtl = controller_->IsRTL();
const int value_text_width =
- gfx::GetStringWidth(controller_->names()[index],
- controller_->GetNameFontListForRow(index));
+ gfx::GetStringWidth(controller_->GetElidedValueAt(index),
+ controller_->GetValueFontListForRow(index));
const int value_content_x = is_rtl ?
entry_rect.width() - value_text_width - kEndPadding : kEndPadding;
canvas->DrawStringRectWithFlags(
- controller_->names()[index],
- controller_->GetNameFontListForRow(index),
+ controller_->GetElidedValueAt(index),
+ controller_->GetValueFontListForRow(index),
controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor,
gfx::Rect(value_content_x,
entry_rect.y(),
@@ -92,8 +94,9 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
// Draw the Autofill icon, if one exists
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
int row_height = controller_->GetRowBounds(index).height();
- if (!controller_->icons()[index].empty()) {
- int icon = controller_->GetIconResourceID(controller_->icons()[index]);
+ if (!controller_->GetSuggestionAt(index).icon.empty()) {
+ int icon = controller_->GetIconResourceID(
+ controller_->GetSuggestionAt(index).icon);
DCHECK_NE(-1, icon);
const gfx::ImageSkia* image = rb.GetImageSkiaNamed(icon);
int icon_y = entry_rect.y() + (row_height - image->height()) / 2;
@@ -105,20 +108,20 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
x_align_left += is_rtl ? image->width() + kIconPadding : -kIconPadding;
}
- // Draw the name text.
- const int subtext_width =
- gfx::GetStringWidth(controller_->subtexts()[index],
- controller_->subtext_font_list());
+ // Draw the label text.
+ const int label_width =
+ gfx::GetStringWidth(controller_->GetElidedLabelAt(index),
+ controller_->GetLabelFontList());
if (!is_rtl)
- x_align_left -= subtext_width;
+ x_align_left -= label_width;
canvas->DrawStringRectWithFlags(
- controller_->subtexts()[index],
- controller_->subtext_font_list(),
+ controller_->GetElidedLabelAt(index),
+ controller_->GetLabelFontList(),
kItemTextColor,
gfx::Rect(x_align_left,
entry_rect.y(),
- subtext_width,
+ label_width,
entry_rect.height()),
gfx::Canvas::TEXT_ALIGN_CENTER);
}
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm ('k') | components/autofill.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698