OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/password_manager/password_store_mac.h" | 5 #include "chrome/browser/password_manager/password_store_mac.h" |
6 #include "chrome/browser/password_manager/password_store_mac_internal.h" | 6 #include "chrome/browser/password_manager/password_store_mac_internal.h" |
7 | 7 |
8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (extract_password_data && (form->password_value.empty() || | 415 if (extract_password_data && (form->password_value.empty() || |
416 EqualsASCII(form->password_value, " "))) { | 416 EqualsASCII(form->password_value, " "))) { |
417 form->blacklisted_by_user = true; | 417 form->blacklisted_by_user = true; |
418 } | 418 } |
419 | 419 |
420 // Android facet URLs aren't parsed correctly by GURL and need to be handled | 420 // Android facet URLs aren't parsed correctly by GURL and need to be handled |
421 // separately. | 421 // separately. |
422 if (password_manager::IsValidAndroidFacetURI(server)) { | 422 if (password_manager::IsValidAndroidFacetURI(server)) { |
423 form->signon_realm = server; | 423 form->signon_realm = server; |
424 form->origin = GURL(); | 424 form->origin = GURL(); |
| 425 form->ssl_valid = true; |
425 } else { | 426 } else { |
426 form->origin = URLFromComponents(form->ssl_valid, server, port, path); | 427 form->origin = URLFromComponents(form->ssl_valid, server, port, path); |
427 // TODO(stuartmorgan): Handle proxies, which need a different signon_realm | 428 // TODO(stuartmorgan): Handle proxies, which need a different signon_realm |
428 // format. | 429 // format. |
429 form->signon_realm = form->origin.GetOrigin().spec(); | 430 form->signon_realm = form->origin.GetOrigin().spec(); |
430 if (form->scheme != PasswordForm::SCHEME_HTML) { | 431 if (form->scheme != PasswordForm::SCHEME_HTML) { |
431 form->signon_realm.append(security_domain); | 432 form->signon_realm.append(security_domain); |
432 } | 433 } |
433 } | 434 } |
434 return true; | 435 return true; |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 } | 806 } |
806 | 807 |
807 SecKeychainItemRef MacKeychainPasswordFormAdapter::KeychainItemForForm( | 808 SecKeychainItemRef MacKeychainPasswordFormAdapter::KeychainItemForForm( |
808 const PasswordForm& form) { | 809 const PasswordForm& form) { |
809 // We don't store blacklist entries in the keychain, so the answer to "what | 810 // We don't store blacklist entries in the keychain, so the answer to "what |
810 // Keychain item goes with this form" is always "nothing" for blacklists. | 811 // Keychain item goes with this form" is always "nothing" for blacklists. |
811 if (form.blacklisted_by_user) { | 812 if (form.blacklisted_by_user) { |
812 return NULL; | 813 return NULL; |
813 } | 814 } |
814 | 815 |
815 std::string path = form.origin.path(); | 816 std::string path; |
| 817 // Path doesn't make sense for Android app credentials. |
| 818 if (!password_manager::IsValidAndroidFacetURI(form.signon_realm)) |
| 819 path = form.origin.path(); |
816 std::string username = base::UTF16ToUTF8(form.username_value); | 820 std::string username = base::UTF16ToUTF8(form.username_value); |
817 std::vector<SecKeychainItemRef> matches = MatchingKeychainItems( | 821 std::vector<SecKeychainItemRef> matches = MatchingKeychainItems( |
818 form.signon_realm, form.scheme, path.c_str(), username.c_str()); | 822 form.signon_realm, form.scheme, path.c_str(), username.c_str()); |
819 | 823 |
820 if (matches.empty()) { | 824 if (matches.empty()) { |
821 return NULL; | 825 return NULL; |
822 } | 826 } |
823 // Free all items after the first, since we won't be returning them. | 827 // Free all items after the first, since we won't be returning them. |
824 for (std::vector<SecKeychainItemRef>::iterator i = matches.begin() + 1; | 828 for (std::vector<SecKeychainItemRef>::iterator i = matches.begin() + 1; |
825 i != matches.end(); ++i) { | 829 i != matches.end(); ++i) { |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1218 ScopedVector<PasswordForm> forms_with_keychain_entry; |
1215 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1219 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
1216 &forms_with_keychain_entry); | 1220 &forms_with_keychain_entry); |
1217 | 1221 |
1218 // Clean up any orphaned database entries. | 1222 // Clean up any orphaned database entries. |
1219 RemoveDatabaseForms(&database_forms); | 1223 RemoveDatabaseForms(&database_forms); |
1220 | 1224 |
1221 // Move the orphaned DB forms to the output parameter. | 1225 // Move the orphaned DB forms to the output parameter. |
1222 AppendSecondToFirst(orphaned_forms, &database_forms); | 1226 AppendSecondToFirst(orphaned_forms, &database_forms); |
1223 } | 1227 } |
OLD | NEW |