| OLD | NEW |
| 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/app/vector_icons/vector_icons.h" |
| 11 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 12 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| 12 #include "chrome/browser/ui/autofill/popup_constants.h" | 13 #include "chrome/browser/ui/autofill/popup_constants.h" |
| 13 #include "components/autofill/core/browser/autofill_experiments.h" | 14 #include "components/autofill/core/browser/autofill_experiments.h" |
| 14 #include "components/autofill/core/browser/credit_card.h" | 15 #include "components/autofill/core/browser/credit_card.h" |
| 15 #include "components/autofill/core/browser/popup_item_ids.h" | 16 #include "components/autofill/core/browser/popup_item_ids.h" |
| 16 #include "components/autofill/core/browser/suggestion.h" | 17 #include "components/autofill/core/browser/suggestion.h" |
| 17 #include "components/autofill/core/common/autofill_util.h" | 18 #include "components/autofill/core/common/autofill_util.h" |
| 18 #include "components/grit/components_scaled_resources.h" | 19 #include "components/grit/components_scaled_resources.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE: | 174 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE: |
| 174 case POPUP_ITEM_ID_CLEAR_FORM: | 175 case POPUP_ITEM_ID_CLEAR_FORM: |
| 175 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO: | 176 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO: |
| 176 case POPUP_ITEM_ID_AUTOFILL_OPTIONS: | 177 case POPUP_ITEM_ID_AUTOFILL_OPTIONS: |
| 177 case POPUP_ITEM_ID_CREATE_HINT: | 178 case POPUP_ITEM_ID_CREATE_HINT: |
| 178 case POPUP_ITEM_ID_SCAN_CREDIT_CARD: | 179 case POPUP_ITEM_ID_SCAN_CREDIT_CARD: |
| 179 case POPUP_ITEM_ID_SEPARATOR: | 180 case POPUP_ITEM_ID_SEPARATOR: |
| 180 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE: | 181 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE: |
| 181 case POPUP_ITEM_ID_TITLE: | 182 case POPUP_ITEM_ID_TITLE: |
| 182 case POPUP_ITEM_ID_PASSWORD_ENTRY: | 183 case POPUP_ITEM_ID_PASSWORD_ENTRY: |
| 184 case POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY: |
| 183 return normal_font_list_; | 185 return normal_font_list_; |
| 184 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: | 186 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: |
| 185 case POPUP_ITEM_ID_DATALIST_ENTRY: | 187 case POPUP_ITEM_ID_DATALIST_ENTRY: |
| 186 case POPUP_ITEM_ID_USERNAME_ENTRY: | 188 case POPUP_ITEM_ID_USERNAME_ENTRY: |
| 187 return bold_font_list_; | 189 return bold_font_list_; |
| 188 } | 190 } |
| 189 NOTREACHED(); | 191 NOTREACHED(); |
| 190 return normal_font_list_; | 192 return normal_font_list_; |
| 191 } | 193 } |
| 192 | 194 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 223 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) { | 225 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) { |
| 224 if (icon_str == base::ASCIIToUTF16("httpWarning")) { | 226 if (icon_str == base::ASCIIToUTF16("httpWarning")) { |
| 225 return gfx::CreateVectorIcon(toolbar::kHttpIcon, kHttpWarningIconWidth, | 227 return gfx::CreateVectorIcon(toolbar::kHttpIcon, kHttpWarningIconWidth, |
| 226 gfx::kChromeIconGrey); | 228 gfx::kChromeIconGrey); |
| 227 } | 229 } |
| 228 DCHECK_EQ(icon_str, base::ASCIIToUTF16("httpsInvalid")); | 230 DCHECK_EQ(icon_str, base::ASCIIToUTF16("httpsInvalid")); |
| 229 return gfx::CreateVectorIcon(toolbar::kHttpsInvalidIcon, | 231 return gfx::CreateVectorIcon(toolbar::kHttpsInvalidIcon, |
| 230 kHttpWarningIconWidth, gfx::kGoogleRed700); | 232 kHttpWarningIconWidth, gfx::kGoogleRed700); |
| 231 } | 233 } |
| 232 | 234 |
| 235 if (icon_str == base::ASCIIToUTF16("showAllSavedPasswords")) { |
| 236 return gfx::CreateVectorIcon(kShowAllSavedPasswordsIcon, |
| 237 kHttpWarningIconWidth, gfx::kChromeIconGrey); |
| 238 } |
| 239 |
| 233 // For other suggestion entries, get icon from PNG files. | 240 // For other suggestion entries, get icon from PNG files. |
| 234 int icon_id = GetIconResourceID(icon_str); | 241 int icon_id = GetIconResourceID(icon_str); |
| 235 DCHECK_NE(-1, icon_id); | 242 DCHECK_NE(-1, icon_id); |
| 236 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id); | 243 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id); |
| 237 } | 244 } |
| 238 #endif | 245 #endif |
| 239 | 246 |
| 240 int AutofillPopupLayoutModel::LineFromY(int y) const { | 247 int AutofillPopupLayoutModel::LineFromY(int y) const { |
| 241 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); | 248 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); |
| 242 int current_height = kPopupBorderThickness; | 249 int current_height = kPopupBorderThickness; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 bool AutofillPopupLayoutModel::IsIconAtStart(int frontend_id) const { | 311 bool AutofillPopupLayoutModel::IsIconAtStart(int frontend_id) const { |
| 305 return frontend_id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE || | 312 return frontend_id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE || |
| 306 (is_credit_card_popup_ && IsIconInCreditCardPopupAtStart()); | 313 (is_credit_card_popup_ && IsIconInCreditCardPopupAtStart()); |
| 307 } | 314 } |
| 308 | 315 |
| 309 unsigned int AutofillPopupLayoutModel::GetMargin() const { | 316 unsigned int AutofillPopupLayoutModel::GetMargin() const { |
| 310 return GetPopupMargin(); | 317 return GetPopupMargin(); |
| 311 } | 318 } |
| 312 | 319 |
| 313 } // namespace autofill | 320 } // namespace autofill |
| OLD | NEW |