| 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 "components/password_manager/core/browser/password_manager.h" | 5 #include "components/password_manager/core/browser/password_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/command_line.h" | |
| 12 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 13 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
| 17 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 18 #include "components/autofill/core/browser/autofill_field.h" | 17 #include "components/autofill/core/browser/autofill_field.h" |
| 19 #include "components/autofill/core/browser/form_structure.h" | 18 #include "components/autofill/core/browser/form_structure.h" |
| 20 #include "components/autofill/core/common/form_data_predictions.h" | 19 #include "components/autofill/core/common/form_data_predictions.h" |
| 21 #include "components/autofill/core/common/password_form_field_prediction_map.h" | 20 #include "components/autofill/core/common/password_form_field_prediction_map.h" |
| 22 #include "components/password_manager/core/browser/affiliation_utils.h" | 21 #include "components/password_manager/core/browser/affiliation_utils.h" |
| 23 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" | 22 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
| 24 #include "components/password_manager/core/browser/keychain_migration_status_mac
.h" | 23 #include "components/password_manager/core/browser/keychain_migration_status_mac
.h" |
| 25 #include "components/password_manager/core/browser/log_manager.h" | 24 #include "components/password_manager/core/browser/log_manager.h" |
| 26 #include "components/password_manager/core/browser/password_autofill_manager.h" | 25 #include "components/password_manager/core/browser/password_autofill_manager.h" |
| 27 #include "components/password_manager/core/browser/password_form_manager.h" | 26 #include "components/password_manager/core/browser/password_form_manager.h" |
| 28 #include "components/password_manager/core/browser/password_manager_client.h" | 27 #include "components/password_manager/core/browser/password_manager_client.h" |
| 29 #include "components/password_manager/core/browser/password_manager_driver.h" | 28 #include "components/password_manager/core/browser/password_manager_driver.h" |
| 30 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 29 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
| 31 #include "components/password_manager/core/browser/password_manager_util.h" | 30 #include "components/password_manager/core/browser/password_manager_util.h" |
| 31 #include "components/password_manager/core/common/password_manager_features.h" |
| 32 #include "components/password_manager/core/common/password_manager_pref_names.h" | 32 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 33 #include "components/password_manager/core/common/password_manager_switches.h" | |
| 34 #include "components/pref_registry/pref_registry_syncable.h" | 33 #include "components/pref_registry/pref_registry_syncable.h" |
| 35 #include "components/prefs/pref_service.h" | 34 #include "components/prefs/pref_service.h" |
| 36 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 35 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 37 | 36 |
| 38 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 39 #include "components/prefs/pref_registry_simple.h" | 38 #include "components/prefs/pref_registry_simple.h" |
| 40 #endif | 39 #endif |
| 41 | 40 |
| 42 using autofill::PasswordForm; | 41 using autofill::PasswordForm; |
| 43 using autofill::PasswordFormMap; | 42 using autofill::PasswordFormMap; |
| 44 | 43 |
| 45 namespace password_manager { | 44 namespace password_manager { |
| 46 | 45 |
| 47 namespace { | 46 namespace { |
| 48 | 47 |
| 49 const char kSpdyProxyRealm[] = "/SpdyProxy"; | 48 const char kSpdyProxyRealm[] = "/SpdyProxy"; |
| 50 | 49 |
| 51 // Shorten the name to spare line breaks. The code provides enough context | 50 // Shorten the name to spare line breaks. The code provides enough context |
| 52 // already. | 51 // already. |
| 53 typedef autofill::SavePasswordProgressLogger Logger; | 52 typedef autofill::SavePasswordProgressLogger Logger; |
| 54 | 53 |
| 55 bool ShouldDropSyncCredential() { | |
| 56 std::string group_name = | |
| 57 base::FieldTrialList::FindFullName("PasswordManagerDropSyncCredential"); | |
| 58 | |
| 59 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 60 if (command_line->HasSwitch(switches::kEnableDropSyncCredential)) | |
| 61 return true; | |
| 62 | |
| 63 if (command_line->HasSwitch(switches::kDisableDropSyncCredential)) | |
| 64 return false; | |
| 65 | |
| 66 // Default to not saving. | |
| 67 return group_name != "Disabled"; | |
| 68 } | |
| 69 | |
| 70 bool URLsEqualUpToScheme(const GURL& a, const GURL& b) { | 54 bool URLsEqualUpToScheme(const GURL& a, const GURL& b) { |
| 71 return (a.GetContent() == b.GetContent()); | 55 return (a.GetContent() == b.GetContent()); |
| 72 } | 56 } |
| 73 | 57 |
| 74 bool URLsEqualUpToHttpHttpsSubstitution(const GURL& a, const GURL& b) { | 58 bool URLsEqualUpToHttpHttpsSubstitution(const GURL& a, const GURL& b) { |
| 75 if (a == b) | 59 if (a == b) |
| 76 return true; | 60 return true; |
| 77 | 61 |
| 78 // The first-time and retry login forms action URLs sometimes differ in | 62 // The first-time and retry login forms action URLs sometimes differ in |
| 79 // switching from HTTP to HTTPS, see http://crbug.com/400769. | 63 // switching from HTTP to HTTPS, see http://crbug.com/400769. |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 } | 666 } |
| 683 | 667 |
| 684 void PasswordManager::OnLoginSuccessful() { | 668 void PasswordManager::OnLoginSuccessful() { |
| 685 scoped_ptr<BrowserSavePasswordProgressLogger> logger; | 669 scoped_ptr<BrowserSavePasswordProgressLogger> logger; |
| 686 if (password_manager_util::IsLoggingActive(client_)) { | 670 if (password_manager_util::IsLoggingActive(client_)) { |
| 687 logger.reset( | 671 logger.reset( |
| 688 new BrowserSavePasswordProgressLogger(client_->GetLogManager())); | 672 new BrowserSavePasswordProgressLogger(client_->GetLogManager())); |
| 689 logger->LogMessage(Logger::STRING_ON_ASK_USER_OR_SAVE_PASSWORD); | 673 logger->LogMessage(Logger::STRING_ON_ASK_USER_OR_SAVE_PASSWORD); |
| 690 } | 674 } |
| 691 | 675 |
| 692 if (ShouldDropSyncCredential() && | 676 if (base::FeatureList::IsEnabled(features::kDropSyncCredential) && |
| 693 !client_->GetStoreResultFilter()->ShouldSave( | 677 !client_->GetStoreResultFilter()->ShouldSave( |
| 694 provisional_save_manager_->pending_credentials())) { | 678 provisional_save_manager_->pending_credentials())) { |
| 695 provisional_save_manager_->WipeStoreCopyIfOutdated(); | 679 provisional_save_manager_->WipeStoreCopyIfOutdated(); |
| 696 RecordFailure(SYNC_CREDENTIAL, | 680 RecordFailure(SYNC_CREDENTIAL, |
| 697 provisional_save_manager_->observed_form().origin, | 681 provisional_save_manager_->observed_form().origin, |
| 698 logger.get()); | 682 logger.get()); |
| 699 provisional_save_manager_.reset(); | 683 provisional_save_manager_.reset(); |
| 700 return; | 684 return; |
| 701 } | 685 } |
| 702 | 686 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 matched_manager_it = iter; | 841 matched_manager_it = iter; |
| 858 current_match_result = result; | 842 current_match_result = result; |
| 859 } | 843 } |
| 860 } | 844 } |
| 861 if (matched_manager_it != pending_login_managers_.end()) | 845 if (matched_manager_it != pending_login_managers_.end()) |
| 862 return *matched_manager_it; | 846 return *matched_manager_it; |
| 863 return nullptr; | 847 return nullptr; |
| 864 } | 848 } |
| 865 | 849 |
| 866 } // namespace password_manager | 850 } // namespace password_manager |
| OLD | NEW |