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

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: more tests 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;
154 (controller_->GetSuggestionAt(index).frontend_id == 154 const bool is_icon_in_front_of_text_row =
155 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE); 155 (current_row_frontend_id ==
156 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE ||
157 current_row_frontend_id == POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY);
156 const bool is_rtl = controller_->IsRTL(); 158 const bool is_rtl = controller_->IsRTL();
157 const int text_align = 159 const int text_align =
158 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT; 160 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
159 gfx::Rect value_rect = entry_rect; 161 gfx::Rect value_rect = entry_rect;
160 value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0); 162 value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0);
161 163
162 // If the icon is on the right of the rect, no matter in RTL or LTR mode. 164 // 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; 165 bool icon_on_the_right = is_icon_in_front_of_text_row == is_rtl;
164 int x_align_left = icon_on_the_right ? value_rect.right() : value_rect.x(); 166 int x_align_left = icon_on_the_right ? value_rect.right() : value_rect.x();
165 167
166 // Draw the Autofill icon, if one exists 168 // Draw the Autofill icon, if one exists
167 int row_height = controller_->layout_model().GetRowBounds(index).height(); 169 int row_height = controller_->layout_model().GetRowBounds(index).height();
168 if (!controller_->GetSuggestionAt(index).icon.empty()) { 170 if (!controller_->GetSuggestionAt(index).icon.empty()) {
169 const gfx::ImageSkia image = 171 const gfx::ImageSkia image =
170 controller_->layout_model().GetIconImage(index); 172 controller_->layout_model().GetIconImage(index);
171 int icon_y = entry_rect.y() + (row_height - image.height()) / 2; 173 int icon_y = entry_rect.y() + (row_height - image.height()) / 2;
172 174
173 int icon_x_align_left = 175 int icon_x_align_left =
174 icon_on_the_right ? x_align_left - image.width() : x_align_left; 176 icon_on_the_right ? x_align_left - image.width() : x_align_left;
175 177
176 canvas->DrawImageInt(image, icon_x_align_left, icon_y); 178 canvas->DrawImageInt(image, icon_x_align_left, icon_y);
177 179
178 // An icon was drawn; adjust the |x_align_left| value for the next element. 180 // An icon was drawn; adjust the |x_align_left| value for the next element.
179 if (is_http_warning) { 181 if (is_icon_in_front_of_text_row) {
vasilii 2017/07/05 17:12:15 Here something strange is going on. - Do you want
melandory 2017/07/06 13:50:10 Yep, deliberately. Renamed.
180 x_align_left = 182 x_align_left =
181 icon_x_align_left + 183 icon_x_align_left +
182 (is_rtl ? -AutofillPopupLayoutModel::kHttpWarningIconPadding 184 (is_rtl ? -AutofillPopupLayoutModel::kHttpWarningIconPadding
183 : image.width() + 185 : image.width() +
184 AutofillPopupLayoutModel::kHttpWarningIconPadding); 186 AutofillPopupLayoutModel::kHttpWarningIconPadding);
185 } else { 187 } else {
186 x_align_left = 188 x_align_left =
187 icon_x_align_left + 189 icon_x_align_left +
188 (is_rtl ? image.width() + AutofillPopupLayoutModel::kIconPadding 190 (is_rtl ? image.width() + AutofillPopupLayoutModel::kIconPadding
189 : -AutofillPopupLayoutModel::kIconPadding); 191 : -AutofillPopupLayoutModel::kIconPadding);
190 } 192 }
191 } 193 }
192 194
193 // Draw the value text 195 // Draw the value text
194 const int value_width = gfx::GetStringWidth( 196 const int value_width = gfx::GetStringWidth(
195 controller_->GetElidedValueAt(index), 197 controller_->GetElidedValueAt(index),
196 controller_->layout_model().GetValueFontListForRow(index)); 198 controller_->layout_model().GetValueFontListForRow(index));
197 int value_x_align_left = x_align_left; 199 int value_x_align_left = x_align_left;
198 200
199 if (is_http_warning) { 201 if (is_icon_in_front_of_text_row) {
vasilii 2017/07/05 17:12:15 Is |is_icon_in_front_of_text_row| saying "there is
melandory 2017/07/06 13:50:10 Done.
200 value_x_align_left += is_rtl ? -value_width : 0; 202 value_x_align_left += is_rtl ? -value_width : 0;
201 } else { 203 } else {
202 value_x_align_left = 204 value_x_align_left =
203 is_rtl ? value_rect.right() - value_width : value_rect.x(); 205 is_rtl ? value_rect.right() - value_width : value_rect.x();
204 } 206 }
205 207
206 canvas->DrawStringRectWithFlags( 208 canvas->DrawStringRectWithFlags(
207 controller_->GetElidedValueAt(index), 209 controller_->GetElidedValueAt(index),
208 controller_->layout_model().GetValueFontListForRow(index), 210 controller_->layout_model().GetValueFontListForRow(index),
209 GetNativeTheme()->GetSystemColor( 211 GetNativeTheme()->GetSystemColor(
210 controller_->layout_model().GetValueFontColorIDForRow(index)), 212 controller_->layout_model().GetValueFontColorIDForRow(index)),
211 gfx::Rect(value_x_align_left, value_rect.y(), value_width, 213 gfx::Rect(value_x_align_left, value_rect.y(), value_width,
212 value_rect.height()), 214 value_rect.height()),
213 text_align); 215 text_align);
214 216
215 // Draw the label text, if one exists. 217 // Draw the label text, if one exists.
216 if (!controller_->GetSuggestionAt(index).label.empty()) { 218 if (!controller_->GetSuggestionAt(index).label.empty()) {
217 const int label_width = gfx::GetStringWidth( 219 const int label_width = gfx::GetStringWidth(
218 controller_->GetElidedLabelAt(index), 220 controller_->GetElidedLabelAt(index),
219 controller_->layout_model().GetLabelFontListForRow(index)); 221 controller_->layout_model().GetLabelFontListForRow(index));
220 int label_x_align_left = x_align_left; 222 int label_x_align_left = x_align_left;
221 223
222 if (is_http_warning) { 224 if (is_icon_in_front_of_text_row) {
223 label_x_align_left = 225 label_x_align_left =
224 is_rtl ? value_rect.x() : value_rect.right() - label_width; 226 is_rtl ? value_rect.x() : value_rect.right() - label_width;
225 } else { 227 } else {
226 label_x_align_left += is_rtl ? 0 : -label_width; 228 label_x_align_left += is_rtl ? 0 : -label_width;
227 } 229 }
228 230
229 // TODO(crbug.com/678033):Add a GetLabelFontColorForRow function similar to 231 // TODO(crbug.com/678033):Add a GetLabelFontColorForRow function similar to
230 // GetValueFontColorForRow so that the cocoa impl could use it too 232 // GetValueFontColorForRow so that the cocoa impl could use it too
231 canvas->DrawStringRectWithFlags( 233 canvas->DrawStringRectWithFlags(
232 controller_->GetElidedLabelAt(index), 234 controller_->GetElidedLabelAt(index),
(...skipping 28 matching lines...) Expand all
261 263
262 // If the top level widget can't be found, cancel the popup since we can't 264 // If the top level widget can't be found, cancel the popup since we can't
263 // fully set it up. 265 // fully set it up.
264 if (!observing_widget) 266 if (!observing_widget)
265 return NULL; 267 return NULL;
266 268
267 return new AutofillPopupViewViews(controller, observing_widget); 269 return new AutofillPopupViewViews(controller, observing_widget);
268 } 270 }
269 271
270 } // namespace autofill 272 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698