Skip to content

Commit

Permalink
Make full-form autofill the only implementation on iOS.
Browse files Browse the repository at this point in the history
Removes support for the old field-at-a-time autofill on iOS. Full-form
has been enabled for all iOS users for many months.

Corresponding internal change:
https://chromereviews.googleplex.com/470777015

BUG=504644,268279

Review-Url: https://codereview.chromium.org/2146523004
Cr-Commit-Position: refs/heads/master@{#405237}
  • Loading branch information
justindonnelly authored and Commit bot committed Jul 13, 2016
1 parent 7d0d327 commit 7117ead
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 171 deletions.
2 changes: 0 additions & 2 deletions components/autofill.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@
'conditions': [
['OS=="ios"', {
'sources': [
'autofill/core/browser/autofill_field_trial_ios.cc',
'autofill/core/browser/autofill_field_trial_ios.h',
'autofill/core/browser/keyboard_accessory_metrics_logger.h',
'autofill/core/browser/keyboard_accessory_metrics_logger.mm',
],
Expand Down
2 changes: 0 additions & 2 deletions components/autofill/core/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ source_set("browser") {

if (is_ios) {
sources += [
"autofill_field_trial_ios.cc",
"autofill_field_trial_ios.h",
"keyboard_accessory_metrics_logger.h",
"keyboard_accessory_metrics_logger.mm",
]
Expand Down
33 changes: 0 additions & 33 deletions components/autofill/core/browser/autofill_field_trial_ios.cc

This file was deleted.

28 changes: 0 additions & 28 deletions components/autofill/core/browser/autofill_field_trial_ios.h

This file was deleted.

8 changes: 0 additions & 8 deletions components/autofill/core/browser/autofill_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
#include "url/gurl.h"

#if defined(OS_IOS)
#include "components/autofill/core/browser/autofill_field_trial_ios.h"
#include "components/autofill/core/browser/keyboard_accessory_metrics_logger.h"
#endif

Expand Down Expand Up @@ -595,13 +594,6 @@ bool AutofillManager::WillFillCreditCardNumber(const FormData& form,
if (autofill_field->Type().GetStorableType() == CREDIT_CARD_NUMBER)
return true;

#if defined(OS_IOS)
// On iOS, we only fill out one field at a time (assuming the new full-form
// feature isn't enabled). So we only need to check the current field.
if (!AutofillFieldTrialIOS::IsFullFormAutofillEnabled())
return false;
#endif

// If the relevant section is already autofilled, the new fill operation will
// only fill |autofill_field|.
if (SectionIsAutofilled(*form_structure, form, autofill_field->section()))
Expand Down
26 changes: 2 additions & 24 deletions components/autofill/core/browser/autofill_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -923,20 +923,6 @@ class AutofillManagerTest : public testing::Test {
autofill_manager_->FillOrPreviewCreditCardForm(
AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form,
form->fields[0], *card);

#if defined(OS_IOS)
// Filling out the entire form on iOS requires requesting autofill on each
// of the form fields.
autofill_manager_->FillOrPreviewCreditCardForm(
AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form,
form->fields[1], *card);
autofill_manager_->FillOrPreviewCreditCardForm(
AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form,
form->fields[2], *card);
autofill_manager_->FillOrPreviewCreditCardForm(
AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form,
form->fields[3], *card);
#endif // defined(OS_IOS)
}

// Convenience method to cast the FullCardRequest into a CardUnmaskDelegate.
Expand Down Expand Up @@ -1827,26 +1813,18 @@ TEST_F(AutofillManagerTest, WillFillCreditCardNumber) {
month_field = &form.fields[i];
}

// Empty form - whole form is Autofilled (except on iOS).
// Empty form - whole form is Autofilled.
EXPECT_TRUE(WillFillCreditCardNumber(form, *number_field));
#if defined(OS_IOS)
EXPECT_FALSE(WillFillCreditCardNumber(form, *name_field));
#else
EXPECT_TRUE(WillFillCreditCardNumber(form, *name_field));
#endif // defined(OS_IOS)

// If the user has entered a value, it won't be overridden.
number_field->value = ASCIIToUTF16("gibberish");
EXPECT_TRUE(WillFillCreditCardNumber(form, *number_field));
EXPECT_FALSE(WillFillCreditCardNumber(form, *name_field));

// But if that value is removed, it will be Autofilled (except on iOS).
// But if that value is removed, it will be Autofilled.
number_field->value.clear();
#if defined(OS_IOS)
EXPECT_FALSE(WillFillCreditCardNumber(form, *name_field));
#else
EXPECT_TRUE(WillFillCreditCardNumber(form, *name_field));
#endif // defined(OS_IOS)

// When part of the section is Autofilled, only fill the initiating field.
month_field->is_autofilled = true;
Expand Down
6 changes: 0 additions & 6 deletions components/autofill/core/common/autofill_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ namespace switches {
// credit card form.
const char kDisableCreditCardScan[] = "disable-credit-card-scan";

// Disables the experimental Full Form Autofill on iOS feature.
const char kDisableFullFormAutofillIOS[] = "disable-full-form-autofill-ios";

// Force hiding the local save checkbox in the autofill dialog box for getting
// the full credit card number for a wallet card. The card will never be stored
// locally.
Expand All @@ -36,9 +33,6 @@ const char kDisableSingleClickAutofill[] = "disable-single-click-autofill";
// credit card form.
const char kEnableCreditCardScan[] = "enable-credit-card-scan";

// Enables the experimental Full Form Autofill on iOS feature.
const char kEnableFullFormAutofillIOS[] = "enable-full-form-autofill-ios";

// Force showing the local save checkbox in the autofill dialog box for getting
// the full credit card number for a wallet card.
const char kEnableOfferStoreUnmaskedWalletCards[] =
Expand Down
2 changes: 0 additions & 2 deletions components/autofill/core/common/autofill_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ namespace switches {
// All switches in alphabetical order. The switches should be documented
// alongside the definition of their values in the .cc file.
extern const char kDisableCreditCardScan[];
extern const char kDisableFullFormAutofillIOS[];
extern const char kDisableOfferStoreUnmaskedWalletCards[];
extern const char kDisableOfferUploadCreditCards[];
extern const char kDisablePasswordGeneration[];
extern const char kDisableSingleClickAutofill[];
extern const char kEnableCreditCardScan[];
extern const char kEnableFullFormAutofillIOS[];
extern const char kEnableOfferStoreUnmaskedWalletCards[];
extern const char kEnableOfferUploadCreditCards[];
extern const char kEnablePasswordGeneration[];
Expand Down
11 changes: 1 addition & 10 deletions components/autofill/ios/browser/js_autofill_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,8 @@
completionHandler:
(void (^)(NSString*))completionHandler;

// Stores the current active element. This is used to make the element active
// again in case the web view loses focus when a dialog is presented over it.
- (void)storeActiveElement;

// Clears the current active element.
- (void)clearActiveElement;

// Fills the data in JSON string |dataString| into the active form field, then
// executes the |completionHandler|. The active form field is either
// document.activeElement or the field stored by a call to storeActiveElement.
// non-null.
// executes the |completionHandler|.
- (void)fillActiveFormField:(NSString*)dataString
completionHandler:(ProceduralBlock)completionHandler;

Expand Down
10 changes: 0 additions & 10 deletions components/autofill/ios/browser/js_autofill_manager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ - (NSString*)presenceBeacon {
return @"__gCrWeb.autofill";
}

- (void)storeActiveElement {
NSString* js = @"__gCrWeb.autofill.storeActiveElement()";
[self evaluate:js stringResultHandler:nil];
}

- (void)clearActiveElement {
NSString* js = @"__gCrWeb.autofill.clearActiveElement()";
[self evaluate:js stringResultHandler:nil];
}

- (void)fillActiveFormField:(NSString*)dataString
completionHandler:(ProceduralBlock)completionHandler {
web::JavaScriptCompletion resultHandler = ^void(NSString*, NSError*) {
Expand Down
31 changes: 1 addition & 30 deletions components/autofill/ios/browser/resources/autofill_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,6 @@ __gCrWeb.autofill.ROLE_ATTRIBUTE_PRESENTATION = 0;
*/
__gCrWeb.autofill.lastAutoFilledElement = null;

/**
* The last element that was active (used to restore focus if necessary).
*
* @type {Element}
*/
__gCrWeb.autofill.lastActiveElement = null;

/**
* Whether CSS for autofilled elements has been injected into the page.
*
Expand Down Expand Up @@ -556,34 +549,12 @@ __gCrWeb.autofill['extractForms'] = function(requiredFields) {
};

/**
* Stores the current active element. This is used to make the element active
* again in case the web view loses focus when a dialog is presented over it.
*/
__gCrWeb.autofill['storeActiveElement'] = function() {
__gCrWeb.autofill.lastActiveElement = document.activeElement;
}

/**
* Clears the current active element by setting it to null.
*/
__gCrWeb.autofill['clearActiveElement'] = function() {
__gCrWeb.autofill.lastActiveElement = null;
}

/**
* Fills data into the active form field. The active form field is either
* document.activeElement or the value of lastActiveElement if that value is
* non-null.
* Fills data into the active form field.
*
* @param {AutofillFormFieldData} data The data to fill in.
*/
__gCrWeb.autofill['fillActiveFormField'] = function(data) {
var activeElement = document.activeElement;
if (__gCrWeb.autofill.lastActiveElement) {
activeElement = __gCrWeb.autofill.lastActiveElement;
activeElement.focus();
__gCrWeb.autofill.lastActiveElement = null;
}
if (data['name'] !== __gCrWeb['common'].nameForAutofill(activeElement)) {
return;
}
Expand Down
9 changes: 0 additions & 9 deletions ios/chrome/browser/about_flags.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "base/sys_info.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/dom_distiller/core/dom_distiller_switches.h"
#include "components/flags_ui/feature_entry.h"
#include "components/flags_ui/feature_entry_macros.h"
Expand Down Expand Up @@ -144,14 +143,6 @@ void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
if ([defaults boolForKey:@"EnableCredentialManagement"])
command_line->AppendSwitch(switches::kEnableCredentialManagerAPI);

// Populate command line flags from FullFormAutofill.
NSString* fullFormAutofillValue = [defaults stringForKey:@"FullFormAutofill"];
if ([fullFormAutofillValue isEqualToString:@"Enabled"]) {
command_line->AppendSwitch(autofill::switches::kEnableFullFormAutofillIOS);
} else if ([fullFormAutofillValue isEqualToString:@"Disabled"]) {
command_line->AppendSwitch(autofill::switches::kDisableFullFormAutofillIOS);
}

NSString* autoReloadEnabledValue =
[defaults stringForKey:@"AutoReloadEnabled"];
if ([autoReloadEnabledValue isEqualToString:@"Enabled"]) {
Expand Down
8 changes: 1 addition & 7 deletions ios/chrome/browser/autofill/form_suggestion_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_field_trial_ios.h"
#include "components/autofill/core/browser/autofill_popup_delegate.h"
#import "components/autofill/ios/browser/form_suggestion.h"
#import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h"
Expand Down Expand Up @@ -304,12 +303,7 @@ - (void)didSelectSuggestion:(FormSuggestion*)suggestion {
forField:base::SysUTF8ToNSString(_suggestionState->field_name)
form:base::SysUTF8ToNSString(_suggestionState->form_name)
completionHandler:^{
if (autofill::AutofillFieldTrialIOS::IsFullFormAutofillEnabled()) {
[[weakSelf accessoryViewDelegate] closeKeyboardWithoutButtonPress];
} else {
[[weakSelf accessoryViewDelegate]
selectNextElementWithoutButtonPress];
}
[[weakSelf accessoryViewDelegate] closeKeyboardWithoutButtonPress];
}];
_provider = nil;
}
Expand Down

0 comments on commit 7117ead

Please sign in to comment.