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

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: fix mac 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 popup_width = std::max(popup_width, row_size); 112 popup_width = std::max(popup_width, row_size);
113 } 113 }
114 114
115 return popup_width; 115 return popup_width;
116 } 116 }
117 117
118 int AutofillPopupLayoutModel::RowWidthWithoutText(int row, 118 int AutofillPopupLayoutModel::RowWidthWithoutText(int row,
119 bool with_label) const { 119 bool with_label) const {
120 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); 120 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions();
121 bool is_warning_message = (suggestions[row].frontend_id ==
122 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE);
121 123
122 int row_size = kEndPadding; 124 int row_size = kEndPadding;
123 125
124 if (with_label) 126 if (with_label)
125 row_size += kNamePadding; 127 row_size += is_warning_message ? kHttpWarningNamePadding : kNamePadding;
126 128
127 // Add the Autofill icon size, if required. 129 // Add the Autofill icon size, if required.
128 const base::string16& icon = suggestions[row].icon; 130 const base::string16& icon = suggestions[row].icon;
129 if (!icon.empty()) { 131 if (!icon.empty()) {
130 row_size += GetIconImage(row).width() + kIconPadding; 132 row_size += GetIconImage(row).width() +
133 (is_warning_message ? kHttpWarningIconPadding : 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 #endif 276 #endif
268 277
269 return result; 278 return result;
270 } 279 }
271 280
272 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const { 281 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const {
273 return gfx::ToEnclosingRect(delegate_->element_bounds()); 282 return gfx::ToEnclosingRect(delegate_->element_bounds());
274 } 283 }
275 284
276 } // namespace autofill 285 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698