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

Unified Diff: components/autofill/core/browser/autofill_external_delegate.cc

Issue 2531223003: Expanded Autofill Credit Card Popup Layout Experiment in Android. (Closed)
Patch Set: Adds clarification for SkColor Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_external_delegate.cc
diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc
index 44264662a03bf37a9fe63bfc4918df5166910b90..5298e687c9563bb7677dbd89ebdb5f43f02bf822 100644
--- a/components/autofill/core/browser/autofill_external_delegate.cc
+++ b/components/autofill/core/browser/autofill_external_delegate.cc
@@ -19,6 +19,7 @@
#include "build/build_config.h"
#include "components/autofill/core/browser/autocomplete_history_manager.h"
#include "components/autofill/core/browser/autofill_driver.h"
+#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/popup_item_ids.h"
@@ -48,6 +49,7 @@ AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager,
has_autofill_suggestions_(false),
has_shown_popup_for_current_edit_(false),
should_show_scan_credit_card_(false),
+ is_credit_card_field_(false),
should_show_cc_signin_promo_(false),
has_shown_address_book_prompt(false),
weak_ptr_factory_(this) {
@@ -69,6 +71,8 @@ void AutofillExternalDelegate::OnQuery(int query_id,
element_bounds_ = element_bounds;
should_show_scan_credit_card_ =
manager_->ShouldShowScanCreditCard(query_form_, query_field_);
+ is_credit_card_field_ =
+ manager_->IsCreditCardField(query_form_, query_field_);
should_show_cc_signin_promo_ =
manager_->ShouldShowCreditCardSigninPromo(query_form_, query_field_);
}
@@ -273,6 +277,10 @@ void AutofillExternalDelegate::ClearPreviewedForm() {
driver_->RendererShouldClearPreviewedForm();
}
+bool AutofillExternalDelegate::IsCreditCardField() {
+ return is_credit_card_field_;
+}
+
void AutofillExternalDelegate::Reset() {
manager_->client()->HideAutofillPopup();
}
@@ -329,8 +337,6 @@ void AutofillExternalDelegate::ApplyAutofillOptions(
if (query_field_.is_autofilled) {
base::string16 value =
l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM);
- // TODO(rouslan): Remove manual upper-casing when keyboard accessory becomes
- // default on Android.
if (IsKeyboardAccessoryEnabled())
value = base::i18n::ToUpper(value);
@@ -338,12 +344,9 @@ void AutofillExternalDelegate::ApplyAutofillOptions(
suggestions->back().frontend_id = POPUP_ITEM_ID_CLEAR_FORM;
}
- // Append the 'Chrome Autofill options' menu item;
- // TODO(rouslan): Switch on the platform in the GRD file when keyboard
- // accessory becomes default on Android.
- suggestions->push_back(Suggestion(l10n_util::GetStringUTF16(
- IsKeyboardAccessoryEnabled() ? IDS_AUTOFILL_OPTIONS_CONTENT_DESCRIPTION
- : IDS_AUTOFILL_OPTIONS_POPUP)));
+ // Append the 'Chrome Autofill options' menu item, or the menu item specified
+ // in the popup layout experiment.
+ suggestions->push_back(Suggestion(GetSettingsSuggestionValue()));
suggestions->back().frontend_id = POPUP_ITEM_ID_AUTOFILL_OPTIONS;
if (IsKeyboardAccessoryEnabled())
suggestions->back().icon = base::ASCIIToUTF16("settings");
@@ -386,4 +389,18 @@ void AutofillExternalDelegate::InsertDataListValues(
}
}
+base::string16 AutofillExternalDelegate::GetSettingsSuggestionValue()
+ const {
+ if (IsKeyboardAccessoryEnabled()) {
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_CONTENT_DESCRIPTION);
+ }
+ if (is_credit_card_field_) {
+ const base::string16 suggestion_value =
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_CREDIT_CARD_OPTIONS_POPUP);
+ if (!suggestion_value.empty())
Mathieu 2016/11/30 21:27:35 why would it be empty?
csashi 2016/12/01 01:13:43 I wasn't sure how the resource strings get populat
Mathieu 2016/12/01 21:59:46 yes assume it is translated
csashi 2016/12/02 05:15:29 Done.
+ return suggestion_value;
+ }
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_POPUP);
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698