Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: chrome/browser/password_manager/password_store_mac.cc

Issue 23742004: Move PasswordForm from //content to //autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_password_form_conversion_utils
Patch Set: Rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/mac/mac_logging.h" 15 #include "base/mac/mac_logging.h"
16 #include "base/mac/mac_util.h" 16 #include "base/mac/mac_util.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/password_manager/login_database.h" 22 #include "chrome/browser/password_manager/login_database.h"
23 #include "chrome/browser/password_manager/password_store_change.h" 23 #include "chrome/browser/password_manager/password_store_change.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "crypto/apple_keychain.h" 25 #include "crypto/apple_keychain.h"
26 26
27 using autofill::PasswordForm;
27 using crypto::AppleKeychain; 28 using crypto::AppleKeychain;
28 using content::PasswordForm;
29 29
30 // Utility class to handle the details of constructing and running a keychain 30 // Utility class to handle the details of constructing and running a keychain
31 // search from a set of attributes. 31 // search from a set of attributes.
32 class KeychainSearch { 32 class KeychainSearch {
33 public: 33 public:
34 explicit KeychainSearch(const AppleKeychain& keychain); 34 explicit KeychainSearch(const AppleKeychain& keychain);
35 ~KeychainSearch(); 35 ~KeychainSearch();
36 36
37 // Sets up a keycahin search based on an non "null" (NULL for char*, 37 // Sets up a keycahin search based on an non "null" (NULL for char*,
38 // The appropriate "Any" entry for other types) arguments. 38 // The appropriate "Any" entry for other types) arguments.
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 for (std::vector<SecKeychainItemRef>::iterator i = matches.begin() + 1; 637 for (std::vector<SecKeychainItemRef>::iterator i = matches.begin() + 1;
638 i != matches.end(); ++i) { 638 i != matches.end(); ++i) {
639 keychain_->Free(*i); 639 keychain_->Free(*i);
640 } 640 }
641 return matches[0]; 641 return matches[0];
642 } 642 }
643 643
644 std::vector<SecKeychainItemRef> 644 std::vector<SecKeychainItemRef>
645 MacKeychainPasswordFormAdapter::MatchingKeychainItems( 645 MacKeychainPasswordFormAdapter::MatchingKeychainItems(
646 const std::string& signon_realm, 646 const std::string& signon_realm,
647 content::PasswordForm::Scheme scheme, 647 autofill::PasswordForm::Scheme scheme,
648 const char* path, const char* username) { 648 const char* path, const char* username) {
649 std::vector<SecKeychainItemRef> matches; 649 std::vector<SecKeychainItemRef> matches;
650 650
651 std::string server; 651 std::string server;
652 std::string security_domain; 652 std::string security_domain;
653 int port; 653 int port;
654 bool is_secure; 654 bool is_secure;
655 if (!ExtractSignonRealmComponents(signon_realm, &server, &port, 655 if (!ExtractSignonRealmComponents(signon_realm, &server, &port,
656 &is_secure, &security_domain)) { 656 &is_secure, &security_domain)) {
657 // TODO(stuartmorgan): Proxies will currently fail here, since their 657 // TODO(stuartmorgan): Proxies will currently fail here, since their
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 } 885 }
886 content::NotificationService::current()->Notify( 886 content::NotificationService::current()->Notify(
887 chrome::NOTIFICATION_LOGINS_CHANGED, 887 chrome::NOTIFICATION_LOGINS_CHANGED,
888 content::Source<PasswordStore>(this), 888 content::Source<PasswordStore>(this),
889 content::Details<PasswordStoreChangeList>(&changes)); 889 content::Details<PasswordStoreChangeList>(&changes));
890 } 890 }
891 } 891 }
892 } 892 }
893 893
894 void PasswordStoreMac::GetLoginsImpl( 894 void PasswordStoreMac::GetLoginsImpl(
895 const content::PasswordForm& form, 895 const autofill::PasswordForm& form,
896 const ConsumerCallbackRunner& callback_runner) { 896 const ConsumerCallbackRunner& callback_runner) {
897 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); 897 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get());
898 std::vector<PasswordForm*> keychain_forms = 898 std::vector<PasswordForm*> keychain_forms =
899 keychain_adapter.PasswordsFillingForm(form); 899 keychain_adapter.PasswordsFillingForm(form);
900 900
901 std::vector<PasswordForm*> database_forms; 901 std::vector<PasswordForm*> database_forms;
902 login_metadata_db_->GetLogins(form, &database_forms); 902 login_metadata_db_->GetLogins(form, &database_forms);
903 903
904 std::vector<PasswordForm*> matched_forms; 904 std::vector<PasswordForm*> matched_forms;
905 internal_keychain_helpers::MergePasswordForms(&keychain_forms, 905 internal_keychain_helpers::MergePasswordForms(&keychain_forms,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 960
961 bool PasswordStoreMac::AddToKeychainIfNecessary(const PasswordForm& form) { 961 bool PasswordStoreMac::AddToKeychainIfNecessary(const PasswordForm& form) {
962 if (form.blacklisted_by_user) { 962 if (form.blacklisted_by_user) {
963 return true; 963 return true;
964 } 964 }
965 MacKeychainPasswordFormAdapter keychainAdapter(keychain_.get()); 965 MacKeychainPasswordFormAdapter keychainAdapter(keychain_.get());
966 return keychainAdapter.AddPassword(form); 966 return keychainAdapter.AddPassword(form);
967 } 967 }
968 968
969 bool PasswordStoreMac::DatabaseHasFormMatchingKeychainForm( 969 bool PasswordStoreMac::DatabaseHasFormMatchingKeychainForm(
970 const content::PasswordForm& form) { 970 const autofill::PasswordForm& form) {
971 bool has_match = false; 971 bool has_match = false;
972 std::vector<PasswordForm*> database_forms; 972 std::vector<PasswordForm*> database_forms;
973 login_metadata_db_->GetLogins(form, &database_forms); 973 login_metadata_db_->GetLogins(form, &database_forms);
974 for (std::vector<PasswordForm*>::iterator i = database_forms.begin(); 974 for (std::vector<PasswordForm*>::iterator i = database_forms.begin();
975 i != database_forms.end(); ++i) { 975 i != database_forms.end(); ++i) {
976 if (internal_keychain_helpers::FormsMatchForMerge(form, **i) && 976 if (internal_keychain_helpers::FormsMatchForMerge(form, **i) &&
977 (*i)->origin == form.origin) { 977 (*i)->origin == form.origin) {
978 has_match = true; 978 has_match = true;
979 break; 979 break;
980 } 980 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); 1018 owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
1019 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); 1019 for (std::vector<PasswordForm*>::const_iterator i = forms.begin();
1020 i != forms.end(); ++i) { 1020 i != forms.end(); ++i) {
1021 owned_keychain_adapter.RemovePassword(**i); 1021 owned_keychain_adapter.RemovePassword(**i);
1022 } 1022 }
1023 } 1023 }
1024 1024
1025 void PasswordStoreMac::CreateNotificationService() { 1025 void PasswordStoreMac::CreateNotificationService() {
1026 notification_service_.reset(content::NotificationService::Create()); 1026 notification_service_.reset(content::NotificationService::Create());
1027 } 1027 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_mac.h ('k') | chrome/browser/password_manager/password_store_mac_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698