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

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 2124343002: [Autofill] Implement Credit Card Signin Promo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ifdef Created 4 years, 5 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 autofill_field->Type().GetStorableType() != CREDIT_CARD_NUMBER) { 265 autofill_field->Type().GetStorableType() != CREDIT_CARD_NUMBER) {
266 return false; 266 return false;
267 } 267 }
268 268
269 static const int kShowScanCreditCardMaxValueLength = 6; 269 static const int kShowScanCreditCardMaxValueLength = 6;
270 return field.value.size() <= kShowScanCreditCardMaxValueLength && 270 return field.value.size() <= kShowScanCreditCardMaxValueLength &&
271 base::ContainsOnlyChars(CreditCard::StripSeparators(field.value), 271 base::ContainsOnlyChars(CreditCard::StripSeparators(field.value),
272 base::ASCIIToUTF16("0123456789")); 272 base::ASCIIToUTF16("0123456789"));
273 } 273 }
274 274
275 bool AutofillManager::ShouldShowCreditCardSigninPromo(
276 const FormData& form,
277 const FormFieldData& field) {
278 // Check whether we are dealing with a credit card field.
279 AutofillField* autofill_field = GetAutofillField(form, field);
280 if (!autofill_field || autofill_field->Type().group() != CREDIT_CARD) {
Evan Stade 2016/07/08 17:34:58 nit: return autofill_field && autofill_field->Type
Mathieu 2016/07/08 18:10:02 Neater thanks
281 return false;
282 }
283
284 // Will check if the user is signed in and if it's appropriate to show the
285 // promo (e.g. the platform is supported).
286 return client_->ShouldShowSigninPromo();
287 }
288
275 void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms, 289 void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms,
276 const TimeTicks& timestamp) { 290 const TimeTicks& timestamp) {
277 if (!IsValidFormDataVector(forms)) 291 if (!IsValidFormDataVector(forms))
278 return; 292 return;
279 293
280 if (!driver_->RendererIsAvailable()) 294 if (!driver_->RendererIsAvailable())
281 return; 295 return;
282 296
283 bool enabled = IsAutofillEnabled(); 297 bool enabled = IsAutofillEnabled();
284 if (!has_logged_autofill_enabled_) { 298 if (!has_logged_autofill_enabled_) {
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 if (i > 0) 2030 if (i > 0)
2017 fputs("Next oldest form:\n", file); 2031 fputs("Next oldest form:\n", file);
2018 } 2032 }
2019 fputs("\n", file); 2033 fputs("\n", file);
2020 2034
2021 fclose(file); 2035 fclose(file);
2022 } 2036 }
2023 #endif // ENABLE_FORM_DEBUG_DUMP 2037 #endif // ENABLE_FORM_DEBUG_DUMP
2024 2038
2025 } // namespace autofill 2039 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698