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

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

Issue 2592653003: Avoid use-after-free in FormFetcherImpl (Closed)
Patch Set: Posting CMPFM method instead of the delegate method Created 3 years, 12 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 unified diff | Download patch
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_fetcher.h"
20 #include "components/password_manager/core/browser/form_saver.h"
vasilii 2016/12/21 11:00:49 I think both headers are unused.
vabr (Chromium) 2016/12/21 11:35:25 They are not. On line 82, there are two nullptr pa
18 #include "components/password_manager/core/browser/password_manager_client.h" 21 #include "components/password_manager/core/browser/password_manager_client.h"
19 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 22 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
20 #include "components/password_manager/core/browser/password_manager_util.h" 23 #include "components/password_manager/core/browser/password_manager_util.h"
21 #include "components/password_manager/core/browser/password_store.h" 24 #include "components/password_manager/core/browser/password_store.h"
22 #include "components/password_manager/core/common/credential_manager_types.h" 25 #include "components/password_manager/core/common/credential_manager_types.h"
23 #include "components/password_manager/core/common/password_manager_pref_names.h" 26 #include "components/password_manager/core/common/password_manager_pref_names.h"
24 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
25 28
26 namespace password_manager { 29 namespace password_manager {
27 30
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (!client_->IsSavingAndFillingEnabledForCurrentPage() || 70 if (!client_->IsSavingAndFillingEnabledForCurrentPage() ||
68 !client_->OnCredentialManagerUsed()) 71 !client_->OnCredentialManagerUsed())
69 return; 72 return;
70 73
71 client_->NotifyStorePasswordCalled(); 74 client_->NotifyStorePasswordCalled();
72 75
73 GURL origin = web_contents()->GetLastCommittedURL().GetOrigin(); 76 GURL origin = web_contents()->GetLastCommittedURL().GetOrigin();
74 std::unique_ptr<autofill::PasswordForm> form( 77 std::unique_ptr<autofill::PasswordForm> form(
75 CreatePasswordFormFromCredentialInfo(credential, origin)); 78 CreatePasswordFormFromCredentialInfo(credential, origin));
76 79
77 form_manager_.reset(new CredentialManagerPasswordFormManager( 80 form_manager_ = base::MakeUnique<CredentialManagerPasswordFormManager>(
78 client_, GetDriver(), *CreateObservedPasswordFormFromOrigin(origin), 81 client_, GetDriver(), *CreateObservedPasswordFormFromOrigin(origin),
79 std::move(form), this)); 82 std::move(form), this, nullptr, nullptr);
80 } 83 }
81 84
82 void CredentialManagerImpl::OnProvisionalSaveComplete() { 85 void CredentialManagerImpl::OnProvisionalSaveComplete() {
83 DCHECK(form_manager_); 86 DCHECK(form_manager_);
84 DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage()); 87 DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage());
85 const autofill::PasswordForm& form = form_manager_->pending_credentials(); 88 const autofill::PasswordForm& form = form_manager_->pending_credentials();
86 89
87 if (!form.federation_origin.unique()) { 90 if (!form.federation_origin.unique()) {
88 // If this is a federated credential, check it against the federated matches 91 // 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 92 // 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() 268 PasswordStore::FormDigest CredentialManagerImpl::GetSynthesizedFormForOrigin()
266 const { 269 const {
267 PasswordStore::FormDigest digest = { 270 PasswordStore::FormDigest digest = {
268 autofill::PasswordForm::SCHEME_HTML, std::string(), 271 autofill::PasswordForm::SCHEME_HTML, std::string(),
269 web_contents()->GetLastCommittedURL().GetOrigin()}; 272 web_contents()->GetLastCommittedURL().GetOrigin()};
270 digest.signon_realm = digest.origin.spec(); 273 digest.signon_realm = digest.origin.spec();
271 return digest; 274 return digest;
272 } 275 }
273 276
274 } // namespace password_manager 277 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698