| 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" |
| 11 #include "chrome/browser/password_manager/password_form_manager.h" | 11 #include "chrome/browser/password_manager/password_form_manager.h" |
| 12 #include "chrome/browser/password_manager/password_manager_delegate.h" | 12 #include "chrome/browser/password_manager/password_manager_delegate.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/autofill_messages.h" | 15 #include "chrome/common/autofill_messages.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/common/frame_navigate_params.h" | 19 #include "content/public/common/frame_navigate_params.h" |
| 20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 21 | 21 |
| 22 using content::UserMetricsAction; | 22 using content::UserMetricsAction; |
| 23 using content::WebContents; | 23 using content::WebContents; |
| 24 using webkit::forms::PasswordForm; | 24 using content::PasswordForm; |
| 25 using webkit::forms::PasswordFormMap; | 25 using content::PasswordFormMap; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const char kSpdyProxyRealm[] = "/SpdyProxy"; | 29 const char kSpdyProxyRealm[] = "/SpdyProxy"; |
| 30 | 30 |
| 31 // This routine is called when PasswordManagers are constructed. | 31 // This routine is called when PasswordManagers are constructed. |
| 32 // | 32 // |
| 33 // Currently we report metrics only once at startup. We require | 33 // Currently we report metrics only once at startup. We require |
| 34 // 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 |
| 35 // 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 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 void PasswordManager::Autofill( | 279 void PasswordManager::Autofill( |
| 280 const PasswordForm& form_for_autofill, | 280 const PasswordForm& form_for_autofill, |
| 281 const PasswordFormMap& best_matches, | 281 const PasswordFormMap& best_matches, |
| 282 const PasswordForm& preferred_match, | 282 const PasswordForm& preferred_match, |
| 283 bool wait_for_username) const { | 283 bool wait_for_username) const { |
| 284 switch (form_for_autofill.scheme) { | 284 switch (form_for_autofill.scheme) { |
| 285 case PasswordForm::SCHEME_HTML: { | 285 case PasswordForm::SCHEME_HTML: { |
| 286 // Note the check above is required because the observer_ for a non-HTML | 286 // Note the check above is required because the observer_ for a non-HTML |
| 287 // schemed password form may have been freed, so we need to distinguish. | 287 // schemed password form may have been freed, so we need to distinguish. |
| 288 webkit::forms::PasswordFormFillData fill_data; | 288 PasswordFormFillData fill_data; |
| 289 webkit::forms::PasswordFormDomManager::InitFillData(form_for_autofill, | 289 InitPasswordFormFillData(form_for_autofill, |
| 290 best_matches, | 290 best_matches, |
| 291 &preferred_match, | 291 &preferred_match, |
| 292 wait_for_username, | 292 wait_for_username, |
| 293 &fill_data); | 293 &fill_data); |
| 294 delegate_->FillPasswordForm(fill_data); | 294 delegate_->FillPasswordForm(fill_data); |
| 295 return; | 295 return; |
| 296 } | 296 } |
| 297 default: | 297 default: |
| 298 if (observer_) { | 298 if (observer_) { |
| 299 observer_->OnAutofillDataAvailable(preferred_match.username_value, | 299 observer_->OnAutofillDataAvailable(preferred_match.username_value, |
| 300 preferred_match.password_value); | 300 preferred_match.password_value); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 bool PasswordManager::IsFillingEnabled() const { | 305 bool PasswordManager::IsFillingEnabled() const { |
| 306 return delegate_->GetProfile() && *password_manager_enabled_; | 306 return delegate_->GetProfile() && *password_manager_enabled_; |
| 307 } | 307 } |
| OLD | NEW |