Commit a9e390c4 authored by vabr@chromium.org's avatar vabr@chromium.org

Fix style in PasswordManager and PasswordAutofillAgent .cc files

This CL contains only style-related clean-up.
The purpose is to allow other CLs (like https://codereview.chromium.org/231283003/) make whole-file clang-format without inducing many unrelated changes.

Putting Ilya in TBR, because of https://codereview.chromium.org/231283003/diff/200001/components/autofill/content/renderer/password_autofill_agent.cc#newcode280

TBR=isherman@chromium.org
BUG=347927

Review URL: https://codereview.chromium.org/254573005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266318 0039d316-1c4b-4281-b951-d872f2087c98
parent 0a4b8695
...@@ -39,8 +39,7 @@ namespace { ...@@ -39,8 +39,7 @@ namespace {
static const size_t kMaximumTextSizeForAutocomplete = 1000; static const size_t kMaximumTextSizeForAutocomplete = 1000;
// Maps element names to the actual elements to simplify form filling. // Maps element names to the actual elements to simplify form filling.
typedef std::map<base::string16, blink::WebInputElement> typedef std::map<base::string16, blink::WebInputElement> FormInputElementMap;
FormInputElementMap;
// Utility struct for form lookup and autofill. When we parse the DOM to look up // Utility struct for form lookup and autofill. When we parse the DOM to look up
// a form, in addition to action and origin URL's we have to compare all // a form, in addition to action and origin URL's we have to compare all
...@@ -213,12 +212,15 @@ PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view) ...@@ -213,12 +212,15 @@ PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view)
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
} }
PasswordAutofillAgent::~PasswordAutofillAgent() {} PasswordAutofillAgent::~PasswordAutofillAgent() {
}
PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper()
: was_user_gesture_seen_(false) {} : was_user_gesture_seen_(false) {
}
PasswordAutofillAgent::PasswordValueGatekeeper::~PasswordValueGatekeeper() {} PasswordAutofillAgent::PasswordValueGatekeeper::~PasswordValueGatekeeper() {
}
void PasswordAutofillAgent::PasswordValueGatekeeper::RegisterElement( void PasswordAutofillAgent::PasswordValueGatekeeper::RegisterElement(
blink::WebInputElement* element) { blink::WebInputElement* element) {
...@@ -258,8 +260,7 @@ bool PasswordAutofillAgent::TextFieldDidEndEditing( ...@@ -258,8 +260,7 @@ bool PasswordAutofillAgent::TextFieldDidEndEditing(
if (iter == login_to_password_info_.end()) if (iter == login_to_password_info_.end())
return false; return false;
const PasswordFormFillData& fill_data = const PasswordFormFillData& fill_data = iter->second.fill_data;
iter->second.fill_data;
// If wait_for_username is false, we should have filled when the text changed. // If wait_for_username is false, we should have filled when the text changed.
if (!fill_data.wait_for_username) if (!fill_data.wait_for_username)
...@@ -273,7 +274,9 @@ bool PasswordAutofillAgent::TextFieldDidEndEditing( ...@@ -273,7 +274,9 @@ bool PasswordAutofillAgent::TextFieldDidEndEditing(
// Do not set selection when ending an editing session, otherwise it can // Do not set selection when ending an editing session, otherwise it can
// mess with focus. // mess with focus.
FillUserNameAndPassword(&username, &password, fill_data, FillUserNameAndPassword(&username,
&password,
fill_data,
true /* exact_username_match */, true /* exact_username_match */,
false /* set_selection */); false /* set_selection */);
return true; return true;
...@@ -462,7 +465,8 @@ bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { ...@@ -462,7 +465,8 @@ bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) {
void PasswordAutofillAgent::DidStartLoading() { void PasswordAutofillAgent::DidStartLoading() {
if (usernames_usage_ != NOTHING_TO_AUTOFILL) { if (usernames_usage_ != NOTHING_TO_AUTOFILL) {
UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage",
usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); usernames_usage_,
OTHER_POSSIBLE_USERNAMES_MAX);
usernames_usage_ = NOTHING_TO_AUTOFILL; usernames_usage_ = NOTHING_TO_AUTOFILL;
} }
} }
...@@ -563,8 +567,7 @@ void PasswordAutofillAgent::DidStartProvisionalLoad( ...@@ -563,8 +567,7 @@ void PasswordAutofillAgent::DidStartProvisionalLoad(
// If onsubmit has been called, try and save that form. // If onsubmit has been called, try and save that form.
if (provisionally_saved_forms_[form_frame].get()) { if (provisionally_saved_forms_[form_frame].get()) {
Send(new AutofillHostMsg_PasswordFormSubmitted( Send(new AutofillHostMsg_PasswordFormSubmitted(
routing_id(), routing_id(), *provisionally_saved_forms_[form_frame]));
*provisionally_saved_forms_[form_frame]));
provisionally_saved_forms_.erase(form_frame); provisionally_saved_forms_.erase(form_frame);
} else { } else {
// Loop through the forms on the page looking for one that has been // Loop through the forms on the page looking for one that has been
...@@ -573,15 +576,14 @@ void PasswordAutofillAgent::DidStartProvisionalLoad( ...@@ -573,15 +576,14 @@ void PasswordAutofillAgent::DidStartProvisionalLoad(
frame->document().forms(forms); frame->document().forms(forms);
for (size_t i = 0; i < forms.size(); ++i) { for (size_t i = 0; i < forms.size(); ++i) {
blink::WebFormElement form_element= forms[i]; blink::WebFormElement form_element = forms[i];
scoped_ptr<PasswordForm> password_form( scoped_ptr<PasswordForm> password_form(
CreatePasswordForm(form_element)); CreatePasswordForm(form_element));
if (password_form.get() && if (password_form.get() && !password_form->username_value.empty() &&
!password_form->username_value.empty() &&
!password_form->password_value.empty() && !password_form->password_value.empty() &&
!PasswordValueIsDefault(*password_form, form_element)) { !PasswordValueIsDefault(*password_form, form_element)) {
Send(new AutofillHostMsg_PasswordFormSubmitted( Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
routing_id(), *password_form)); *password_form));
} }
} }
} }
...@@ -642,9 +644,7 @@ void PasswordAutofillAgent::OnFillPasswordForm( ...@@ -642,9 +644,7 @@ void PasswordAutofillAgent::OnFillPasswordForm(
FindFormAndFieldForFormControlElement( FindFormAndFieldForFormControlElement(
username_element, &form, &field, REQUIRE_NONE); username_element, &form, &field, REQUIRE_NONE);
Send(new AutofillHostMsg_AddPasswordFormMapping( Send(new AutofillHostMsg_AddPasswordFormMapping(
routing_id(), routing_id(), field, form_data));
field,
form_data));
} }
} }
...@@ -663,7 +663,8 @@ void PasswordAutofillAgent::GetSuggestions( ...@@ -663,7 +663,8 @@ void PasswordAutofillAgent::GetSuggestions(
for (PasswordFormFillData::LoginCollection::const_iterator iter = for (PasswordFormFillData::LoginCollection::const_iterator iter =
fill_data.additional_logins.begin(); fill_data.additional_logins.begin();
iter != fill_data.additional_logins.end(); ++iter) { iter != fill_data.additional_logins.end();
++iter) {
if (StartsWith(iter->first, input, false)) { if (StartsWith(iter->first, input, false)) {
suggestions->push_back(iter->first); suggestions->push_back(iter->first);
realms->push_back(base::UTF8ToUTF16(iter->second.realm)); realms->push_back(base::UTF8ToUTF16(iter->second.realm));
...@@ -672,7 +673,8 @@ void PasswordAutofillAgent::GetSuggestions( ...@@ -672,7 +673,8 @@ void PasswordAutofillAgent::GetSuggestions(
for (PasswordFormFillData::UsernamesCollection::const_iterator iter = for (PasswordFormFillData::UsernamesCollection::const_iterator iter =
fill_data.other_possible_usernames.begin(); fill_data.other_possible_usernames.begin();
iter != fill_data.other_possible_usernames.end(); ++iter) { iter != fill_data.other_possible_usernames.end();
++iter) {
for (size_t i = 0; i < iter->second.size(); ++i) { for (size_t i = 0; i < iter->second.size(); ++i) {
if (StartsWith(iter->second[i], input, false)) { if (StartsWith(iter->second[i], input, false)) {
usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN; usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN;
...@@ -712,11 +714,8 @@ bool PasswordAutofillAgent::ShowSuggestionPopup( ...@@ -712,11 +714,8 @@ bool PasswordAutofillAgent::ShowSuggestionPopup(
bounding_box.y() * scale, bounding_box.y() * scale,
bounding_box.width() * scale, bounding_box.width() * scale,
bounding_box.height() * scale); bounding_box.height() * scale);
Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), Send(new AutofillHostMsg_ShowPasswordSuggestions(
field, routing_id(), field, bounding_box_scaled, suggestions, realms));
bounding_box_scaled,
suggestions,
realms));
return !suggestions.empty(); return !suggestions.empty();
} }
...@@ -747,7 +746,9 @@ void PasswordAutofillAgent::FillFormOnPasswordRecieved( ...@@ -747,7 +746,9 @@ void PasswordAutofillAgent::FillFormOnPasswordRecieved(
// Fill if we have an exact match for the username. Note that this sets // Fill if we have an exact match for the username. Note that this sets
// username to autofilled. // username to autofilled.
FillUserNameAndPassword(&username_element, &password_element, fill_data, FillUserNameAndPassword(&username_element,
&password_element,
fill_data,
true /* exact_username_match */, true /* exact_username_match */,
false /* set_selection */); false /* set_selection */);
} }
...@@ -764,7 +765,8 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( ...@@ -764,7 +765,8 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
base::string16 password; base::string16 password;
// Look for any suitable matches to current field text. // Look for any suitable matches to current field text.
if (DoUsernamesMatch(fill_data.basic_data.fields[0].value, current_username, if (DoUsernamesMatch(fill_data.basic_data.fields[0].value,
current_username,
exact_username_match)) { exact_username_match)) {
username = fill_data.basic_data.fields[0].value; username = fill_data.basic_data.fields[0].value;
password = fill_data.basic_data.fields[1].value; password = fill_data.basic_data.fields[1].value;
...@@ -772,9 +774,10 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( ...@@ -772,9 +774,10 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
// Scan additional logins for a match. // Scan additional logins for a match.
PasswordFormFillData::LoginCollection::const_iterator iter; PasswordFormFillData::LoginCollection::const_iterator iter;
for (iter = fill_data.additional_logins.begin(); for (iter = fill_data.additional_logins.begin();
iter != fill_data.additional_logins.end(); ++iter) { iter != fill_data.additional_logins.end();
if (DoUsernamesMatch(iter->first, current_username, ++iter) {
exact_username_match)) { if (DoUsernamesMatch(
iter->first, current_username, exact_username_match)) {
username = iter->first; username = iter->first;
password = iter->second.password; password = iter->second.password;
break; break;
...@@ -785,10 +788,11 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( ...@@ -785,10 +788,11 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
if (username.empty() && password.empty()) { if (username.empty() && password.empty()) {
for (PasswordFormFillData::UsernamesCollection::const_iterator iter = for (PasswordFormFillData::UsernamesCollection::const_iterator iter =
fill_data.other_possible_usernames.begin(); fill_data.other_possible_usernames.begin();
iter != fill_data.other_possible_usernames.end(); ++iter) { iter != fill_data.other_possible_usernames.end();
++iter) {
for (size_t i = 0; i < iter->second.size(); ++i) { for (size_t i = 0; i < iter->second.size(); ++i) {
if (DoUsernamesMatch(iter->second[i], current_username, if (DoUsernamesMatch(
exact_username_match)) { iter->second[i], current_username, exact_username_match)) {
usernames_usage_ = OTHER_POSSIBLE_USERNAME_SELECTED; usernames_usage_ = OTHER_POSSIBLE_USERNAME_SELECTED;
username = iter->second[i]; username = iter->second[i];
password = iter->first.password; password = iter->first.password;
...@@ -856,11 +860,12 @@ void PasswordAutofillAgent::PerformInlineAutocomplete( ...@@ -856,11 +860,12 @@ void PasswordAutofillAgent::PerformInlineAutocomplete(
// Show the popup with the list of available usernames. // Show the popup with the list of available usernames.
ShowSuggestionPopup(fill_data, username); ShowSuggestionPopup(fill_data, username);
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// Fill the user and password field with the most relevant match. Android // Fill the user and password field with the most relevant match. Android
// only fills in the fields after the user clicks on the suggestion popup. // only fills in the fields after the user clicks on the suggestion popup.
FillUserNameAndPassword(&username, &password, fill_data, FillUserNameAndPassword(&username,
&password,
fill_data,
false /* exact_username_match */, false /* exact_username_match */,
true /* set_selection */); true /* set_selection */);
#endif #endif
......
...@@ -85,9 +85,9 @@ PasswordManager::~PasswordManager() { ...@@ -85,9 +85,9 @@ PasswordManager::~PasswordManager() {
void PasswordManager::SetFormHasGeneratedPassword(const PasswordForm& form) { void PasswordManager::SetFormHasGeneratedPassword(const PasswordForm& form) {
for (ScopedVector<PasswordFormManager>::iterator iter = for (ScopedVector<PasswordFormManager>::iterator iter =
pending_login_managers_.begin(); pending_login_managers_.begin();
iter != pending_login_managers_.end(); ++iter) { iter != pending_login_managers_.end();
if ((*iter)->DoesManage( ++iter) {
form, PasswordFormManager::ACTION_MATCH_REQUIRED)) { if ((*iter)->DoesManage(form, PasswordFormManager::ACTION_MATCH_REQUIRED)) {
(*iter)->SetHasGeneratedPassword(); (*iter)->SetHasGeneratedPassword();
return; return;
} }
...@@ -97,8 +97,8 @@ void PasswordManager::SetFormHasGeneratedPassword(const PasswordForm& form) { ...@@ -97,8 +97,8 @@ void PasswordManager::SetFormHasGeneratedPassword(const PasswordForm& form) {
// ability to detect forms. // ability to detect forms.
bool ssl_valid = (form.origin.SchemeIsSecure() && bool ssl_valid = (form.origin.SchemeIsSecure() &&
!driver_->DidLastPageLoadEncounterSSLErrors()); !driver_->DidLastPageLoadEncounterSSLErrors());
PasswordFormManager* manager = new PasswordFormManager( PasswordFormManager* manager =
this, client_, driver_, form, ssl_valid); new PasswordFormManager(this, client_, driver_, form, ssl_valid);
pending_login_managers_.push_back(manager); pending_login_managers_.push_back(manager);
manager->SetHasGeneratedPassword(); manager->SetHasGeneratedPassword();
// TODO(gcasto): Add UMA stats to track this. // TODO(gcasto): Add UMA stats to track this.
...@@ -125,18 +125,18 @@ void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { ...@@ -125,18 +125,18 @@ void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) {
pending_login_managers_.end(); pending_login_managers_.end();
for (ScopedVector<PasswordFormManager>::iterator iter = for (ScopedVector<PasswordFormManager>::iterator iter =
pending_login_managers_.begin(); pending_login_managers_.begin();
iter != pending_login_managers_.end(); ++iter) { iter != pending_login_managers_.end();
// If we find a manager that exactly matches the submitted form including ++iter) {
// the action URL, exit the loop. if ((*iter)->DoesManage(form, PasswordFormManager::ACTION_MATCH_REQUIRED)) {
if ((*iter)->DoesManage( // If we find a manager that exactly matches the submitted form including
form, PasswordFormManager::ACTION_MATCH_REQUIRED)) { // the action URL, exit the loop.
matched_manager_it = iter; matched_manager_it = iter;
break; break;
// If the current manager matches the submitted form excluding the action
// URL, remember it as a candidate and continue searching for an exact
// match.
} else if ((*iter)->DoesManage( } else if ((*iter)->DoesManage(
form, PasswordFormManager::ACTION_MATCH_NOT_REQUIRED)) { form, PasswordFormManager::ACTION_MATCH_NOT_REQUIRED)) {
// If the current manager matches the submitted form excluding the action
// URL, remember it as a candidate and continue searching for an exact
// match.
matched_manager_it = iter; matched_manager_it = iter;
} }
} }
...@@ -179,8 +179,7 @@ void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { ...@@ -179,8 +179,7 @@ void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) {
// Chrome to manage such passwords. For other passwords, respect the // Chrome to manage such passwords. For other passwords, respect the
// autocomplete attribute if autocomplete='off' is not ignored. // autocomplete attribute if autocomplete='off' is not ignored.
if (!autofill::ShouldIgnoreAutocompleteOffForPasswordFields() && if (!autofill::ShouldIgnoreAutocompleteOffForPasswordFields() &&
!manager->HasGeneratedPassword() && !manager->HasGeneratedPassword() && !form.password_autocomplete_set) {
!form.password_autocomplete_set) {
RecordFailure(AUTOCOMPLETE_OFF, form.origin.host()); RecordFailure(AUTOCOMPLETE_OFF, form.origin.host());
return; return;
} }
...@@ -200,8 +199,8 @@ void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { ...@@ -200,8 +199,8 @@ void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) {
void PasswordManager::RecordFailure(ProvisionalSaveFailure failure, void PasswordManager::RecordFailure(ProvisionalSaveFailure failure,
const std::string& form_origin) { const std::string& form_origin) {
UMA_HISTOGRAM_ENUMERATION("PasswordManager.ProvisionalSaveFailure", UMA_HISTOGRAM_ENUMERATION(
failure, MAX_FAILURE_VALUE); "PasswordManager.ProvisionalSaveFailure", failure, MAX_FAILURE_VALUE);
std::string group_name = metrics_util::GroupIdToString( std::string group_name = metrics_util::GroupIdToString(
metrics_util::MonitoredDomainGroupId(form_origin, client_->GetPrefs())); metrics_util::MonitoredDomainGroupId(form_origin, client_->GetPrefs()));
...@@ -251,15 +250,16 @@ void PasswordManager::OnPasswordFormsParsed( ...@@ -251,15 +250,16 @@ void PasswordManager::OnPasswordFormsParsed(
bool had_ssl_error = driver_->DidLastPageLoadEncounterSSLErrors(); bool had_ssl_error = driver_->DidLastPageLoadEncounterSSLErrors();
for (std::vector<PasswordForm>::const_iterator iter = forms.begin(); for (std::vector<PasswordForm>::const_iterator iter = forms.begin();
iter != forms.end(); ++iter) { iter != forms.end();
++iter) {
// Don't involve the password manager if this form corresponds to // Don't involve the password manager if this form corresponds to
// SpdyProxy authentication, as indicated by the realm. // SpdyProxy authentication, as indicated by the realm.
if (EndsWith(iter->signon_realm, kSpdyProxyRealm, true)) if (EndsWith(iter->signon_realm, kSpdyProxyRealm, true))
continue; continue;
bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error; bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error;
PasswordFormManager* manager = new PasswordFormManager( PasswordFormManager* manager =
this, client_, driver_, *iter, ssl_valid); new PasswordFormManager(this, client_, driver_, *iter, ssl_valid);
pending_login_managers_.push_back(manager); pending_login_managers_.push_back(manager);
// Avoid prompting the user for access to a password if they don't have // Avoid prompting the user for access to a password if they don't have
...@@ -320,7 +320,8 @@ void PasswordManager::PossiblyInitializeUsernamesExperiment( ...@@ -320,7 +320,8 @@ void PasswordManager::PossiblyInitializeUsernamesExperiment(
bool other_possible_usernames_exist = false; bool other_possible_usernames_exist = false;
for (autofill::PasswordFormMap::const_iterator it = best_matches.begin(); for (autofill::PasswordFormMap::const_iterator it = best_matches.begin();
it != best_matches.end(); ++it) { it != best_matches.end();
++it) {
if (!it->second->other_possible_usernames.empty()) { if (!it->second->other_possible_usernames.empty()) {
other_possible_usernames_exist = true; other_possible_usernames_exist = true;
break; break;
...@@ -346,14 +347,13 @@ void PasswordManager::PossiblyInitializeUsernamesExperiment( ...@@ -346,14 +347,13 @@ void PasswordManager::PossiblyInitializeUsernamesExperiment(
bool PasswordManager::OtherPossibleUsernamesEnabled() const { bool PasswordManager::OtherPossibleUsernamesEnabled() const {
return base::FieldTrialList::FindFullName( return base::FieldTrialList::FindFullName(
kOtherPossibleUsernamesExperiment) == "Enabled"; kOtherPossibleUsernamesExperiment) == "Enabled";
} }
void PasswordManager::Autofill( void PasswordManager::Autofill(const PasswordForm& form_for_autofill,
const PasswordForm& form_for_autofill, const PasswordFormMap& best_matches,
const PasswordFormMap& best_matches, const PasswordForm& preferred_match,
const PasswordForm& preferred_match, bool wait_for_username) const {
bool wait_for_username) const {
PossiblyInitializeUsernamesExperiment(best_matches); PossiblyInitializeUsernamesExperiment(best_matches);
// TODO(tedchoc): Switch to only requesting authentication if the user is // TODO(tedchoc): Switch to only requesting authentication if the user is
...@@ -361,7 +361,8 @@ void PasswordManager::Autofill( ...@@ -361,7 +361,8 @@ void PasswordManager::Autofill(
// of on page load. // of on page load.
bool authentication_required = preferred_match.use_additional_authentication; bool authentication_required = preferred_match.use_additional_authentication;
for (autofill::PasswordFormMap::const_iterator it = best_matches.begin(); for (autofill::PasswordFormMap::const_iterator it = best_matches.begin();
!authentication_required && it != best_matches.end(); ++it) { !authentication_required && it != best_matches.end();
++it) {
if (it->second->use_additional_authentication) if (it->second->use_additional_authentication)
authentication_required = true; authentication_required = true;
} }
......
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