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

Unified Diff: components/password_manager/content/browser/credential_manager_dispatcher.cc

Issue 866983003: GetLoginsRequest: Use ScopedVector to express ownership of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@324291_scopedvector
Patch Set: Rebased Created 5 years, 11 months 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/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());
}
}

Powered by Google App Engine
This is Rietveld 408576698