Commit 1fdadcba authored by Christos Froussios's avatar Christos Froussios Committed by Commit Bot

[Password Manager] Split AUTOFILLED field flag

The flag currently indicates that the field was autofilled, regardless
of the trigger for autofilling.

We will now identify two triggers separately.
1. AUTOFILLED_ON_USER_TRIGGER. This refers to Fill On Account Select in
the context of the password manager. It also the current default
behaviour for Autofill.
2. AUTOFILLED_ON_PAGELOAD. Password manager determined that a password
form is a login form and filled the credentials as soon as the page was
loaded.

Any conditions which took AUTOFILLED into account are made to work with
either of the new flags.

Bug: 867348
Change-Id: I2eb5fea7219ce784822174de24e76b3e1e4f1f15
Reviewed-on: https://chromium-review.googlesource.com/1169060Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Christos Froussios <cfroussios@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582121}
parent 6cacb2df
...@@ -897,9 +897,9 @@ void PasswordAutofillAgent::FillField(WebInputElement* input, ...@@ -897,9 +897,9 @@ void PasswordAutofillAgent::FillField(WebInputElement* input,
DCHECK(!input->IsNull()); DCHECK(!input->IsNull());
input->SetAutofillValue(WebString::FromUTF16(credential)); input->SetAutofillValue(WebString::FromUTF16(credential));
input->SetAutofillState(WebAutofillState::kAutofilled); input->SetAutofillState(WebAutofillState::kAutofilled);
UpdateFieldValueAndPropertiesMaskMap(*input, &credential, UpdateFieldValueAndPropertiesMaskMap(
FieldPropertiesFlags::AUTOFILLED, *input, &credential, FieldPropertiesFlags::AUTOFILLED_ON_USER_TRIGGER,
&field_value_and_properties_map_); &field_value_and_properties_map_);
} }
void PasswordAutofillAgent::FillPasswordFieldAndSave( void PasswordAutofillAgent::FillPasswordFieldAndSave(
...@@ -1876,9 +1876,10 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( ...@@ -1876,9 +1876,10 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
} }
} }
UpdateFieldValueAndPropertiesMaskMap(*username_element, &username, UpdateFieldValueAndPropertiesMaskMap(
FieldPropertiesFlags::AUTOFILLED, *username_element, &username,
field_value_and_properties_map); FieldPropertiesFlags::AUTOFILLED_ON_PAGELOAD,
field_value_and_properties_map);
username_element->SetAutofillState(WebAutofillState::kAutofilled); username_element->SetAutofillState(WebAutofillState::kAutofilled);
if (logger) if (logger)
logger->LogElementName(Logger::STRING_USERNAME_FILLED, *username_element); logger->LogElementName(Logger::STRING_USERNAME_FILLED, *username_element);
...@@ -1889,9 +1890,10 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( ...@@ -1889,9 +1890,10 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
// user is intentionally interacting with the page. // user is intentionally interacting with the page.
if (password_element->Value().Utf16() != password) if (password_element->Value().Utf16() != password)
password_element->SetSuggestedValue(WebString::FromUTF16(password)); password_element->SetSuggestedValue(WebString::FromUTF16(password));
UpdateFieldValueAndPropertiesMaskMap(*password_element, &password, UpdateFieldValueAndPropertiesMaskMap(
FieldPropertiesFlags::AUTOFILLED, *password_element, &password,
field_value_and_properties_map); FieldPropertiesFlags::AUTOFILLED_ON_PAGELOAD,
field_value_and_properties_map);
ProvisionallySavePassword(password_element->Form(), *password_element, ProvisionallySavePassword(password_element->Form(), *password_element,
RESTRICTION_NONE); RESTRICTION_NONE);
gatekeeper_.RegisterElement(password_element); gatekeeper_.RegisterElement(password_element);
......
...@@ -28,13 +28,19 @@ enum FieldPropertiesFlags { ...@@ -28,13 +28,19 @@ enum FieldPropertiesFlags {
// being autofilled. This is different from // being autofilled. This is different from
// WebFormControlElement::IsAutofilled(). It is meant to be used for password // WebFormControlElement::IsAutofilled(). It is meant to be used for password
// fields, to determine whether viewing the value needs user reauthentication. // fields, to determine whether viewing the value needs user reauthentication.
AUTOFILLED = 1u << 1, AUTOFILLED_ON_USER_TRIGGER = 1u << 1,
// The field received focus at any moment.
HAD_FOCUS = 1u << 2, HAD_FOCUS = 1u << 2,
// Use this flag, if some error occurred in flags processing. // Use this flag, if some error occurred in flags processing.
ERROR_OCCURRED = 1u << 3, ERROR_OCCURRED = 1u << 3,
// On submission, the value of the field was recognised as a value which is // On submission, the value of the field was recognised as a value which is
// already stored. // already stored.
KNOWN_VALUE = 1u << 4 KNOWN_VALUE = 1u << 4,
// A value was autofilled on pageload. This means that at least one character
// of the field value comes from being autofilled.
AUTOFILLED_ON_PAGELOAD = 1u << 5,
// A value was autofilled on any of the triggers.
AUTOFILLED = AUTOFILLED_ON_USER_TRIGGER | AUTOFILLED_ON_PAGELOAD,
}; };
// FieldPropertiesMask is used to contain combinations of FieldPropertiesFlags // FieldPropertiesMask is used to contain combinations of FieldPropertiesFlags
......
...@@ -168,10 +168,14 @@ std::string BrowserSavePasswordProgressLogger::FormStructureToFieldsLogString( ...@@ -168,10 +168,14 @@ std::string BrowserSavePasswordProgressLogger::FormStructureToFieldsLogString(
(field->properties_mask & autofill::FieldPropertiesFlags::USER_TYPED) (field->properties_mask & autofill::FieldPropertiesFlags::USER_TYPED)
? "T" ? "T"
: "_"; : "_";
field_info += field_info += (field->properties_mask &
(field->properties_mask & autofill::FieldPropertiesFlags::AUTOFILLED) autofill::FieldPropertiesFlags::AUTOFILLED_ON_PAGELOAD)
? "A" ? "Ap"
: "_"; : "__";
field_info += (field->properties_mask &
autofill::FieldPropertiesFlags::AUTOFILLED_ON_USER_TRIGGER)
? "Au"
: "__";
field_info += field_info +=
(field->properties_mask & autofill::FieldPropertiesFlags::HAD_FOCUS) (field->properties_mask & autofill::FieldPropertiesFlags::HAD_FOCUS)
? "F" ? "F"
......
...@@ -896,13 +896,34 @@ TEST(FormParserTest, ReadonlyFields) { ...@@ -896,13 +896,34 @@ TEST(FormParserTest, ReadonlyFields) {
}, },
{ {
.description_for_logging = "And passwords already filled by user or " .description_for_logging = "And passwords already filled by user or "
"Chrome are accepted even if " "Chrome on pageload are accepted even if "
"readonly", "readonly",
.fields = .fields =
{ {
{.role = ElementRole::USERNAME, .form_control_type = "text"}, {.role = ElementRole::USERNAME, .form_control_type = "text"},
{.role = ElementRole::CURRENT_PASSWORD, {.role = ElementRole::CURRENT_PASSWORD,
.properties_mask = FieldPropertiesFlags::AUTOFILLED, .properties_mask =
FieldPropertiesFlags::AUTOFILLED_ON_PAGELOAD,
.form_control_type = "password",
.is_readonly = true},
{.role = ElementRole::NEW_PASSWORD,
.properties_mask = FieldPropertiesFlags::USER_TYPED,
.form_control_type = "password",
.is_readonly = true},
{.form_control_type = "password", .is_readonly = true},
},
.number_of_all_possible_passwords = 3,
},
{
.description_for_logging = "And passwords already filled by user or "
"Chrome with FOAS are accepted even if "
"readonly",
.fields =
{
{.role = ElementRole::USERNAME, .form_control_type = "text"},
{.role = ElementRole::CURRENT_PASSWORD,
.properties_mask =
FieldPropertiesFlags::AUTOFILLED_ON_USER_TRIGGER,
.form_control_type = "password", .form_control_type = "password",
.is_readonly = true}, .is_readonly = true},
{.role = ElementRole::NEW_PASSWORD, {.role = ElementRole::NEW_PASSWORD,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment