| Index: components/password_manager/content/browser/credential_manager_dispatcher.cc
|
| diff --git a/components/password_manager/content/browser/credential_manager_dispatcher.cc b/components/password_manager/content/browser/credential_manager_dispatcher.cc
|
| index d459cfa4eaac65724b90dcd874cfc65133b1eb3b..8392fb143fc062de593b3294d2c071b99f12540a 100644
|
| --- a/components/password_manager/content/browser/credential_manager_dispatcher.cc
|
| +++ b/components/password_manager/content/browser/credential_manager_dispatcher.cc
|
| @@ -26,6 +26,7 @@ namespace password_manager {
|
| class CredentialManagerDispatcher::PendingRequestTask
|
| : public PasswordStoreConsumer {
|
| public:
|
| + // TODO(mkwst): De-inline the methods in this class. http://goo.gl/RmFwKd
|
| PendingRequestTask(CredentialManagerDispatcher* const dispatcher,
|
| int request_id,
|
| bool request_zero_click_only,
|
| @@ -42,22 +43,19 @@ class CredentialManagerDispatcher::PendingRequestTask
|
| int id() const { return id_; }
|
|
|
| // PasswordStoreConsumer implementation.
|
| - void OnGetPasswordStoreResults(
|
| - const std::vector<autofill::PasswordForm*>& results) override {
|
| + void OnGetPasswordStoreResults() override {
|
| // We own the PasswordForm instances, so we're responsible for cleaning
|
| // up the instances we don't add to |local_results| or |federated_results|.
|
| - //
|
| - // TODO(mkwst): Switch this and PromptUserToChooseCredentials() to use
|
| - // ScopedVector.
|
| - std::vector<autofill::PasswordForm*> local_results;
|
| - std::vector<autofill::PasswordForm*> federated_results;
|
| - for (autofill::PasswordForm* form : results) {
|
| - if (form->origin == origin_)
|
| + ScopedVector<autofill::PasswordForm> local_results;
|
| + ScopedVector<autofill::PasswordForm> federated_results;
|
| + for (auto& form : *results()) {
|
| + if (form->origin == origin_) {
|
| local_results.push_back(form);
|
| - else if (federations_.count(form->origin.spec()))
|
| + form = nullptr;
|
| + } else if (federations_.count(form->origin.spec())) {
|
| federated_results.push_back(form);
|
| - else
|
| - delete form;
|
| + form = nullptr;
|
| + }
|
| }
|
|
|
| if ((local_results.empty() && federated_results.empty()) ||
|
| @@ -73,19 +71,15 @@ class CredentialManagerDispatcher::PendingRequestTask
|
| local_results[0]->federation_url.is_empty()
|
| ? CredentialType::CREDENTIAL_TYPE_LOCAL
|
| : CredentialType::CREDENTIAL_TYPE_FEDERATED);
|
| - STLDeleteElements(&local_results);
|
| - STLDeleteElements(&federated_results);
|
| dispatcher_->SendCredential(id_, info);
|
| return;
|
| }
|
|
|
| if (zero_click_only_ ||
|
| !dispatcher_->client()->PromptUserToChooseCredentials(
|
| - local_results, federated_results,
|
| + local_results.Pass(), federated_results.Pass(),
|
| base::Bind(&CredentialManagerDispatcher::SendCredential,
|
| base::Unretained(dispatcher_), id_))) {
|
| - STLDeleteElements(&local_results);
|
| - STLDeleteElements(&federated_results);
|
| dispatcher_->SendCredential(id_, CredentialInfo());
|
| }
|
| }
|
|
|