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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_layout_model.cc

Issue 2971783002: Skeleton for showing "Show all saved passwords row" for Linux/CrOs/Windows platforms (Closed)
Patch Set: Fix ios compilation 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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/autofill/autofill_popup_layout_model.h" 5 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/ui/autofill/autofill_popup_view.h" 11 #include "chrome/browser/ui/autofill/autofill_popup_view.h"
12 #include "chrome/browser/ui/autofill/popup_constants.h" 12 #include "chrome/browser/ui/autofill/popup_constants.h"
13 #include "components/autofill/core/browser/autofill_experiments.h" 13 #include "components/autofill/core/browser/autofill_experiments.h"
14 #include "components/autofill/core/browser/credit_card.h" 14 #include "components/autofill/core/browser/credit_card.h"
15 #include "components/autofill/core/browser/popup_item_ids.h" 15 #include "components/autofill/core/browser/popup_item_ids.h"
16 #include "components/autofill/core/browser/suggestion.h" 16 #include "components/autofill/core/browser/suggestion.h"
17 #include "components/autofill/core/common/autofill_util.h" 17 #include "components/autofill/core/common/autofill_util.h"
18 #include "components/grit/components_scaled_resources.h" 18 #include "components/grit/components_scaled_resources.h"
19 #include "third_party/skia/include/core/SkColor.h" 19 #include "third_party/skia/include/core/SkColor.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/color_palette.h" 21 #include "ui/gfx/color_palette.h"
22 #include "ui/gfx/color_utils.h" 22 #include "ui/gfx/color_utils.h"
23 #include "ui/gfx/font_list.h" 23 #include "ui/gfx/font_list.h"
24 #include "ui/gfx/geometry/rect_conversions.h" 24 #include "ui/gfx/geometry/rect_conversions.h"
25 #include "ui/gfx/image/image_skia.h" 25 #include "ui/gfx/image/image_skia.h"
26 #include "ui/gfx/paint_vector_icon.h" 26 #include "ui/gfx/paint_vector_icon.h"
27 27
28 #if !defined(OS_ANDROID) 28 #if !defined(OS_ANDROID)
29 #include "chrome/app/vector_icons/vector_icons.h"
29 #include "components/toolbar/vector_icons.h" // nogncheck 30 #include "components/toolbar/vector_icons.h" // nogncheck
30 #endif 31 #endif
31 32
32 namespace autofill { 33 namespace autofill {
33 34
34 namespace { 35 namespace {
35 36
36 // The vertical height of each row in pixels. 37 // The vertical height of each row in pixels.
37 const size_t kRowHeight = 24; 38 const size_t kRowHeight = 24;
38 39
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 popup_width = std::max(popup_width, row_size); 116 popup_width = std::max(popup_width, row_size);
116 } 117 }
117 118
118 return popup_width; 119 return popup_width;
119 } 120 }
120 121
121 int AutofillPopupLayoutModel::RowWidthWithoutText(int row, 122 int AutofillPopupLayoutModel::RowWidthWithoutText(int row,
122 bool with_label) const { 123 bool with_label) const {
123 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 124 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
124 bool is_warning_message = (suggestions[row].frontend_id == 125 bool is_row_with_right_handside_icon =
vasilii 2017/07/10 17:17:57 it is left side
melandory 2017/07/11 16:00:01 Done.
125 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE); 126 ((suggestions[row].frontend_id ==
127 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) ||
128 (suggestions[row].frontend_id ==
129 POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY));
126 130
127 int row_size = kEndPadding; 131 int row_size = kEndPadding;
128 132
129 if (with_label) 133 if (with_label)
vasilii 2017/07/10 17:17:57 {}
melandory 2017/07/11 16:00:01 Done.
130 row_size += is_warning_message ? kHttpWarningNamePadding : kNamePadding; 134 row_size += is_row_with_right_handside_icon ? kHttpWarningNamePadding
vasilii 2017/07/10 17:17:57 I don't understand how presence of an icon affects
melandory 2017/07/11 16:00:01 It's not only presence of the icon, but as I under
135 : kNamePadding;
131 136
132 // Add the Autofill icon size, if required. 137 // Add the Autofill icon size, if required.
133 const base::string16& icon = suggestions[row].icon; 138 const base::string16& icon = suggestions[row].icon;
134 if (!icon.empty()) { 139 if (!icon.empty()) {
135 row_size += GetIconImage(row).width() + 140 row_size += GetIconImage(row).width() + (is_row_with_right_handside_icon
136 (is_warning_message ? kHttpWarningIconPadding : kIconPadding); 141 ? kLeftSideIconTextPadding
142 : kIconPadding);
137 } 143 }
138 144
139 // Add the padding at the end. 145 // Add the padding at the end.
140 row_size += kEndPadding; 146 row_size += kEndPadding;
141 147
142 // Add room for the popup border. 148 // Add room for the popup border.
143 row_size += 2 * kPopupBorderThickness; 149 row_size += 2 * kPopupBorderThickness;
144 150
145 return row_size; 151 return row_size;
146 } 152 }
(...skipping 26 matching lines...) Expand all
173 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE: 179 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE:
174 case POPUP_ITEM_ID_CLEAR_FORM: 180 case POPUP_ITEM_ID_CLEAR_FORM:
175 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO: 181 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO:
176 case POPUP_ITEM_ID_AUTOFILL_OPTIONS: 182 case POPUP_ITEM_ID_AUTOFILL_OPTIONS:
177 case POPUP_ITEM_ID_CREATE_HINT: 183 case POPUP_ITEM_ID_CREATE_HINT:
178 case POPUP_ITEM_ID_SCAN_CREDIT_CARD: 184 case POPUP_ITEM_ID_SCAN_CREDIT_CARD:
179 case POPUP_ITEM_ID_SEPARATOR: 185 case POPUP_ITEM_ID_SEPARATOR:
180 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE: 186 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE:
181 case POPUP_ITEM_ID_TITLE: 187 case POPUP_ITEM_ID_TITLE:
182 case POPUP_ITEM_ID_PASSWORD_ENTRY: 188 case POPUP_ITEM_ID_PASSWORD_ENTRY:
189 case POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY:
183 return normal_font_list_; 190 return normal_font_list_;
184 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: 191 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY:
185 case POPUP_ITEM_ID_DATALIST_ENTRY: 192 case POPUP_ITEM_ID_DATALIST_ENTRY:
186 case POPUP_ITEM_ID_USERNAME_ENTRY: 193 case POPUP_ITEM_ID_USERNAME_ENTRY:
187 return bold_font_list_; 194 return bold_font_list_;
188 } 195 }
189 NOTREACHED(); 196 NOTREACHED();
190 return normal_font_list_; 197 return normal_font_list_;
191 } 198 }
192 199
(...skipping 30 matching lines...) Expand all
223 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) { 230 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) {
224 if (icon_str == base::ASCIIToUTF16("httpWarning")) { 231 if (icon_str == base::ASCIIToUTF16("httpWarning")) {
225 return gfx::CreateVectorIcon(toolbar::kHttpIcon, kHttpWarningIconWidth, 232 return gfx::CreateVectorIcon(toolbar::kHttpIcon, kHttpWarningIconWidth,
226 gfx::kChromeIconGrey); 233 gfx::kChromeIconGrey);
227 } 234 }
228 DCHECK_EQ(icon_str, base::ASCIIToUTF16("httpsInvalid")); 235 DCHECK_EQ(icon_str, base::ASCIIToUTF16("httpsInvalid"));
229 return gfx::CreateVectorIcon(toolbar::kHttpsInvalidIcon, 236 return gfx::CreateVectorIcon(toolbar::kHttpsInvalidIcon,
230 kHttpWarningIconWidth, gfx::kGoogleRed700); 237 kHttpWarningIconWidth, gfx::kGoogleRed700);
231 } 238 }
232 239
240 if (icon_str == base::ASCIIToUTF16("showAllSavedPasswords")) {
241 return gfx::CreateVectorIcon(kShowAllSavedPasswordsIcon,
242 kHttpWarningIconWidth, gfx::kChromeIconGrey);
243 }
244
233 // For other suggestion entries, get icon from PNG files. 245 // For other suggestion entries, get icon from PNG files.
234 int icon_id = GetIconResourceID(icon_str); 246 int icon_id = GetIconResourceID(icon_str);
235 DCHECK_NE(-1, icon_id); 247 DCHECK_NE(-1, icon_id);
236 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id); 248 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id);
237 } 249 }
238 #endif 250 #endif
239 251
240 int AutofillPopupLayoutModel::LineFromY(int y) const { 252 int AutofillPopupLayoutModel::LineFromY(int y) const {
241 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 253 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
242 int current_height = kPopupBorderThickness; 254 int current_height = kPopupBorderThickness;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 bool AutofillPopupLayoutModel::IsIconAtStart(int frontend_id) const { 316 bool AutofillPopupLayoutModel::IsIconAtStart(int frontend_id) const {
305 return frontend_id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE || 317 return frontend_id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE ||
306 (is_credit_card_popup_ && IsIconInCreditCardPopupAtStart()); 318 (is_credit_card_popup_ && IsIconInCreditCardPopupAtStart());
307 } 319 }
308 320
309 unsigned int AutofillPopupLayoutModel::GetMargin() const { 321 unsigned int AutofillPopupLayoutModel::GetMargin() const {
310 return GetPopupMargin(); 322 return GetPopupMargin();
311 } 323 }
312 324
313 } // namespace autofill 325 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698