Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: components/password_manager/core/browser/password_manager.cc

Issue 1668523002: [Password Manager] Switch password manager code to use the Feature framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 } 651 }
668 652
669 void PasswordManager::OnLoginSuccessful() { 653 void PasswordManager::OnLoginSuccessful() {
670 scoped_ptr<BrowserSavePasswordProgressLogger> logger; 654 scoped_ptr<BrowserSavePasswordProgressLogger> logger;
671 if (password_manager_util::IsLoggingActive(client_)) { 655 if (password_manager_util::IsLoggingActive(client_)) {
672 logger.reset( 656 logger.reset(
673 new BrowserSavePasswordProgressLogger(client_->GetLogManager())); 657 new BrowserSavePasswordProgressLogger(client_->GetLogManager()));
674 logger->LogMessage(Logger::STRING_ON_ASK_USER_OR_SAVE_PASSWORD); 658 logger->LogMessage(Logger::STRING_ON_ASK_USER_OR_SAVE_PASSWORD);
675 } 659 }
676 660
677 if (ShouldDropSyncCredential() && 661 if (base::FeatureList::IsEnabled(features::kDropSyncCredential) &&
678 !client_->GetStoreResultFilter()->ShouldSave( 662 !client_->GetStoreResultFilter()->ShouldSave(
679 provisional_save_manager_->pending_credentials())) { 663 provisional_save_manager_->pending_credentials())) {
680 provisional_save_manager_->WipeStoreCopyIfOutdated(); 664 provisional_save_manager_->WipeStoreCopyIfOutdated();
681 RecordFailure(SYNC_CREDENTIAL, 665 RecordFailure(SYNC_CREDENTIAL,
682 provisional_save_manager_->observed_form().origin, 666 provisional_save_manager_->observed_form().origin,
683 logger.get()); 667 logger.get());
684 provisional_save_manager_.reset(); 668 provisional_save_manager_.reset();
685 return; 669 return;
686 } 670 }
687 671
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 matched_manager_it = iter; 829 matched_manager_it = iter;
846 current_match_result = result; 830 current_match_result = result;
847 } 831 }
848 } 832 }
849 if (matched_manager_it != pending_login_managers_.end()) 833 if (matched_manager_it != pending_login_managers_.end())
850 return *matched_manager_it; 834 return *matched_manager_it;
851 return nullptr; 835 return nullptr;
852 } 836 }
853 837
854 } // namespace password_manager 838 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698