| 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/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/password_manager/password_form_manager.h" | 11 #include "chrome/browser/password_manager/password_form_manager.h" |
| 11 #include "chrome/browser/password_manager/password_manager_delegate.h" | 12 #include "chrome/browser/password_manager/password_manager_delegate.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/autofill_messages.h" | 15 #include "chrome/common/autofill_messages.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/common/frame_navigate_params.h" | 19 #include "content/public/common/frame_navigate_params.h" |
| 19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 20 | 21 |
| 21 using content::UserMetricsAction; | 22 using content::UserMetricsAction; |
| 22 using content::WebContents; | 23 using content::WebContents; |
| 23 using webkit::forms::PasswordForm; | 24 using webkit::forms::PasswordForm; |
| 24 using webkit::forms::PasswordFormMap; | 25 using webkit::forms::PasswordFormMap; |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 29 const char kSpdyProxyRealm[] = "/SpdyProxy"; |
| 30 |
| 28 // This routine is called when PasswordManagers are constructed. | 31 // This routine is called when PasswordManagers are constructed. |
| 29 // | 32 // |
| 30 // Currently we report metrics only once at startup. We require | 33 // Currently we report metrics only once at startup. We require |
| 31 // that this is only ever called from a single thread in order to | 34 // that this is only ever called from a single thread in order to |
| 32 // avoid needing to lock (a static boolean flag is then sufficient to | 35 // avoid needing to lock (a static boolean flag is then sufficient to |
| 33 // guarantee running only once). | 36 // guarantee running only once). |
| 34 void ReportMetrics(bool password_manager_enabled) { | 37 void ReportMetrics(bool password_manager_enabled) { |
| 35 static base::PlatformThreadId initial_thread_id = | 38 static base::PlatformThreadId initial_thread_id = |
| 36 base::PlatformThread::CurrentId(); | 39 base::PlatformThread::CurrentId(); |
| 37 DCHECK(initial_thread_id == base::PlatformThread::CurrentId()); | 40 DCHECK(initial_thread_id == base::PlatformThread::CurrentId()); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 void PasswordManager::OnPasswordFormsParsed( | 208 void PasswordManager::OnPasswordFormsParsed( |
| 206 const std::vector<PasswordForm>& forms) { | 209 const std::vector<PasswordForm>& forms) { |
| 207 if (!IsFillingEnabled()) | 210 if (!IsFillingEnabled()) |
| 208 return; | 211 return; |
| 209 | 212 |
| 210 // Ask the SSLManager for current security. | 213 // Ask the SSLManager for current security. |
| 211 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors(); | 214 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors(); |
| 212 | 215 |
| 213 for (std::vector<PasswordForm>::const_iterator iter = forms.begin(); | 216 for (std::vector<PasswordForm>::const_iterator iter = forms.begin(); |
| 214 iter != forms.end(); ++iter) { | 217 iter != forms.end(); ++iter) { |
| 218 // Don't involve the password manager if this form corresponds to |
| 219 // SpdyProxy authentication, as indicated by the realm. |
| 220 if (EndsWith(iter->signon_realm, kSpdyProxyRealm, true)) |
| 221 continue; |
| 222 |
| 215 bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error; | 223 bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error; |
| 216 PasswordFormManager* manager = | 224 PasswordFormManager* manager = |
| 217 new PasswordFormManager(delegate_->GetProfile(), | 225 new PasswordFormManager(delegate_->GetProfile(), |
| 218 this, | 226 this, |
| 219 web_contents(), | 227 web_contents(), |
| 220 *iter, | 228 *iter, |
| 221 ssl_valid); | 229 ssl_valid); |
| 222 pending_login_managers_.push_back(manager); | 230 pending_login_managers_.push_back(manager); |
| 223 manager->FetchMatchingLoginsFromPasswordStore(); | 231 manager->FetchMatchingLoginsFromPasswordStore(); |
| 224 } | 232 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (observer_) { | 298 if (observer_) { |
| 291 observer_->OnAutofillDataAvailable(preferred_match.username_value, | 299 observer_->OnAutofillDataAvailable(preferred_match.username_value, |
| 292 preferred_match.password_value); | 300 preferred_match.password_value); |
| 293 } | 301 } |
| 294 } | 302 } |
| 295 } | 303 } |
| 296 | 304 |
| 297 bool PasswordManager::IsFillingEnabled() const { | 305 bool PasswordManager::IsFillingEnabled() const { |
| 298 return delegate_->GetProfile() && *password_manager_enabled_; | 306 return delegate_->GetProfile() && *password_manager_enabled_; |
| 299 } | 307 } |
| OLD | NEW |