1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/password_manager/content/common/credential_manager_content_utils.h"
7 #include "base/logging.h"
8 #include "third_party/WebKit/public/platform/WebCredential.h"
9 #include "third_party/WebKit/public/platform/WebFederatedCredential.h"
10 #include "third_party/WebKit/public/platform/WebPasswordCredential.h"
12 namespace password_manager
{
14 CredentialInfo
WebCredentialToCredentialInfo(
15 const blink::WebCredential
& credential
) {
16 CredentialInfo credential_info
;
17 credential_info
.id
= credential
.id();
18 credential_info
.name
= credential
.name();
19 credential_info
.avatar
= credential
.avatarURL();
20 credential_info
.type
= credential
.isPasswordCredential()
21 ? CredentialType::CREDENTIAL_TYPE_PASSWORD
22 : CredentialType::CREDENTIAL_TYPE_FEDERATED
;
23 if (credential_info
.type
== CredentialType::CREDENTIAL_TYPE_PASSWORD
) {
24 DCHECK(credential
.isPasswordCredential());
25 credential_info
.password
=
26 static_cast<const blink::WebPasswordCredential
&>(credential
).password();
28 DCHECK(credential
.isFederatedCredential());
29 credential_info
.federation
=
30 static_cast<const blink::WebFederatedCredential
&>(credential
)
33 return credential_info
;
36 } // namespace password_manager