| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 blink::WebString::FromUTF16(info.password), | 58 blink::WebString::FromUTF16(info.password), |
| 59 blink::WebString::FromUTF16(info.name), info.icon); | 59 blink::WebString::FromUTF16(info.name), info.icon); |
| 60 case CredentialType::CREDENTIAL_TYPE_EMPTY: | 60 case CredentialType::CREDENTIAL_TYPE_EMPTY: |
| 61 return nullptr; | 61 return nullptr; |
| 62 } | 62 } |
| 63 | 63 |
| 64 NOTREACHED(); | 64 NOTREACHED(); |
| 65 return nullptr; | 65 return nullptr; |
| 66 } | 66 } |
| 67 | 67 |
| 68 CredentialMediationRequirement GetCredentialMediationRequirementFromBlink( |
| 69 blink::WebCredentialMediationRequirement mediation) { |
| 70 switch (mediation) { |
| 71 case blink::WebCredentialMediationRequirement::kSilent: |
| 72 return CredentialMediationRequirement::kSilent; |
| 73 case blink::WebCredentialMediationRequirement::kOptional: |
| 74 return CredentialMediationRequirement::kOptional; |
| 75 case blink::WebCredentialMediationRequirement::kRequired: |
| 76 return CredentialMediationRequirement::kRequired; |
| 77 } |
| 78 |
| 79 NOTREACHED(); |
| 80 return CredentialMediationRequirement::kOptional; |
| 81 } |
| 82 |
| 68 blink::WebCredentialManagerError GetWebCredentialManagerErrorFromMojo( | 83 blink::WebCredentialManagerError GetWebCredentialManagerErrorFromMojo( |
| 69 mojom::CredentialManagerError error) { | 84 mojom::CredentialManagerError error) { |
| 70 switch (error) { | 85 switch (error) { |
| 71 case mojom::CredentialManagerError::DISABLED: | 86 case mojom::CredentialManagerError::DISABLED: |
| 72 return blink::WebCredentialManagerError:: | 87 return blink::WebCredentialManagerError:: |
| 73 kWebCredentialManagerDisabledError; | 88 kWebCredentialManagerDisabledError; |
| 74 case mojom::CredentialManagerError::PENDINGREQUEST: | 89 case mojom::CredentialManagerError::PENDINGREQUEST: |
| 75 return blink::WebCredentialManagerError:: | 90 return blink::WebCredentialManagerError:: |
| 76 kWebCredentialManagerPendingRequestError; | 91 kWebCredentialManagerPendingRequestError; |
| 77 case mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE: | 92 case mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE: |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { | 235 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { |
| 221 DCHECK(callbacks); | 236 DCHECK(callbacks); |
| 222 ConnectToMojoCMIfNeeded(); | 237 ConnectToMojoCMIfNeeded(); |
| 223 | 238 |
| 224 mojo_cm_service_->RequireUserMediation( | 239 mojo_cm_service_->RequireUserMediation( |
| 225 base::Bind(&RespondToNotificationCallback, | 240 base::Bind(&RespondToNotificationCallback, |
| 226 base::Owned(new NotificationCallbacksWrapper(callbacks)))); | 241 base::Owned(new NotificationCallbacksWrapper(callbacks)))); |
| 227 } | 242 } |
| 228 | 243 |
| 229 void CredentialManagerClient::DispatchGet( | 244 void CredentialManagerClient::DispatchGet( |
| 230 bool zero_click_only, | 245 blink::WebCredentialMediationRequirement mediation, |
| 231 bool include_passwords, | 246 bool include_passwords, |
| 232 const blink::WebVector<blink::WebURL>& federations, | 247 const blink::WebVector<blink::WebURL>& federations, |
| 233 RequestCallbacks* callbacks) { | 248 RequestCallbacks* callbacks) { |
| 234 DCHECK(callbacks); | 249 DCHECK(callbacks); |
| 235 ConnectToMojoCMIfNeeded(); | 250 ConnectToMojoCMIfNeeded(); |
| 236 | 251 |
| 237 std::vector<GURL> federation_vector; | 252 std::vector<GURL> federation_vector; |
| 238 for (size_t i = 0; i < std::min(federations.size(), kMaxFederations); ++i) | 253 for (size_t i = 0; i < std::min(federations.size(), kMaxFederations); ++i) |
| 239 federation_vector.push_back(federations[i]); | 254 federation_vector.push_back(federations[i]); |
| 240 | 255 |
| 241 mojo_cm_service_->Get( | 256 mojo_cm_service_->Get( |
| 242 zero_click_only, include_passwords, federation_vector, | 257 GetCredentialMediationRequirementFromBlink(mediation), include_passwords, |
| 258 federation_vector, |
| 243 base::Bind(&RespondToRequestCallback, | 259 base::Bind(&RespondToRequestCallback, |
| 244 base::Owned(new RequestCallbacksWrapper(callbacks)))); | 260 base::Owned(new RequestCallbacksWrapper(callbacks)))); |
| 245 } | 261 } |
| 246 | 262 |
| 247 void CredentialManagerClient::ConnectToMojoCMIfNeeded() { | 263 void CredentialManagerClient::ConnectToMojoCMIfNeeded() { |
| 248 if (mojo_cm_service_) | 264 if (mojo_cm_service_) |
| 249 return; | 265 return; |
| 250 | 266 |
| 251 content::RenderFrame* main_frame = render_view()->GetMainRenderFrame(); | 267 content::RenderFrame* main_frame = render_view()->GetMainRenderFrame(); |
| 252 main_frame->GetRemoteInterfaces()->GetInterface(&mojo_cm_service_); | 268 main_frame->GetRemoteInterfaces()->GetInterface(&mojo_cm_service_); |
| 253 } | 269 } |
| 254 | 270 |
| 255 void CredentialManagerClient::OnDestruct() { | 271 void CredentialManagerClient::OnDestruct() { |
| 256 delete this; | 272 delete this; |
| 257 } | 273 } |
| 258 | 274 |
| 259 } // namespace password_manager | 275 } // namespace password_manager |
| OLD | NEW |