| OLD | NEW |
| 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 Loading... |
| 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::CredentialManagerAssociatedRequest request) { |
| 53 bindings_.AddBinding(this, std::move(request)); | 56 DCHECK(!binding_.is_bound()); |
| 57 binding_.Bind(std::move(request)); |
| 58 |
| 59 // The browser side will close the message pipe on DidFinishNavigation before |
| 60 // the renderer side would be destroyed, and the renderer never explicitly |
| 61 // closes the pipe. So a connection error really means an error here, in which |
| 62 // case the renderer will try to reconnect when the next call to the API is |
| 63 // made. Make sure this implementation will no longer be bound to a broken |
| 64 // pipe once that happens, so the DCHECK above will succeed. |
| 65 binding_.set_connection_error_handler(base::Bind( |
| 66 &CredentialManagerImpl::DisconnectBinding, base::Unretained(this))); |
| 67 } |
| 68 |
| 69 bool CredentialManagerImpl::HasBinding() const { |
| 70 return binding_.is_bound(); |
| 71 } |
| 72 |
| 73 void CredentialManagerImpl::DisconnectBinding() { |
| 74 binding_.Close(); |
| 54 } | 75 } |
| 55 | 76 |
| 56 void CredentialManagerImpl::Store(const CredentialInfo& credential, | 77 void CredentialManagerImpl::Store(const CredentialInfo& credential, |
| 57 StoreCallback callback) { | 78 StoreCallback callback) { |
| 58 DCHECK_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, credential.type); | 79 DCHECK_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, credential.type); |
| 59 | 80 |
| 60 if (password_manager_util::IsLoggingActive(client_)) { | 81 if (password_manager_util::IsLoggingActive(client_)) { |
| 61 CredentialManagerLogger(client_->GetLogManager()) | 82 CredentialManagerLogger(client_->GetLogManager()) |
| 62 .LogStoreCredential(web_contents()->GetLastCommittedURL(), | 83 .LogStoreCredential(web_contents()->GetLastCommittedURL(), |
| 63 credential.type); | 84 credential.type); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 PasswordStore::FormDigest CredentialManagerImpl::GetSynthesizedFormForOrigin() | 300 PasswordStore::FormDigest CredentialManagerImpl::GetSynthesizedFormForOrigin() |
| 280 const { | 301 const { |
| 281 PasswordStore::FormDigest digest = { | 302 PasswordStore::FormDigest digest = { |
| 282 autofill::PasswordForm::SCHEME_HTML, std::string(), | 303 autofill::PasswordForm::SCHEME_HTML, std::string(), |
| 283 web_contents()->GetLastCommittedURL().GetOrigin()}; | 304 web_contents()->GetLastCommittedURL().GetOrigin()}; |
| 284 digest.signon_realm = digest.origin.spec(); | 305 digest.signon_realm = digest.origin.spec(); |
| 285 return digest; | 306 return digest; |
| 286 } | 307 } |
| 287 | 308 |
| 288 } // namespace password_manager | 309 } // namespace password_manager |
| OLD | NEW |