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

Side by Side Diff: components/password_manager/content/browser/credential_manager_impl.cc

Issue 2592653003: Avoid use-after-free in FormFetcherImpl (Closed)
Patch Set: Typos Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/password_manager/core/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/password_manager/content/browser/credential_manager_impl.h" 5 #include "components/password_manager/content/browser/credential_manager_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/metrics/user_metrics.h" 11 #include "base/metrics/user_metrics.h"
11 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "components/autofill/core/common/password_form.h" 14 #include "components/autofill/core/common/password_form.h"
14 #include "components/password_manager/content/browser/content_password_manager_d river.h" 15 #include "components/password_manager/content/browser/content_password_manager_d river.h"
15 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h" 16 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h"
16 #include "components/password_manager/core/browser/affiliated_match_helper.h" 17 #include "components/password_manager/core/browser/affiliated_match_helper.h"
17 #include "components/password_manager/core/browser/credential_manager_logger.h" 18 #include "components/password_manager/core/browser/credential_manager_logger.h"
19 #include "components/password_manager/core/browser/form_saver.h"
18 #include "components/password_manager/core/browser/password_manager_client.h" 20 #include "components/password_manager/core/browser/password_manager_client.h"
19 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 21 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
20 #include "components/password_manager/core/browser/password_manager_util.h" 22 #include "components/password_manager/core/browser/password_manager_util.h"
21 #include "components/password_manager/core/browser/password_store.h" 23 #include "components/password_manager/core/browser/password_store.h"
22 #include "components/password_manager/core/common/credential_manager_types.h" 24 #include "components/password_manager/core/common/credential_manager_types.h"
23 #include "components/password_manager/core/common/password_manager_pref_names.h" 25 #include "components/password_manager/core/common/password_manager_pref_names.h"
24 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
25 27
26 namespace password_manager { 28 namespace password_manager {
27 29
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (!client_->IsSavingAndFillingEnabledForCurrentPage() || 69 if (!client_->IsSavingAndFillingEnabledForCurrentPage() ||
68 !client_->OnCredentialManagerUsed()) 70 !client_->OnCredentialManagerUsed())
69 return; 71 return;
70 72
71 client_->NotifyStorePasswordCalled(); 73 client_->NotifyStorePasswordCalled();
72 74
73 GURL origin = web_contents()->GetLastCommittedURL().GetOrigin(); 75 GURL origin = web_contents()->GetLastCommittedURL().GetOrigin();
74 std::unique_ptr<autofill::PasswordForm> form( 76 std::unique_ptr<autofill::PasswordForm> form(
75 CreatePasswordFormFromCredentialInfo(credential, origin)); 77 CreatePasswordFormFromCredentialInfo(credential, origin));
76 78
77 form_manager_.reset(new CredentialManagerPasswordFormManager( 79 form_manager_ = base::MakeUnique<CredentialManagerPasswordFormManager>(
78 client_, GetDriver(), *CreateObservedPasswordFormFromOrigin(origin), 80 client_, GetDriver(), *CreateObservedPasswordFormFromOrigin(origin),
79 std::move(form), this)); 81 std::move(form), this, nullptr, nullptr);
80 } 82 }
81 83
82 void CredentialManagerImpl::OnProvisionalSaveComplete() { 84 void CredentialManagerImpl::OnProvisionalSaveComplete() {
83 DCHECK(form_manager_); 85 DCHECK(form_manager_);
84 DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage()); 86 DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage());
85 const autofill::PasswordForm& form = form_manager_->pending_credentials(); 87 const autofill::PasswordForm& form = form_manager_->pending_credentials();
86 88
87 if (!form.federation_origin.unique()) { 89 if (!form.federation_origin.unique()) {
88 // If this is a federated credential, check it against the federated matches 90 // If this is a federated credential, check it against the federated matches
89 // produced by the PasswordFormManager. If a match is found, update it and 91 // produced by the PasswordFormManager. If a match is found, update it and
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 PasswordStore::FormDigest CredentialManagerImpl::GetSynthesizedFormForOrigin() 267 PasswordStore::FormDigest CredentialManagerImpl::GetSynthesizedFormForOrigin()
266 const { 268 const {
267 PasswordStore::FormDigest digest = { 269 PasswordStore::FormDigest digest = {
268 autofill::PasswordForm::SCHEME_HTML, std::string(), 270 autofill::PasswordForm::SCHEME_HTML, std::string(),
269 web_contents()->GetLastCommittedURL().GetOrigin()}; 271 web_contents()->GetLastCommittedURL().GetOrigin()};
270 digest.signon_realm = digest.origin.spec(); 272 digest.signon_realm = digest.origin.spec();
271 return digest; 273 return digest;
272 } 274 }
273 275
274 } // namespace password_manager 276 } // namespace password_manager
OLDNEW
« no previous file with comments | « no previous file | components/password_manager/core/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698