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/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/password_manager/password_form_manager.h" | 9 #include "chrome/browser/password_manager/password_form_manager.h" |
10 #include "chrome/browser/password_manager/password_manager_delegate.h" | 10 #include "chrome/browser/password_manager/password_manager_delegate.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 DCHECK(delegate_); | 67 DCHECK(delegate_); |
68 password_manager_enabled_.Init(prefs::kPasswordManagerEnabled, | 68 password_manager_enabled_.Init(prefs::kPasswordManagerEnabled, |
69 delegate_->GetProfileForPasswordManager()->GetPrefs(), NULL); | 69 delegate_->GetProfileForPasswordManager()->GetPrefs(), NULL); |
70 | 70 |
71 ReportMetrics(*password_manager_enabled_); | 71 ReportMetrics(*password_manager_enabled_); |
72 } | 72 } |
73 | 73 |
74 PasswordManager::~PasswordManager() { | 74 PasswordManager::~PasswordManager() { |
75 } | 75 } |
76 | 76 |
| 77 bool PasswordManager::IsEnabled() const { |
| 78 const Profile* profile = delegate_->GetProfileForPasswordManager(); |
| 79 return profile && !profile->IsOffTheRecord() && *password_manager_enabled_; |
| 80 } |
| 81 |
77 void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { | 82 void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { |
78 if (!IsEnabled()) | 83 if (!IsEnabled()) |
79 return; | 84 return; |
80 | 85 |
81 // No password to save? Then don't. | 86 // No password to save? Then don't. |
82 if (form.password_value.empty()) | 87 if (form.password_value.empty()) |
83 return; | 88 return; |
84 | 89 |
85 scoped_ptr<PasswordFormManager> manager; | 90 scoped_ptr<PasswordFormManager> manager; |
86 for (ScopedVector<PasswordFormManager>::iterator iter = | 91 for (ScopedVector<PasswordFormManager>::iterator iter = |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 delegate_->FillPasswordForm(fill_data); | 238 delegate_->FillPasswordForm(fill_data); |
234 return; | 239 return; |
235 } | 240 } |
236 default: | 241 default: |
237 if (observer_) { | 242 if (observer_) { |
238 observer_->OnAutofillDataAvailable(preferred_match.username_value, | 243 observer_->OnAutofillDataAvailable(preferred_match.username_value, |
239 preferred_match.password_value); | 244 preferred_match.password_value); |
240 } | 245 } |
241 } | 246 } |
242 } | 247 } |
243 | |
244 bool PasswordManager::IsEnabled() const { | |
245 const Profile* profile = delegate_->GetProfileForPasswordManager(); | |
246 return profile && !profile->IsOffTheRecord() && *password_manager_enabled_; | |
247 } | |
OLD | NEW |