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

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

Issue 2517843002: Http Bad: Put icon on the left of http warning message on Views (Closed)
Patch Set: add comments Created 4 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 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"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 popup_width = std::max(popup_width, row_size); 111 popup_width = std::max(popup_width, row_size);
112 } 112 }
113 113
114 return popup_width; 114 return popup_width;
115 } 115 }
116 116
117 int AutofillPopupLayoutModel::RowWidthWithoutText(int row, 117 int AutofillPopupLayoutModel::RowWidthWithoutText(int row,
118 bool with_label) const { 118 bool with_label) const {
119 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 119 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
120 bool isWarningMessage = (suggestions[row].frontend_id ==
Evan Stade 2016/11/29 15:43:17 is_warning_message
lshang 2016/11/30 05:43:36 Done.
121 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE);
120 122
121 int row_size = kEndPadding; 123 int row_size = kEndPadding;
122 124
123 if (with_label) 125 if (with_label)
124 row_size += kNamePadding; 126 row_size += isWarningMessage ? kHttpWarningNamePadding : kNamePadding;
125 127
126 // Add the Autofill icon size, if required. 128 // Add the Autofill icon size, if required.
127 const base::string16& icon = suggestions[row].icon; 129 const base::string16& icon = suggestions[row].icon;
128 if (!icon.empty()) { 130 if (!icon.empty()) {
129 int icon_width = GetIconImage(row).width(); 131 int icon_width = GetIconImage(row).width();
130 row_size += icon_width + kIconPadding; 132 row_size += isWarningMessage ? icon_width + kHttpWarningIconPadding
Evan Stade 2016/11/29 15:43:17 nit: row_size += icon_width + (is_warning ? kHttp
lshang 2016/11/30 05:43:36 Done.
133 : icon_width + kIconPadding;
131 } 134 }
132 135
133 // Add the padding at the end. 136 // Add the padding at the end.
134 row_size += kEndPadding; 137 row_size += kEndPadding;
135 138
136 // Add room for the popup border. 139 // Add room for the popup border.
137 row_size += 2 * kPopupBorderThickness; 140 row_size += 2 * kPopupBorderThickness;
138 141
139 return row_size; 142 return row_size;
140 } 143 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 case POPUP_ITEM_ID_TITLE: 179 case POPUP_ITEM_ID_TITLE:
177 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: 180 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY:
178 case POPUP_ITEM_ID_DATALIST_ENTRY: 181 case POPUP_ITEM_ID_DATALIST_ENTRY:
179 case POPUP_ITEM_ID_PASSWORD_ENTRY: 182 case POPUP_ITEM_ID_PASSWORD_ENTRY:
180 return bold_font_list_; 183 return bold_font_list_;
181 } 184 }
182 NOTREACHED(); 185 NOTREACHED();
183 return normal_font_list_; 186 return normal_font_list_;
184 } 187 }
185 188
186 const gfx::FontList& AutofillPopupLayoutModel::GetLabelFontList() const { 189 const gfx::FontList& AutofillPopupLayoutModel::GetLabelFontListForRow(
190 size_t index) const {
191 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
192 if (suggestions[index].frontend_id ==
193 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE)
194 return normal_font_list_;
195
187 return smaller_font_list_; 196 return smaller_font_list_;
188 } 197 }
189 198
190 SkColor AutofillPopupLayoutModel::GetValueFontColorForRow(size_t index) const { 199 SkColor AutofillPopupLayoutModel::GetValueFontColorForRow(size_t index) const {
191 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 200 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
192 switch (suggestions[index].frontend_id) { 201 switch (suggestions[index].frontend_id) {
193 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE: 202 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE:
194 return gfx::kGoogleRed700; 203 return gfx::kGoogleRed700;
195 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE: 204 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE:
196 return kLabelTextColor; 205 return kLabelTextColor;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 #endif 281 #endif
273 282
274 return result; 283 return result;
275 } 284 }
276 285
277 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const { 286 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const {
278 return gfx::ToEnclosingRect(delegate_->element_bounds()); 287 return gfx::ToEnclosingRect(delegate_->element_bounds());
279 } 288 }
280 289
281 } // namespace autofill 290 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698