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

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

Issue 2947413002: Restrict CM API interface request and message dispatch. (Closed)
Patch Set: Reworked tests, added error handler in renderer. Created 3 years, 5 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/memory/ptr_util.h"
(...skipping 22 matching lines...) Expand all
33 const CredentialInfo& info) { 33 const CredentialInfo& info) {
34 std::move(callback).Run(mojom::CredentialManagerError::SUCCESS, info); 34 std::move(callback).Run(mojom::CredentialManagerError::SUCCESS, info);
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 // CredentialManagerImpl ------------------------------------------------- 39 // CredentialManagerImpl -------------------------------------------------
40 40
41 CredentialManagerImpl::CredentialManagerImpl(content::WebContents* web_contents, 41 CredentialManagerImpl::CredentialManagerImpl(content::WebContents* web_contents,
42 PasswordManagerClient* client) 42 PasswordManagerClient* client)
43 : WebContentsObserver(web_contents), client_(client), weak_factory_(this) { 43 : WebContentsObserver(web_contents),
44 client_(client),
45 binding_(this),
46 weak_factory_(this) {
44 DCHECK(web_contents); 47 DCHECK(web_contents);
45 auto_signin_enabled_.Init(prefs::kCredentialsEnableAutosignin, 48 auto_signin_enabled_.Init(prefs::kCredentialsEnableAutosignin,
46 client_->GetPrefs()); 49 client_->GetPrefs());
47 } 50 }
48 51
49 CredentialManagerImpl::~CredentialManagerImpl() {} 52 CredentialManagerImpl::~CredentialManagerImpl() {}
50 53
51 void CredentialManagerImpl::BindRequest( 54 void CredentialManagerImpl::BindRequest(
52 mojom::CredentialManagerRequest request) { 55 mojom::CredentialManagerRequest request) {
53 bindings_.AddBinding(this, std::move(request)); 56 // This can happen if the pipe broke and the renderer is now reconnecting.
57 if (binding_.is_bound())
58 binding_.Close();
dcheng 2017/06/28 19:04:49 I'm confused how we could get here--shouldn't the
engedy 2017/06/28 19:26:34 I was trying to be on the safe side here -- my thi
dcheng 2017/06/29 06:43:49 One common alternative is to add an explicit conne
engedy 2017/06/30 19:41:55 Yep, added error handler.
59 binding_.Bind(std::move(request));
60 }
61
62 bool CredentialManagerImpl::HasBinding() const {
63 return binding_.is_bound();
64 }
65
66 void CredentialManagerImpl::DisconnectBinding() {
67 binding_.Close();
54 } 68 }
55 69
56 void CredentialManagerImpl::Store(const CredentialInfo& credential, 70 void CredentialManagerImpl::Store(const CredentialInfo& credential,
57 StoreCallback callback) { 71 StoreCallback callback) {
58 DCHECK_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, credential.type); 72 DCHECK_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, credential.type);
59 73
60 if (password_manager_util::IsLoggingActive(client_)) { 74 if (password_manager_util::IsLoggingActive(client_)) {
61 CredentialManagerLogger(client_->GetLogManager()) 75 CredentialManagerLogger(client_->GetLogManager())
62 .LogStoreCredential(web_contents()->GetLastCommittedURL(), 76 .LogStoreCredential(web_contents()->GetLastCommittedURL(),
63 credential.type); 77 credential.type);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 PasswordStore::FormDigest CredentialManagerImpl::GetSynthesizedFormForOrigin() 293 PasswordStore::FormDigest CredentialManagerImpl::GetSynthesizedFormForOrigin()
280 const { 294 const {
281 PasswordStore::FormDigest digest = { 295 PasswordStore::FormDigest digest = {
282 autofill::PasswordForm::SCHEME_HTML, std::string(), 296 autofill::PasswordForm::SCHEME_HTML, std::string(),
283 web_contents()->GetLastCommittedURL().GetOrigin()}; 297 web_contents()->GetLastCommittedURL().GetOrigin()};
284 digest.signon_realm = digest.origin.spec(); 298 digest.signon_realm = digest.origin.spec();
285 return digest; 299 return digest;
286 } 300 }
287 301
288 } // namespace password_manager 302 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698