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_manager.h" | 5 #include "chrome/browser/password_manager/password_manager.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 // Also get out of here if the user told us to 'never remember' passwords for | 175 // Also get out of here if the user told us to 'never remember' passwords for |
176 // this form. | 176 // this form. |
177 if (manager->IsBlacklisted()) | 177 if (manager->IsBlacklisted()) |
178 return; | 178 return; |
179 | 179 |
180 // Bail if we're missing any of the necessary form components. | 180 // Bail if we're missing any of the necessary form components. |
181 if (!manager->HasValidPasswordForm()) | 181 if (!manager->HasValidPasswordForm()) |
182 return; | 182 return; |
183 | 183 |
| 184 // Always save generated passwords, as the user expresses explicit intent for |
| 185 // Chrome to manage such passwords. For other passwords, respect the |
| 186 // autocomplete attribute. |
| 187 if (!manager->HasGeneratedPassword() && !form.password_autocomplete_set) |
| 188 return; |
| 189 |
184 PasswordForm provisionally_saved_form(form); | 190 PasswordForm provisionally_saved_form(form); |
185 provisionally_saved_form.ssl_valid = form.origin.SchemeIsSecure() && | 191 provisionally_saved_form.ssl_valid = form.origin.SchemeIsSecure() && |
186 !delegate_->DidLastPageLoadEncounterSSLErrors(); | 192 !delegate_->DidLastPageLoadEncounterSSLErrors(); |
187 provisionally_saved_form.preferred = true; | 193 provisionally_saved_form.preferred = true; |
188 manager->ProvisionallySave(provisionally_saved_form); | 194 manager->ProvisionallySave(provisionally_saved_form); |
189 provisional_save_manager_.swap(manager); | 195 provisional_save_manager_.swap(manager); |
190 } | 196 } |
191 | 197 |
192 void PasswordManager::SetObserver(LoginModelObserver* observer) { | 198 void PasswordManager::SetObserver(LoginModelObserver* observer) { |
193 observer_ = observer; | 199 observer_ = observer; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 delegate_->FillPasswordForm(fill_data); | 313 delegate_->FillPasswordForm(fill_data); |
308 return; | 314 return; |
309 } | 315 } |
310 default: | 316 default: |
311 if (observer_) { | 317 if (observer_) { |
312 observer_->OnAutofillDataAvailable(preferred_match.username_value, | 318 observer_->OnAutofillDataAvailable(preferred_match.username_value, |
313 preferred_match.password_value); | 319 preferred_match.password_value); |
314 } | 320 } |
315 } | 321 } |
316 } | 322 } |
OLD | NEW |