| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Handler; | 8 import android.os.Handler; |
| 9 import android.text.TextUtils; | 9 import android.text.TextUtils; |
| 10 import android.util.JsonWriter; | 10 import android.util.JsonWriter; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 * cards also verifies that the card number is valid and the name on card is
not empty. | 249 * cards also verifies that the card number is valid and the name on card is
not empty. |
| 250 * | 250 * |
| 251 * Does not check the expiration date. If the card is expired, the user has
the opportunity | 251 * Does not check the expiration date. If the card is expired, the user has
the opportunity |
| 252 * update the expiration date when providing their CVC in the card unmask di
alog. | 252 * update the expiration date when providing their CVC in the card unmask di
alog. |
| 253 * | 253 * |
| 254 * Does not check that the card type is accepted by the merchant. This is do
ne elsewhere to | 254 * Does not check that the card type is accepted by the merchant. This is do
ne elsewhere to |
| 255 * filter out such cards from view entirely. | 255 * filter out such cards from view entirely. |
| 256 */ | 256 */ |
| 257 private void checkAndUpateCardCompleteness() { | 257 private void checkAndUpateCardCompleteness() { |
| 258 int editMessageResId = 0; // Zero is the invalid resource Id. | 258 int editMessageResId = 0; // Zero is the invalid resource Id. |
| 259 int editTitleResId = 0; | 259 int editTitleResId = R.string.payments_edit_card; |
| 260 int invalidFieldsCount = 0; | 260 int invalidFieldsCount = 0; |
| 261 | 261 |
| 262 if (mBillingAddress == null) { | 262 if (mBillingAddress == null) { |
| 263 editMessageResId = R.string.payments_billing_address_required; | 263 editMessageResId = R.string.payments_billing_address_required; |
| 264 editTitleResId = R.string.payments_add_billing_address; | 264 editTitleResId = R.string.payments_add_billing_address; |
| 265 invalidFieldsCount++; | 265 invalidFieldsCount++; |
| 266 } | 266 } |
| 267 | 267 |
| 268 if (mCard.getIsLocal()) { | 268 if (mCard.getIsLocal()) { |
| 269 if (TextUtils.isEmpty(mCard.getName())) { | 269 if (TextUtils.isEmpty(mCard.getName())) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 280 invalidFieldsCount++; | 280 invalidFieldsCount++; |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 if (invalidFieldsCount > 1) { | 284 if (invalidFieldsCount > 1) { |
| 285 editMessageResId = R.string.payments_more_information_required; | 285 editMessageResId = R.string.payments_more_information_required; |
| 286 editTitleResId = R.string.payments_add_more_information; | 286 editTitleResId = R.string.payments_add_more_information; |
| 287 } | 287 } |
| 288 | 288 |
| 289 mEditMessage = editMessageResId == 0 ? null : mContext.getString(editMes
sageResId); | 289 mEditMessage = editMessageResId == 0 ? null : mContext.getString(editMes
sageResId); |
| 290 mEditTitle = editTitleResId == 0 ? null : mContext.getString(editTitleRe
sId); | 290 mEditTitle = mContext.getString(editTitleResId); |
| 291 mIsComplete = mEditMessage == null; | 291 mIsComplete = mEditMessage == null; |
| 292 } | 292 } |
| 293 | 293 |
| 294 /** @return The credit card represented by this payment instrument. */ | 294 /** @return The credit card represented by this payment instrument. */ |
| 295 public CreditCard getCard() { | 295 public CreditCard getCard() { |
| 296 return mCard; | 296 return mCard; |
| 297 } | 297 } |
| 298 | 298 |
| 299 /** @return The billing address associated with this credit card. */ | 299 /** @return The billing address associated with this credit card. */ |
| 300 public AutofillProfile getBillingAddress() { | 300 public AutofillProfile getBillingAddress() { |
| 301 return mBillingAddress; | 301 return mBillingAddress; |
| 302 } | 302 } |
| 303 } | 303 } |
| OLD | NEW |