diff options
author | estade <estade@chromium.org> | 2015-05-18 13:51:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-18 20:51:42 +0000 |
commit | c806c71f4a9e704d40b14df026a6ebfa0c2fcac1 (patch) | |
tree | bf2c3fd0c6d0d231e925273e35ec743b4e772583 /components | |
parent | b7931b4dec4529327e5c3a51bf59ece6a39e0dbe (diff) | |
download | chromium_src-c806c71f4a9e704d40b14df026a6ebfa0c2fcac1.zip chromium_src-c806c71f4a9e704d40b14df026a6ebfa0c2fcac1.tar.gz chromium_src-c806c71f4a9e704d40b14df026a6ebfa0c2fcac1.tar.bz2 |
Autofill item deletion on android
You can now delete things by long pressing suggestions in the dropdown (assuming it's the right kind of suggestion).
BUG=486153
Review URL: https://codereview.chromium.org/1134793004
Cr-Commit-Position: refs/heads/master@{#330413}
Diffstat (limited to 'components')
8 files changed, 103 insertions, 0 deletions
diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc index 5f8a3e0..0618dc4 100644 --- a/components/autofill/core/browser/autofill_external_delegate.cc +++ b/components/autofill/core/browser/autofill_external_delegate.cc @@ -267,6 +267,14 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, manager_->client()->HideAutofillPopup(); } +bool AutofillExternalDelegate::GetDeletionConfirmationText( + const base::string16& value, + int identifier, + base::string16* title, + base::string16* body) { + return manager_->GetDeletionConfirmationText(value, identifier, title, body); +} + bool AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, int identifier) { if (identifier > 0) diff --git a/components/autofill/core/browser/autofill_external_delegate.h b/components/autofill/core/browser/autofill_external_delegate.h index 1f88ff0..3803e24 100644 --- a/components/autofill/core/browser/autofill_external_delegate.h +++ b/components/autofill/core/browser/autofill_external_delegate.h @@ -42,6 +42,10 @@ class AutofillExternalDelegate : public AutofillPopupDelegate { int identifier) override; void DidAcceptSuggestion(const base::string16& value, int identifier) override; + bool GetDeletionConfirmationText(const base::string16& value, + int identifier, + base::string16* title, + base::string16* body) override; bool RemoveSuggestion(const base::string16& value, int identifier) override; void ClearPreviewedForm() override; diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc index 5df3ca1..f5040f9 100644 --- a/components/autofill/core/browser/autofill_manager.cc +++ b/components/autofill/core/browser/autofill_manager.cc @@ -700,6 +700,62 @@ void AutofillManager::OnHidePopup() { client_->HideAutofillPopup(); } +bool AutofillManager::GetDeletionConfirmationText(const base::string16& value, + int identifier, + base::string16* title, + base::string16* body) { + if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { + if (title) + title->assign(value); + if (body) { + body->assign(l10n_util::GetStringUTF16( + IDS_AUTOFILL_DELETE_AUTOCOMPLETE_SUGGESTION_CONFIRMATION_BODY)); + } + + return true; + } + + if (identifier < 0) + return false; + + size_t variant = 0; + const CreditCard* credit_card = nullptr; + const AutofillProfile* profile = nullptr; + if (GetCreditCard(identifier, &credit_card)) { + if (credit_card->record_type() != CreditCard::LOCAL_CARD) + return false; + + if (title) + title->assign(credit_card->TypeAndLastFourDigits()); + if (body) { + body->assign(l10n_util::GetStringUTF16( + IDS_AUTOFILL_DELETE_CREDIT_CARD_SUGGESTION_CONFIRMATION_BODY)); + } + + return true; + } else if (GetProfile(identifier, &profile, &variant)) { + if (profile->record_type() != AutofillProfile::LOCAL_PROFILE) + return false; + + if (title) { + base::string16 street_address = profile->GetRawInfo(ADDRESS_HOME_CITY); + if (!street_address.empty()) + title->swap(street_address); + else + title->assign(value); + } + if (body) { + body->assign(l10n_util::GetStringUTF16( + IDS_AUTOFILL_DELETE_PROFILE_SUGGESTION_CONFIRMATION_BODY)); + } + + return true; + } + + NOTREACHED(); + return false; +} + bool AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { std::string guid; size_t variant = 0; diff --git a/components/autofill/core/browser/autofill_manager.h b/components/autofill/core/browser/autofill_manager.h index c0696cf..de15710 100644 --- a/components/autofill/core/browser/autofill_manager.h +++ b/components/autofill/core/browser/autofill_manager.h @@ -123,6 +123,13 @@ class AutofillManager : public AutofillDownloadManager::Observer, void OnDidFillAutofillFormData(const base::TimeTicks& timestamp); void OnDidPreviewAutofillFormData(); + // Returns true if the value/identifier is deletable. Fills out + // |title| and |body| with relevant user-facing text. + bool GetDeletionConfirmationText(const base::string16& value, + int identifier, + base::string16* title, + base::string16* body); + // Remove the credit card or Autofill profile that matches |unique_id| // from the database. Returns true if deletion is allowed. bool RemoveAutofillProfileOrCreditCard(int unique_id); diff --git a/components/autofill/core/browser/autofill_popup_delegate.h b/components/autofill/core/browser/autofill_popup_delegate.h index 2eff7c1..8c77edb 100644 --- a/components/autofill/core/browser/autofill_popup_delegate.h +++ b/components/autofill/core/browser/autofill_popup_delegate.h @@ -28,6 +28,13 @@ class AutofillPopupDelegate { virtual void DidAcceptSuggestion(const base::string16& value, int identifier) = 0; + // Returns whether the given value can be deleted, and if true, + // fills out |title| and |body|. + virtual bool GetDeletionConfirmationText(const base::string16& value, + int identifier, + base::string16* title, + base::string16* body) = 0; + // Delete the described suggestion. Returns true if something was deleted, // or false if deletion is not allowed. virtual bool RemoveSuggestion(const base::string16& value, diff --git a/components/autofill_strings.grdp b/components/autofill_strings.grdp index 70dd8ad..701afad 100644 --- a/components/autofill_strings.grdp +++ b/components/autofill_strings.grdp @@ -10,6 +10,15 @@ <message name="IDS_AUTOFILL_WARNING_INSECURE_CONNECTION" desc="Warning text to show when credit card autofill is disabled because the website is not using a secure connection."> Automatic credit card filling is disabled because this form does not use a secure connection. </message> + <message name="IDS_AUTOFILL_DELETE_AUTOCOMPLETE_SUGGESTION_CONFIRMATION_BODY" desc="Text in a dialog to confirm that the user wants to delete an autocomplete form history suggestion."> + Remove form suggestion from Chrome? + </message> + <message name="IDS_AUTOFILL_DELETE_CREDIT_CARD_SUGGESTION_CONFIRMATION_BODY" desc="Text in a dialog to confirm that the user wants to delete a credit card from Chrome Autofill."> + Remove credit card from Chrome? + </message> + <message name="IDS_AUTOFILL_DELETE_PROFILE_SUGGESTION_CONFIRMATION_BODY" desc="Text in a dialog to confirm that the user wants to delete an address from Chrome Autofill."> + Remove address from Chrome? + </message> <message name="IDS_AUTOFILL_CC_AMEX" desc="Full American Express credit card name."> American Express </message> diff --git a/components/password_manager/core/browser/password_autofill_manager.cc b/components/password_manager/core/browser/password_autofill_manager.cc index e0a57cd..d585a47 100644 --- a/components/password_manager/core/browser/password_autofill_manager.cc +++ b/components/password_manager/core/browser/password_autofill_manager.cc @@ -218,6 +218,14 @@ void PasswordAutofillManager::DidAcceptSuggestion(const base::string16& value, autofill_client_->HideAutofillPopup(); } +bool PasswordAutofillManager::GetDeletionConfirmationText( + const base::string16& value, + int identifier, + base::string16* title, + base::string16* body) { + return false; +} + bool PasswordAutofillManager::RemoveSuggestion(const base::string16& value, int identifier) { // http://crbug.com/329038 diff --git a/components/password_manager/core/browser/password_autofill_manager.h b/components/password_manager/core/browser/password_autofill_manager.h index 08c9842..96e998f 100644 --- a/components/password_manager/core/browser/password_autofill_manager.h +++ b/components/password_manager/core/browser/password_autofill_manager.h @@ -35,6 +35,10 @@ class PasswordAutofillManager : public autofill::AutofillPopupDelegate { int identifier) override; void DidAcceptSuggestion(const base::string16& value, int identifier) override; + bool GetDeletionConfirmationText(const base::string16& value, + int identifier, + base::string16* title, + base::string16* body) override; bool RemoveSuggestion(const base::string16& value, int identifier) override; void ClearPreviewedForm() override; |