| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.preferences.autofill; | 5 package org.chromium.chrome.browser.preferences.autofill; |
| 6 | 6 |
| 7 import android.os.Bundle; | 7 import android.os.Bundle; |
| 8 import android.preference.Preference; | 8 import android.preference.Preference; |
| 9 import android.preference.Preference.OnPreferenceClickListener; | 9 import android.preference.Preference.OnPreferenceClickListener; |
| 10 import android.preference.PreferenceFragment; | 10 import android.preference.PreferenceFragment; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 getActivity().setTitle(R.string.autofill_edit_credit_card); | 33 getActivity().setTitle(R.string.autofill_edit_credit_card); |
| 34 | 34 |
| 35 // We know which card to display based on the GUID stuffed in | 35 // We know which card to display based on the GUID stuffed in |
| 36 // our extras by AutofillPreferences. | 36 // our extras by AutofillPreferences. |
| 37 Bundle extras = getArguments(); | 37 Bundle extras = getArguments(); |
| 38 if (extras != null) { | 38 if (extras != null) { |
| 39 mGUID = extras.getString(AutofillPreferences.AUTOFILL_GUID); | 39 mGUID = extras.getString(AutofillPreferences.AUTOFILL_GUID); |
| 40 } | 40 } |
| 41 assert mGUID != null; | 41 assert mGUID != null; |
| 42 CreditCard card = PersonalDataManager.getInstance().getCreditCard(mGUID)
; | 42 CreditCard card = PersonalDataManager.getInstance().getCreditCard(mGUID)
; |
| 43 if (card == null) { |
| 44 getActivity().finish(); |
| 45 return; |
| 46 } |
| 47 |
| 43 assert !card.getIsLocal(); | 48 assert !card.getIsLocal(); |
| 44 | 49 |
| 45 Preference cardDescription = findPreference(PREF_SERVER_CARD_DESCRIPTION
); | 50 Preference cardDescription = findPreference(PREF_SERVER_CARD_DESCRIPTION
); |
| 46 cardDescription.setTitle(card.getObfuscatedNumber()); | 51 cardDescription.setTitle(card.getObfuscatedNumber()); |
| 47 cardDescription.setSummary(card.getFormattedExpirationDate(getActivity()
)); | 52 cardDescription.setSummary(card.getFormattedExpirationDate(getActivity()
)); |
| 48 | 53 |
| 49 findPreference(PREF_SERVER_CARD_EDIT_LINK).setOnPreferenceClickListener(
this); | 54 findPreference(PREF_SERVER_CARD_EDIT_LINK).setOnPreferenceClickListener(
this); |
| 50 | 55 |
| 51 Preference clearLocalCopy = findPreference(PREF_SERVER_CARD_LOCAL_COPY); | 56 Preference clearLocalCopy = findPreference(PREF_SERVER_CARD_LOCAL_COPY); |
| 52 if (!card.getIsCached()) { | 57 if (!card.getIsCached()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 63 R.string.autofill_edit_credit_card, R.string.autofill_manage
_wallet_cards_url); | 68 R.string.autofill_edit_credit_card, R.string.autofill_manage
_wallet_cards_url); |
| 64 } else { | 69 } else { |
| 65 assert preference.getKey().equals(PREF_SERVER_CARD_LOCAL_COPY); | 70 assert preference.getKey().equals(PREF_SERVER_CARD_LOCAL_COPY); |
| 66 PersonalDataManager.getInstance().clearUnmaskedCache(mGUID); | 71 PersonalDataManager.getInstance().clearUnmaskedCache(mGUID); |
| 67 // It's no longer cached locally. Hide the clear button. | 72 // It's no longer cached locally. Hide the clear button. |
| 68 getPreferenceScreen().removePreference(preference); | 73 getPreferenceScreen().removePreference(preference); |
| 69 } | 74 } |
| 70 return true; | 75 return true; |
| 71 } | 76 } |
| 72 } | 77 } |
| OLD | NEW |