| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #import "ios/chrome/browser/passwords/credential_manager.h" | 5 #import "ios/chrome/browser/passwords/credential_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #import "base/ios/weak_nsobject.h" | 9 #import "base/ios/weak_nsobject.h" |
| 10 #include "base/mac/bind_objc_block.h" | 10 #include "base/mac/bind_objc_block.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 RejectPromise(request_id, ERROR_TYPE_SECURITY_ERROR_UNTRUSTED_ORIGIN); | 149 RejectPromise(request_id, ERROR_TYPE_SECURITY_ERROR_UNTRUSTED_ORIGIN); |
| 150 return; | 150 return; |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Bundle up the arguments and forward them to the PasswordStore, which will | 153 // Bundle up the arguments and forward them to the PasswordStore, which will |
| 154 // asynchronously return the resulting Credential by invoking | 154 // asynchronously return the resulting Credential by invoking |
| 155 // |SendCredential|. | 155 // |SendCredential|. |
| 156 std::vector<GURL> federation_urls; | 156 std::vector<GURL> federation_urls; |
| 157 for (const auto& federation : federations) | 157 for (const auto& federation : federations) |
| 158 federation_urls.push_back(GURL(federation)); | 158 federation_urls.push_back(GURL(federation)); |
| 159 std::vector<std::string> realms; | |
| 160 pending_request_.reset( | 159 pending_request_.reset( |
| 161 new password_manager::CredentialManagerPendingRequestTask( | 160 new password_manager::CredentialManagerPendingRequestTask( |
| 162 this, base::Bind(&CredentialManager::SendCredentialByID, | 161 this, base::Bind(&CredentialManager::SendCredentialByID, |
| 163 base::Unretained(this), request_id), | 162 base::Unretained(this), request_id), |
| 164 zero_click_only, page_url, true, federation_urls, realms)); | 163 zero_click_only, true, federation_urls)); |
| 165 store->GetAutofillableLogins(pending_request_.get()); | 164 password_manager::PasswordStore::FormDigest form = { |
| 165 autofill::PasswordForm::SCHEME_HTML, page_url.spec(), page_url}; |
| 166 store->GetLogins(form, pending_request_.get()); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void CredentialManager::SignedIn(int request_id, | 169 void CredentialManager::SignedIn(int request_id, |
| 169 const GURL& source_url, | 170 const GURL& source_url, |
| 170 const web::Credential& credential) { | 171 const web::Credential& credential) { |
| 171 // Invoked when the page invokes navigator.credentials.notifySignedIn(), this | 172 // Invoked when the page invokes navigator.credentials.notifySignedIn(), this |
| 172 // function stores the signed-in |credential| and sends a message back to the | 173 // function stores the signed-in |credential| and sends a message back to the |
| 173 // page to resolve the Promise associated with |request_id|. | 174 // page to resolve the Promise associated with |request_id|. |
| 174 DCHECK(credential.type != web::CredentialType::CREDENTIAL_TYPE_EMPTY); | 175 DCHECK(credential.type != web::CredentialType::CREDENTIAL_TYPE_EMPTY); |
| 175 DCHECK_GE(request_id, 0); | 176 DCHECK_GE(request_id, 0); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 info = password_manager::CredentialInfo(*form, type_to_return); | 298 info = password_manager::CredentialInfo(*form, type_to_return); |
| 298 // TODO(vasilii): update |skip_zero_click| in the store (crbug.com/594110). | 299 // TODO(vasilii): update |skip_zero_click| in the store (crbug.com/594110). |
| 299 } | 300 } |
| 300 SendCredential(send_callback, info); | 301 SendCredential(send_callback, info); |
| 301 } | 302 } |
| 302 | 303 |
| 303 password_manager::PasswordManagerClient* CredentialManager::client() const { | 304 password_manager::PasswordManagerClient* CredentialManager::client() const { |
| 304 return client_; | 305 return client_; |
| 305 } | 306 } |
| 306 | 307 |
| 307 password_manager::PasswordStore::FormDigest | |
| 308 CredentialManager::GetSynthesizedFormForOrigin() const { | |
| 309 password_manager::PasswordStore::FormDigest form = { | |
| 310 autofill::PasswordForm::SCHEME_HTML, std::string(), | |
| 311 web_state()->GetLastCommittedURL().GetOrigin()}; | |
| 312 form.signon_realm = form.origin.spec(); | |
| 313 return form; | |
| 314 } | |
| 315 | |
| 316 void CredentialManager::OnProvisionalSaveComplete() { | 308 void CredentialManager::OnProvisionalSaveComplete() { |
| 317 // Invoked after a credential sent up by the page was stored in a FormManager | 309 // Invoked after a credential sent up by the page was stored in a FormManager |
| 318 // by |SignedIn|, this function asks the user if the password should be stored | 310 // by |SignedIn|, this function asks the user if the password should be stored |
| 319 // in the password manager. | 311 // in the password manager. |
| 320 DCHECK(form_manager_); | 312 DCHECK(form_manager_); |
| 321 if (client_->IsSavingAndFillingEnabledForCurrentPage() && | 313 if (client_->IsSavingAndFillingEnabledForCurrentPage() && |
| 322 !form_manager_->IsBlacklisted()) { | 314 !form_manager_->IsBlacklisted()) { |
| 323 client_->PromptUserToSaveOrUpdatePassword( | 315 client_->PromptUserToSaveOrUpdatePassword( |
| 324 std::move(form_manager_), | 316 std::move(form_manager_), |
| 325 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API, false); | 317 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API, false); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 bool CredentialManager::GetUrlWithAbsoluteTrust(GURL* page_url) { | 362 bool CredentialManager::GetUrlWithAbsoluteTrust(GURL* page_url) { |
| 371 web::URLVerificationTrustLevel trust_level = | 363 web::URLVerificationTrustLevel trust_level = |
| 372 web::URLVerificationTrustLevel::kNone; | 364 web::URLVerificationTrustLevel::kNone; |
| 373 const GURL possibly_untrusted_url(web_state()->GetCurrentURL(&trust_level)); | 365 const GURL possibly_untrusted_url(web_state()->GetCurrentURL(&trust_level)); |
| 374 if (trust_level == web::URLVerificationTrustLevel::kAbsolute) { | 366 if (trust_level == web::URLVerificationTrustLevel::kAbsolute) { |
| 375 *page_url = possibly_untrusted_url; | 367 *page_url = possibly_untrusted_url; |
| 376 return true; | 368 return true; |
| 377 } | 369 } |
| 378 return false; | 370 return false; |
| 379 } | 371 } |
| OLD | NEW |