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

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

Issue 2971783002: Skeleton for showing "Show all saved passwords row" for Linux/CrOs/Windows platforms (Closed)
Patch Set: more comments adaressed Created 3 years, 5 months 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
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 ad9bd1d676f707874ef91c809544bfbe8ca8efab..fbb4007d378dbfde5833d99851c960a4c8f54cd8 100644
--- a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
@@ -150,9 +150,11 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
GetNativeTheme()->GetSystemColor(
controller_->GetBackgroundColorIDForRow(index)));
- const bool is_http_warning =
- (controller_->GetSuggestionAt(index).frontend_id ==
- POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE);
+ int current_row_frontend_id = controller_->GetSuggestionAt(index).frontend_id;
+ const bool icon_in_front_of_text_row =
vasilii 2017/07/06 15:15:21 icon_in_front_of_text?
melandory 2017/07/07 12:26:31 Done.
+ (current_row_frontend_id ==
+ POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE ||
+ current_row_frontend_id == POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY);
const bool is_rtl = controller_->IsRTL();
const int text_align =
is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
@@ -160,7 +162,7 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0);
// If the icon is on the right of the rect, no matter in RTL or LTR mode.
- bool icon_on_the_right = is_http_warning == is_rtl;
+ bool icon_on_the_right = icon_in_front_of_text_row == is_rtl;
int x_align_left = icon_on_the_right ? value_rect.right() : value_rect.x();
// Draw the Autofill icon, if one exists
@@ -176,27 +178,22 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
canvas->DrawImageInt(image, icon_x_align_left, icon_y);
// An icon was drawn; adjust the |x_align_left| value for the next element.
- if (is_http_warning) {
- x_align_left =
- icon_x_align_left +
- (is_rtl ? -AutofillPopupLayoutModel::kHttpWarningIconPadding
- : image.width() +
- AutofillPopupLayoutModel::kHttpWarningIconPadding);
- } else {
- x_align_left =
- icon_x_align_left +
- (is_rtl ? image.width() + AutofillPopupLayoutModel::kIconPadding
- : -AutofillPopupLayoutModel::kIconPadding);
- }
+ const int width_icon_padding =
+ image.width() +
+ (icon_in_front_of_text_row
+ ? AutofillPopupLayoutModel::kRightHandSideIconPapping
vasilii 2017/07/06 15:15:21 Two questions: - what is papping? - Why "right han
melandory 2017/07/07 12:26:31 mistyped padding =)
vasilii 2017/07/07 12:51:27 But the icon is actually on the left side
+ : AutofillPopupLayoutModel::kIconPadding);
+ x_align_left = x_align_left + (icon_on_the_right ? -width_icon_padding
+ : width_icon_padding);
}
- // Draw the value text
+ // Draw the value text.
const int value_width = gfx::GetStringWidth(
controller_->GetElidedValueAt(index),
controller_->layout_model().GetValueFontListForRow(index));
int value_x_align_left = x_align_left;
- if (is_http_warning) {
+ if (icon_in_front_of_text_row) {
value_x_align_left += is_rtl ? -value_width : 0;
} else {
value_x_align_left =
@@ -219,15 +216,15 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
controller_->layout_model().GetLabelFontListForRow(index));
int label_x_align_left = x_align_left;
- if (is_http_warning) {
+ if (icon_in_front_of_text_row) {
label_x_align_left =
is_rtl ? value_rect.x() : value_rect.right() - label_width;
} else {
label_x_align_left += is_rtl ? 0 : -label_width;
}
- // TODO(crbug.com/678033):Add a GetLabelFontColorForRow function similar to
- // GetValueFontColorForRow so that the cocoa impl could use it too
+ // TODO(crbug.com/678033): Add a GetLabelFontColorForRow function similar to
+ // GetValueFontColorForRow so that the cocoa impl could use it too.
canvas->DrawStringRectWithFlags(
controller_->GetElidedLabelAt(index),
controller_->layout_model().GetLabelFontListForRow(index),

Powered by Google App Engine
This is Rietveld 408576698