| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_x.h" | 5 #include "chrome/browser/password_manager/password_store_x.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 Details<PasswordStoreChangeList>(&changes)); | 92 Details<PasswordStoreChangeList>(&changes)); |
| 93 allow_fallback_ = false; | 93 allow_fallback_ = false; |
| 94 } else if (allow_default_store()) { | 94 } else if (allow_default_store()) { |
| 95 PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl(delete_begin, | 95 PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl(delete_begin, |
| 96 delete_end); | 96 delete_end); |
| 97 } | 97 } |
| 98 STLDeleteElements(&forms); | 98 STLDeleteElements(&forms); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void PasswordStoreX::GetLoginsImpl(GetLoginsRequest* request, | 101 void PasswordStoreX::GetLoginsImpl(GetLoginsRequest* request, |
| 102 const PasswordForm& form) { | 102 const PasswordForm& form) { |
| 103 CheckMigration(); | 103 CheckMigration(); |
| 104 vector<PasswordForm*> forms; | 104 if (use_native_backend() && backend_->GetLogins(form, &request->value)) { |
| 105 if (use_native_backend() && backend_->GetLogins(form, &forms)) { | 105 ForwardLoginsResult(request); |
| 106 NotifyConsumer(request, forms); | |
| 107 allow_fallback_ = false; | 106 allow_fallback_ = false; |
| 108 } else if (allow_default_store()) { | 107 } else if (allow_default_store()) { |
| 109 PasswordStoreDefault::GetLoginsImpl(request, form); | 108 PasswordStoreDefault::GetLoginsImpl(request, form); |
| 110 } else { | 109 } else { |
| 111 // The consumer will be left hanging unless we reply. | 110 // The consumer will be left hanging unless we reply. |
| 112 NotifyConsumer(request, forms); | 111 ForwardLoginsResult(request); |
| 113 } | 112 } |
| 114 } | 113 } |
| 115 | 114 |
| 116 void PasswordStoreX::GetAutofillableLoginsImpl(GetLoginsRequest* request) { | 115 void PasswordStoreX::GetAutofillableLoginsImpl(GetLoginsRequest* request) { |
| 117 CheckMigration(); | 116 CheckMigration(); |
| 118 vector<PasswordForm*> forms; | 117 if (use_native_backend() && |
| 119 if (use_native_backend() && backend_->GetAutofillableLogins(&forms)) { | 118 backend_->GetAutofillableLogins(&request->value)) { |
| 120 NotifyConsumer(request, forms); | 119 ForwardLoginsResult(request); |
| 121 allow_fallback_ = false; | 120 allow_fallback_ = false; |
| 122 } else if (allow_default_store()) { | 121 } else if (allow_default_store()) { |
| 123 PasswordStoreDefault::GetAutofillableLoginsImpl(request); | 122 PasswordStoreDefault::GetAutofillableLoginsImpl(request); |
| 124 } else { | 123 } else { |
| 125 // The consumer will be left hanging unless we reply. | 124 // The consumer will be left hanging unless we reply. |
| 126 NotifyConsumer(request, forms); | 125 ForwardLoginsResult(request); |
| 127 } | 126 } |
| 128 } | 127 } |
| 129 | 128 |
| 130 void PasswordStoreX::GetBlacklistLoginsImpl(GetLoginsRequest* request) { | 129 void PasswordStoreX::GetBlacklistLoginsImpl(GetLoginsRequest* request) { |
| 131 CheckMigration(); | 130 CheckMigration(); |
| 132 vector<PasswordForm*> forms; | 131 if (use_native_backend() && |
| 133 if (use_native_backend() && backend_->GetBlacklistLogins(&forms)) { | 132 backend_->GetBlacklistLogins(&request->value)) { |
| 134 NotifyConsumer(request, forms); | 133 ForwardLoginsResult(request); |
| 135 allow_fallback_ = false; | 134 allow_fallback_ = false; |
| 136 } else if (allow_default_store()) { | 135 } else if (allow_default_store()) { |
| 137 PasswordStoreDefault::GetBlacklistLoginsImpl(request); | 136 PasswordStoreDefault::GetBlacklistLoginsImpl(request); |
| 138 } else { | 137 } else { |
| 139 // The consumer will be left hanging unless we reply. | 138 // The consumer will be left hanging unless we reply. |
| 140 NotifyConsumer(request, forms); | 139 ForwardLoginsResult(request); |
| 141 } | 140 } |
| 142 } | 141 } |
| 143 | 142 |
| 144 bool PasswordStoreX::FillAutofillableLogins(vector<PasswordForm*>* forms) { | 143 bool PasswordStoreX::FillAutofillableLogins(vector<PasswordForm*>* forms) { |
| 145 CheckMigration(); | 144 CheckMigration(); |
| 146 if (use_native_backend() && backend_->GetAutofillableLogins(forms)) { | 145 if (use_native_backend() && backend_->GetAutofillableLogins(forms)) { |
| 147 allow_fallback_ = false; | 146 allow_fallback_ = false; |
| 148 return true; | 147 return true; |
| 149 } | 148 } |
| 150 if (allow_default_store()) | 149 if (allow_default_store()) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // it before deleting the file just in case there is some problem deleting | 225 // it before deleting the file just in case there is some problem deleting |
| 227 // the file (e.g. directory is not writable, but file is), which would | 226 // the file (e.g. directory is not writable, but file is), which would |
| 228 // otherwise cause passwords to re-migrate next (or maybe every) time. | 227 // otherwise cause passwords to re-migrate next (or maybe every) time. |
| 229 DeleteAndRecreateDatabaseFile(); | 228 DeleteAndRecreateDatabaseFile(); |
| 230 } | 229 } |
| 231 } | 230 } |
| 232 ssize_t result = ok ? forms.size() : -1; | 231 ssize_t result = ok ? forms.size() : -1; |
| 233 STLDeleteElements(&forms); | 232 STLDeleteElements(&forms); |
| 234 return result; | 233 return result; |
| 235 } | 234 } |
| OLD | NEW |