| 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/renderer/credential_manager_client
.h" | 5 #include "components/password_manager/content/renderer/credential_manager_client
.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "third_party/WebKit/public/platform/WebFederatedCredential.h" | 21 #include "third_party/WebKit/public/platform/WebFederatedCredential.h" |
| 22 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" | 22 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" |
| 23 #include "third_party/WebKit/public/web/WebView.h" | 23 #include "third_party/WebKit/public/web/WebView.h" |
| 24 | 24 |
| 25 namespace password_manager { | 25 namespace password_manager { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 void WebCredentialToCredentialInfo(const blink::WebCredential& credential, | 29 void WebCredentialToCredentialInfo(const blink::WebCredential& credential, |
| 30 CredentialInfo* out) { | 30 CredentialInfo* out) { |
| 31 out->id = credential.id(); | 31 out->id = credential.id().utf16(); |
| 32 out->name = credential.name(); | 32 out->name = credential.name().utf16(); |
| 33 out->icon = credential.iconURL(); | 33 out->icon = credential.iconURL(); |
| 34 if (credential.isPasswordCredential()) { | 34 if (credential.isPasswordCredential()) { |
| 35 out->type = CredentialType::CREDENTIAL_TYPE_PASSWORD; | 35 out->type = CredentialType::CREDENTIAL_TYPE_PASSWORD; |
| 36 out->password = | 36 out->password = static_cast<const blink::WebPasswordCredential&>(credential) |
| 37 static_cast<const blink::WebPasswordCredential&>(credential).password(); | 37 .password() |
| 38 .utf16(); |
| 38 } else { | 39 } else { |
| 39 DCHECK(credential.isFederatedCredential()); | 40 DCHECK(credential.isFederatedCredential()); |
| 40 out->type = CredentialType::CREDENTIAL_TYPE_FEDERATED; | 41 out->type = CredentialType::CREDENTIAL_TYPE_FEDERATED; |
| 41 out->federation = | 42 out->federation = |
| 42 static_cast<const blink::WebFederatedCredential&>(credential) | 43 static_cast<const blink::WebFederatedCredential&>(credential) |
| 43 .provider(); | 44 .provider(); |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 | 47 |
| 47 std::unique_ptr<blink::WebCredential> CredentialInfoToWebCredential( | 48 std::unique_ptr<blink::WebCredential> CredentialInfoToWebCredential( |
| 48 const CredentialInfo& info) { | 49 const CredentialInfo& info) { |
| 49 switch (info.type) { | 50 switch (info.type) { |
| 50 case CredentialType::CREDENTIAL_TYPE_FEDERATED: | 51 case CredentialType::CREDENTIAL_TYPE_FEDERATED: |
| 51 return base::MakeUnique<blink::WebFederatedCredential>( | 52 return base::MakeUnique<blink::WebFederatedCredential>( |
| 52 info.id, info.federation, info.name, info.icon); | 53 blink::WebString::fromUTF16(info.id), info.federation, |
| 54 blink::WebString::fromUTF16(info.name), info.icon); |
| 53 case CredentialType::CREDENTIAL_TYPE_PASSWORD: | 55 case CredentialType::CREDENTIAL_TYPE_PASSWORD: |
| 54 return base::MakeUnique<blink::WebPasswordCredential>( | 56 return base::MakeUnique<blink::WebPasswordCredential>( |
| 55 info.id, info.password, info.name, info.icon); | 57 blink::WebString::fromUTF16(info.id), |
| 58 blink::WebString::fromUTF16(info.password), |
| 59 blink::WebString::fromUTF16(info.name), info.icon); |
| 56 case CredentialType::CREDENTIAL_TYPE_EMPTY: | 60 case CredentialType::CREDENTIAL_TYPE_EMPTY: |
| 57 return nullptr; | 61 return nullptr; |
| 58 } | 62 } |
| 59 | 63 |
| 60 NOTREACHED(); | 64 NOTREACHED(); |
| 61 return nullptr; | 65 return nullptr; |
| 62 } | 66 } |
| 63 | 67 |
| 64 blink::WebCredentialManagerError GetWebCredentialManagerErrorFromMojo( | 68 blink::WebCredentialManagerError GetWebCredentialManagerErrorFromMojo( |
| 65 mojom::CredentialManagerError error) { | 69 mojom::CredentialManagerError error) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 249 |
| 246 content::RenderFrame* main_frame = render_view()->GetMainRenderFrame(); | 250 content::RenderFrame* main_frame = render_view()->GetMainRenderFrame(); |
| 247 main_frame->GetRemoteInterfaces()->GetInterface(&mojo_cm_service_); | 251 main_frame->GetRemoteInterfaces()->GetInterface(&mojo_cm_service_); |
| 248 } | 252 } |
| 249 | 253 |
| 250 void CredentialManagerClient::OnDestruct() { | 254 void CredentialManagerClient::OnDestruct() { |
| 251 delete this; | 255 delete this; |
| 252 } | 256 } |
| 253 | 257 |
| 254 } // namespace password_manager | 258 } // namespace password_manager |
| OLD | NEW |