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 | 6 |
7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 if (extract_password_data) { | 357 if (extract_password_data) { |
358 base::UTF8ToUTF16(static_cast<const char *>(password_data), password_length, | 358 base::UTF8ToUTF16(static_cast<const char *>(password_data), password_length, |
359 &(form->password_value)); | 359 &(form->password_value)); |
360 } | 360 } |
361 | 361 |
362 int port = kAnyPort; | 362 int port = kAnyPort; |
363 std::string server; | 363 std::string server; |
364 std::string security_domain; | 364 std::string security_domain; |
365 std::string path; | 365 std::string path; |
| 366 bool is_secure = false; |
366 for (unsigned int i = 0; i < attrList->count; i++) { | 367 for (unsigned int i = 0; i < attrList->count; i++) { |
367 SecKeychainAttribute attr = attrList->attr[i]; | 368 SecKeychainAttribute attr = attrList->attr[i]; |
368 if (!attr.data) { | 369 if (!attr.data) { |
369 continue; | 370 continue; |
370 } | 371 } |
371 switch (attr.tag) { | 372 switch (attr.tag) { |
372 case kSecAccountItemAttr: | 373 case kSecAccountItemAttr: |
373 base::UTF8ToUTF16(static_cast<const char *>(attr.data), attr.length, | 374 base::UTF8ToUTF16(static_cast<const char *>(attr.data), attr.length, |
374 &(form->username_value)); | 375 &(form->username_value)); |
375 break; | 376 break; |
376 case kSecServerItemAttr: | 377 case kSecServerItemAttr: |
377 server.assign(static_cast<const char *>(attr.data), attr.length); | 378 server.assign(static_cast<const char *>(attr.data), attr.length); |
378 break; | 379 break; |
379 case kSecPortItemAttr: | 380 case kSecPortItemAttr: |
380 port = *(static_cast<UInt32*>(attr.data)); | 381 port = *(static_cast<UInt32*>(attr.data)); |
381 break; | 382 break; |
382 case kSecPathItemAttr: | 383 case kSecPathItemAttr: |
383 path.assign(static_cast<const char *>(attr.data), attr.length); | 384 path.assign(static_cast<const char *>(attr.data), attr.length); |
384 break; | 385 break; |
385 case kSecProtocolItemAttr: | 386 case kSecProtocolItemAttr: |
386 { | 387 { |
387 SecProtocolType protocol = *(static_cast<SecProtocolType*>(attr.data)); | 388 SecProtocolType protocol = *(static_cast<SecProtocolType*>(attr.data)); |
388 // TODO(stuartmorgan): Handle proxy types | 389 // TODO(stuartmorgan): Handle proxy types |
389 form->ssl_valid = (protocol == kSecProtocolTypeHTTPS); | 390 is_secure = (protocol == kSecProtocolTypeHTTPS); |
390 break; | 391 break; |
391 } | 392 } |
392 case kSecAuthenticationTypeItemAttr: | 393 case kSecAuthenticationTypeItemAttr: |
393 { | 394 { |
394 SecAuthenticationType auth_type = | 395 SecAuthenticationType auth_type = |
395 *(static_cast<SecAuthenticationType*>(attr.data)); | 396 *(static_cast<SecAuthenticationType*>(attr.data)); |
396 form->scheme = SchemeForAuthType(auth_type); | 397 form->scheme = SchemeForAuthType(auth_type); |
397 break; | 398 break; |
398 } | 399 } |
399 case kSecSecurityDomainItemAttr: | 400 case kSecSecurityDomainItemAttr: |
(...skipping 22 matching lines...) Expand all Loading... |
422 if (extract_password_data && (form->password_value.empty() || | 423 if (extract_password_data && (form->password_value.empty() || |
423 base::EqualsASCII(form->password_value, " "))) { | 424 base::EqualsASCII(form->password_value, " "))) { |
424 form->blacklisted_by_user = true; | 425 form->blacklisted_by_user = true; |
425 } | 426 } |
426 | 427 |
427 // Android facet URLs aren't parsed correctly by GURL and need to be handled | 428 // Android facet URLs aren't parsed correctly by GURL and need to be handled |
428 // separately. | 429 // separately. |
429 if (password_manager::IsValidAndroidFacetURI(server)) { | 430 if (password_manager::IsValidAndroidFacetURI(server)) { |
430 form->signon_realm = server; | 431 form->signon_realm = server; |
431 form->origin = GURL(); | 432 form->origin = GURL(); |
432 form->ssl_valid = true; | |
433 } else { | 433 } else { |
434 form->origin = URLFromComponents(form->ssl_valid, server, port, path); | 434 form->origin = URLFromComponents(is_secure, server, port, path); |
435 // TODO(stuartmorgan): Handle proxies, which need a different signon_realm | 435 // TODO(stuartmorgan): Handle proxies, which need a different signon_realm |
436 // format. | 436 // format. |
437 form->signon_realm = form->origin.GetOrigin().spec(); | 437 form->signon_realm = form->origin.GetOrigin().spec(); |
438 if (form->scheme != PasswordForm::SCHEME_HTML) { | 438 if (form->scheme != PasswordForm::SCHEME_HTML) { |
439 form->signon_realm.append(security_domain); | 439 form->signon_realm.append(security_domain); |
440 } | 440 } |
441 } | 441 } |
442 return true; | 442 return true; |
443 } | 443 } |
444 | 444 |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1396 ScopedVector<PasswordForm> forms_with_keychain_entry; |
1397 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1397 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
1398 &forms_with_keychain_entry); | 1398 &forms_with_keychain_entry); |
1399 | 1399 |
1400 // Clean up any orphaned database entries. | 1400 // Clean up any orphaned database entries. |
1401 RemoveDatabaseForms(&database_forms); | 1401 RemoveDatabaseForms(&database_forms); |
1402 | 1402 |
1403 // Move the orphaned DB forms to the output parameter. | 1403 // Move the orphaned DB forms to the output parameter. |
1404 AppendSecondToFirst(orphaned_forms, &database_forms); | 1404 AppendSecondToFirst(orphaned_forms, &database_forms); |
1405 } | 1405 } |
OLD | NEW |