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

Side by Side 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: . 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/autofill/autofill_popup_view_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
6 6
7 #include "base/optional.h" 7 #include "base/optional.h"
8 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 8 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
9 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" 9 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 * stored autofill info and check for credit card or password forms. 143 * stored autofill info and check for credit card or password forms.
144 */ 144 */
145 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas, 145 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
146 int index, 146 int index,
147 const gfx::Rect& entry_rect) { 147 const gfx::Rect& entry_rect) {
148 canvas->FillRect( 148 canvas->FillRect(
149 entry_rect, 149 entry_rect,
150 GetNativeTheme()->GetSystemColor( 150 GetNativeTheme()->GetSystemColor(
151 controller_->GetBackgroundColorIDForRow(index))); 151 controller_->GetBackgroundColorIDForRow(index)));
152 152
153 const bool is_http_warning = 153 int current_row_frontend_id = controller_->GetSuggestionAt(index).frontend_id;
Evan Stade 2017/07/13 16:48:43 same nits as before: const int and no "current_row
melandory 2017/07/25 15:08:50 Done.
154 (controller_->GetSuggestionAt(index).frontend_id == 154 const bool is_http_warning = (current_row_frontend_id ==
155 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE); 155 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE);
156 const bool icon_in_front_of_text =
157 (is_http_warning ||
158 current_row_frontend_id == POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY);
156 const bool is_rtl = controller_->IsRTL(); 159 const bool is_rtl = controller_->IsRTL();
157 const int text_align = 160 const int text_align =
158 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT; 161 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
159 gfx::Rect value_rect = entry_rect; 162 gfx::Rect value_rect = entry_rect;
160 value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0); 163 value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0);
161 164
162 // If the icon is on the right of the rect, no matter in RTL or LTR mode. 165 // If the icon is on the right of the rect, no matter in RTL or LTR mode.
163 bool icon_on_the_right = is_http_warning == is_rtl; 166 bool icon_on_the_right = icon_in_front_of_text == is_rtl;
164 int x_align_left = icon_on_the_right ? value_rect.right() : value_rect.x(); 167 int x_align_left = icon_on_the_right ? value_rect.right() : value_rect.x();
165 168
166 // Draw the Autofill icon, if one exists 169 // Draw the Autofill icon, if one exists
167 int row_height = controller_->layout_model().GetRowBounds(index).height(); 170 int row_height = controller_->layout_model().GetRowBounds(index).height();
168 if (!controller_->GetSuggestionAt(index).icon.empty()) { 171 if (!controller_->GetSuggestionAt(index).icon.empty()) {
169 const gfx::ImageSkia image = 172 const gfx::ImageSkia image =
170 controller_->layout_model().GetIconImage(index); 173 controller_->layout_model().GetIconImage(index);
171 int icon_y = entry_rect.y() + (row_height - image.height()) / 2; 174 int icon_y = entry_rect.y() + (row_height - image.height()) / 2;
172 175
173 int icon_x_align_left = 176 int icon_x_align_left =
174 icon_on_the_right ? x_align_left - image.width() : x_align_left; 177 icon_on_the_right ? x_align_left - image.width() : x_align_left;
175 178
176 canvas->DrawImageInt(image, icon_x_align_left, icon_y); 179 canvas->DrawImageInt(image, icon_x_align_left, icon_y);
177 180
178 // An icon was drawn; adjust the |x_align_left| value for the next element. 181 // An icon was drawn; adjust the |x_align_left| value for the next element.
179 if (is_http_warning) { 182 if (icon_in_front_of_text) {
180 x_align_left = 183 x_align_left =
181 icon_x_align_left + 184 icon_x_align_left +
182 (is_rtl ? -AutofillPopupLayoutModel::kHttpWarningIconPadding 185 (is_rtl
183 : image.width() + 186 ? -AutofillPopupLayoutModel::kPaddingBetweenLeftSideIconAndText
Evan Stade 2017/07/13 16:48:43 nit: can we rename kPaddingBetweenLeftSideIconAndT
melandory 2017/07/25 15:08:50 Done.
184 AutofillPopupLayoutModel::kHttpWarningIconPadding); 187 : image.width() + AutofillPopupLayoutModel::
188 kPaddingBetweenLeftSideIconAndText);
185 } else { 189 } else {
186 x_align_left = 190 x_align_left =
187 icon_x_align_left + 191 icon_x_align_left +
188 (is_rtl ? image.width() + AutofillPopupLayoutModel::kIconPadding 192 (is_rtl ? image.width() + AutofillPopupLayoutModel::kIconPadding
189 : -AutofillPopupLayoutModel::kIconPadding); 193 : -AutofillPopupLayoutModel::kIconPadding);
190 } 194 }
191 } 195 }
192 196
193 // Draw the value text 197 // Draw the value text
194 const int value_width = gfx::GetStringWidth( 198 const int value_width = gfx::GetStringWidth(
195 controller_->GetElidedValueAt(index), 199 controller_->GetElidedValueAt(index),
196 controller_->layout_model().GetValueFontListForRow(index)); 200 controller_->layout_model().GetValueFontListForRow(index));
197 int value_x_align_left = x_align_left; 201 int value_x_align_left = x_align_left;
198 202
199 if (is_http_warning) { 203 if (icon_in_front_of_text) {
200 value_x_align_left += is_rtl ? -value_width : 0; 204 value_x_align_left += is_rtl ? -value_width : 0;
201 } else { 205 } else {
202 value_x_align_left = 206 value_x_align_left =
203 is_rtl ? value_rect.right() - value_width : value_rect.x(); 207 is_rtl ? value_rect.right() - value_width : value_rect.x();
204 } 208 }
205 209
206 canvas->DrawStringRectWithFlags( 210 canvas->DrawStringRectWithFlags(
207 controller_->GetElidedValueAt(index), 211 controller_->GetElidedValueAt(index),
208 controller_->layout_model().GetValueFontListForRow(index), 212 controller_->layout_model().GetValueFontListForRow(index),
209 GetNativeTheme()->GetSystemColor( 213 GetNativeTheme()->GetSystemColor(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 265
262 // If the top level widget can't be found, cancel the popup since we can't 266 // If the top level widget can't be found, cancel the popup since we can't
263 // fully set it up. 267 // fully set it up.
264 if (!observing_widget) 268 if (!observing_widget)
265 return NULL; 269 return NULL;
266 270
267 return new AutofillPopupViewViews(controller, observing_widget); 271 return new AutofillPopupViewViews(controller, observing_widget);
268 } 272 }
269 273
270 } // namespace autofill 274 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698