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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 this, | 114 this, |
115 web_contents(), | 115 web_contents(), |
116 form, | 116 form, |
117 ssl_valid); | 117 ssl_valid); |
118 pending_login_managers_.push_back(manager); | 118 pending_login_managers_.push_back(manager); |
119 manager->SetHasGeneratedPassword(); | 119 manager->SetHasGeneratedPassword(); |
120 // TODO(gcasto): Add UMA stats to track this. | 120 // TODO(gcasto): Add UMA stats to track this. |
121 } | 121 } |
122 | 122 |
123 bool PasswordManager::IsSavingEnabled() const { | 123 bool PasswordManager::IsSavingEnabled() const { |
124 return IsFillingEnabled() && !delegate_->GetProfile()->IsOffTheRecord(); | 124 return *password_manager_enabled_ && |
| 125 !delegate_->GetProfile()->IsOffTheRecord(); |
125 } | 126 } |
126 | 127 |
127 void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { | 128 void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { |
128 if (!IsSavingEnabled()) | 129 if (!IsSavingEnabled()) |
129 return; | 130 return; |
130 | 131 |
131 // No password to save? Then don't. | 132 // No password to save? Then don't. |
132 if (form.password_value.empty()) | 133 if (form.password_value.empty()) |
133 return; | 134 return; |
134 | 135 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 OnPasswordFormsParsed) | 216 OnPasswordFormsParsed) |
216 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered, | 217 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered, |
217 OnPasswordFormsRendered) | 218 OnPasswordFormsRendered) |
218 IPC_MESSAGE_UNHANDLED(handled = false) | 219 IPC_MESSAGE_UNHANDLED(handled = false) |
219 IPC_END_MESSAGE_MAP() | 220 IPC_END_MESSAGE_MAP() |
220 return handled; | 221 return handled; |
221 } | 222 } |
222 | 223 |
223 void PasswordManager::OnPasswordFormsParsed( | 224 void PasswordManager::OnPasswordFormsParsed( |
224 const std::vector<PasswordForm>& forms) { | 225 const std::vector<PasswordForm>& forms) { |
225 if (!IsFillingEnabled()) | |
226 return; | |
227 | |
228 // Ask the SSLManager for current security. | 226 // Ask the SSLManager for current security. |
229 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors(); | 227 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors(); |
230 | 228 |
231 for (std::vector<PasswordForm>::const_iterator iter = forms.begin(); | 229 for (std::vector<PasswordForm>::const_iterator iter = forms.begin(); |
232 iter != forms.end(); ++iter) { | 230 iter != forms.end(); ++iter) { |
233 // Don't involve the password manager if this form corresponds to | 231 // Don't involve the password manager if this form corresponds to |
234 // SpdyProxy authentication, as indicated by the realm. | 232 // SpdyProxy authentication, as indicated by the realm. |
235 if (EndsWith(iter->signon_realm, kSpdyProxyRealm, true)) | 233 if (EndsWith(iter->signon_realm, kSpdyProxyRealm, true)) |
236 continue; | 234 continue; |
237 | 235 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 delegate_->FillPasswordForm(fill_data); | 307 delegate_->FillPasswordForm(fill_data); |
310 return; | 308 return; |
311 } | 309 } |
312 default: | 310 default: |
313 if (observer_) { | 311 if (observer_) { |
314 observer_->OnAutofillDataAvailable(preferred_match.username_value, | 312 observer_->OnAutofillDataAvailable(preferred_match.username_value, |
315 preferred_match.password_value); | 313 preferred_match.password_value); |
316 } | 314 } |
317 } | 315 } |
318 } | 316 } |
319 | |
320 bool PasswordManager::IsFillingEnabled() const { | |
321 return delegate_->GetProfile() && *password_manager_enabled_; | |
322 } | |
OLD | NEW |