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

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 test 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 popup_width = std::max(popup_width, row_size); 105 popup_width = std::max(popup_width, row_size);
106 } 106 }
107 107
108 return popup_width; 108 return popup_width;
109 } 109 }
110 110
111 int AutofillPopupLayoutModel::RowWidthWithoutText(int row, 111 int AutofillPopupLayoutModel::RowWidthWithoutText(int row,
112 bool with_label) const { 112 bool with_label) const {
113 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 113 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
114 bool isWarningMessage = (suggestions[row].frontend_id ==
115 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE);
114 116
115 int row_size = kEndPadding; 117 int row_size = kEndPadding;
116 118
117 if (with_label) 119 if (with_label)
118 row_size += kNamePadding; 120 row_size += isWarningMessage ? kHttpWarningNamePadding : kNamePadding;
119 121
120 // Add the Autofill icon size, if required. 122 // Add the Autofill icon size, if required.
121 const base::string16& icon = suggestions[row].icon; 123 const base::string16& icon = suggestions[row].icon;
122 if (!icon.empty()) { 124 if (!icon.empty()) {
123 int icon_width = ui::ResourceBundle::GetSharedInstance() 125 int icon_width = ui::ResourceBundle::GetSharedInstance()
124 .GetImageNamed(GetIconResourceID(icon)) 126 .GetImageNamed(GetIconResourceID(icon))
125 .Width(); 127 .Width();
126 row_size += icon_width + kIconPadding; 128 row_size += isWarningMessage ? icon_width + kHttpWarningIconPadding
129 : icon_width + kIconPadding;
127 } 130 }
128 131
129 // Add the padding at the end. 132 // Add the padding at the end.
130 row_size += kEndPadding; 133 row_size += kEndPadding;
131 134
132 // Add room for the popup border. 135 // Add room for the popup border.
133 row_size += 2 * kPopupBorderThickness; 136 row_size += 2 * kPopupBorderThickness;
134 137
135 return row_size; 138 return row_size;
136 } 139 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 case POPUP_ITEM_ID_TITLE: 175 case POPUP_ITEM_ID_TITLE:
173 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: 176 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY:
174 case POPUP_ITEM_ID_DATALIST_ENTRY: 177 case POPUP_ITEM_ID_DATALIST_ENTRY:
175 case POPUP_ITEM_ID_PASSWORD_ENTRY: 178 case POPUP_ITEM_ID_PASSWORD_ENTRY:
176 return bold_font_list_; 179 return bold_font_list_;
177 } 180 }
178 NOTREACHED(); 181 NOTREACHED();
179 return normal_font_list_; 182 return normal_font_list_;
180 } 183 }
181 184
182 const gfx::FontList& AutofillPopupLayoutModel::GetLabelFontList() const { 185 const gfx::FontList& AutofillPopupLayoutModel::GetLabelFontListForRow(
186 size_t index) const {
187 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
188 PopupItemId id = static_cast<PopupItemId>(suggestions[index].frontend_id);
189 if (id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE)
Mathieu 2016/11/22 14:36:45 curious, can't you do if (suggestions[index].fron
lshang 2016/11/27 04:59:13 Done.
190 return normal_font_list_;
191
183 return smaller_font_list_; 192 return smaller_font_list_;
184 } 193 }
185 194
186 SkColor AutofillPopupLayoutModel::GetValueFontColorForRow(size_t index) const { 195 SkColor AutofillPopupLayoutModel::GetValueFontColorForRow(size_t index) const {
187 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 196 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
188 switch (suggestions[index].frontend_id) { 197 switch (suggestions[index].frontend_id) {
189 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE: 198 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE:
190 return gfx::kGoogleRed700; 199 return gfx::kGoogleRed700;
191 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE: 200 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE:
192 return kLabelTextColor; 201 return kLabelTextColor;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 #endif 249 #endif
241 250
242 return result; 251 return result;
243 } 252 }
244 253
245 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const { 254 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const {
246 return gfx::ToEnclosingRect(delegate_->element_bounds()); 255 return gfx::ToEnclosingRect(delegate_->element_bounds());
247 } 256 }
248 257
249 } // namespace autofill 258 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698