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

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

Issue 2496683003: Http Bad: Add a PopupItemId to identify http warning message (Closed)
Patch Set: minor change Created 4 years, 1 month 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 size_t index) const { 150 size_t index) const {
151 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 151 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
152 152
153 // Autofill values have positive |frontend_id|. 153 // Autofill values have positive |frontend_id|.
154 if (suggestions[index].frontend_id > 0) 154 if (suggestions[index].frontend_id > 0)
155 return bold_font_list_; 155 return bold_font_list_;
156 156
157 // All other message types are defined here. 157 // All other message types are defined here.
158 PopupItemId id = static_cast<PopupItemId>(suggestions[index].frontend_id); 158 PopupItemId id = static_cast<PopupItemId>(suggestions[index].frontend_id);
159 switch (id) { 159 switch (id) {
160 case POPUP_ITEM_ID_WARNING_MESSAGE: 160 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE:
161 return warning_font_list_; 161 return warning_font_list_;
162 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE:
162 case POPUP_ITEM_ID_CLEAR_FORM: 163 case POPUP_ITEM_ID_CLEAR_FORM:
163 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO: 164 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO:
164 case POPUP_ITEM_ID_AUTOFILL_OPTIONS: 165 case POPUP_ITEM_ID_AUTOFILL_OPTIONS:
165 case POPUP_ITEM_ID_SCAN_CREDIT_CARD: 166 case POPUP_ITEM_ID_SCAN_CREDIT_CARD:
166 case POPUP_ITEM_ID_SEPARATOR: 167 case POPUP_ITEM_ID_SEPARATOR:
167 return normal_font_list_; 168 return normal_font_list_;
168 case POPUP_ITEM_ID_TITLE: 169 case POPUP_ITEM_ID_TITLE:
169 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: 170 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY:
170 case POPUP_ITEM_ID_DATALIST_ENTRY: 171 case POPUP_ITEM_ID_DATALIST_ENTRY:
171 case POPUP_ITEM_ID_PASSWORD_ENTRY: 172 case POPUP_ITEM_ID_PASSWORD_ENTRY:
172 return bold_font_list_; 173 return bold_font_list_;
173 } 174 }
174 NOTREACHED(); 175 NOTREACHED();
175 return normal_font_list_; 176 return normal_font_list_;
176 } 177 }
177 178
178 const gfx::FontList& AutofillPopupLayoutModel::GetLabelFontList() const { 179 const gfx::FontList& AutofillPopupLayoutModel::GetLabelFontList() const {
179 return smaller_font_list_; 180 return smaller_font_list_;
180 } 181 }
182
183 SkColor AutofillPopupLayoutModel::GetValueFontColorForRow(size_t index) const {
184 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
185 switch (suggestions[index].frontend_id) {
csashi 2016/11/17 01:41:31 Because you only need the frontend_id would it be
lshang 2016/11/17 07:03:46 Yes GetSuggestions() is used all over this file to
186 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE:
187 return kHttpWarningTextColor;
188 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE:
189 return kLabelTextColor;
190 default:
191 return kValueTextColor;
192 }
193 }
181 #endif 194 #endif
182 195
183 int AutofillPopupLayoutModel::LineFromY(int y) const { 196 int AutofillPopupLayoutModel::LineFromY(int y) const {
184 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 197 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
185 int current_height = kPopupBorderThickness; 198 int current_height = kPopupBorderThickness;
186 199
187 for (size_t i = 0; i < suggestions.size(); ++i) { 200 for (size_t i = 0; i < suggestions.size(); ++i) {
188 current_height += GetRowHeightFromId(suggestions[i].frontend_id); 201 current_height += GetRowHeightFromId(suggestions[i].frontend_id);
189 202
190 if (y <= current_height) 203 if (y <= current_height)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 #endif 237 #endif
225 238
226 return result; 239 return result;
227 } 240 }
228 241
229 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const { 242 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const {
230 return gfx::ToEnclosingRect(delegate_->element_bounds()); 243 return gfx::ToEnclosingRect(delegate_->element_bounds());
231 } 244 }
232 245
233 } // namespace autofill 246 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698