OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/sync/browser/sync_credentials_filter.h" | 5 #include "components/password_manager/sync/browser/sync_credentials_filter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 ScopedVector<PasswordForm> SyncCredentialsFilter::FilterResults( | 51 ScopedVector<PasswordForm> SyncCredentialsFilter::FilterResults( |
52 ScopedVector<PasswordForm> results) const { | 52 ScopedVector<PasswordForm> results) const { |
53 const AutofillForSyncCredentialsState autofill_sync_state = | 53 const AutofillForSyncCredentialsState autofill_sync_state = |
54 GetAutofillForSyncCredentialsState(); | 54 GetAutofillForSyncCredentialsState(); |
55 | 55 |
56 if (autofill_sync_state != DISALLOW_SYNC_CREDENTIALS && | 56 if (autofill_sync_state != DISALLOW_SYNC_CREDENTIALS && |
57 (autofill_sync_state != DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH || | 57 (autofill_sync_state != DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH || |
58 !LastLoadWasTransactionalReauthPage( | 58 !LastLoadWasTransactionalReauthPage( |
59 client_->GetLastCommittedEntryURL()))) { | 59 client_->GetLastCommittedEntryURL()))) { |
60 return results.Pass(); | 60 return results; |
61 } | 61 } |
62 | 62 |
63 auto begin_of_removed = | 63 auto begin_of_removed = |
64 std::partition(results.begin(), results.end(), | 64 std::partition(results.begin(), results.end(), |
65 [this](PasswordForm* form) { return ShouldSave(*form); }); | 65 [this](PasswordForm* form) { return ShouldSave(*form); }); |
66 | 66 |
67 // TODO(vabr): Improve the description of the histogram to mention that it is | 67 // TODO(vabr): Improve the description of the histogram to mention that it is |
68 // only reported for forms where the sync credentials would have been filled | 68 // only reported for forms where the sync credentials would have been filled |
69 // in. | 69 // in. |
70 UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered", | 70 UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered", |
71 begin_of_removed != results.end()); | 71 begin_of_removed != results.end()); |
72 | 72 |
73 results.erase(begin_of_removed, results.end()); | 73 results.erase(begin_of_removed, results.end()); |
74 | 74 |
75 return results.Pass(); | 75 return results; |
76 } | 76 } |
77 | 77 |
78 bool SyncCredentialsFilter::ShouldSave( | 78 bool SyncCredentialsFilter::ShouldSave( |
79 const autofill::PasswordForm& form) const { | 79 const autofill::PasswordForm& form) const { |
80 return !sync_util::IsSyncAccountCredential( | 80 return !sync_util::IsSyncAccountCredential( |
81 form, sync_service_factory_function_.Run(), | 81 form, sync_service_factory_function_.Run(), |
82 signin_manager_factory_function_.Run()); | 82 signin_manager_factory_function_.Run()); |
83 } | 83 } |
84 | 84 |
85 void SyncCredentialsFilter::ReportFormUsed( | 85 void SyncCredentialsFilter::ReportFormUsed( |
(...skipping 21 matching lines...) Expand all Loading... |
107 if (group_name == "DisallowSyncCredentialsForReauth") | 107 if (group_name == "DisallowSyncCredentialsForReauth") |
108 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 108 return DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
109 if (group_name == "DisallowSyncCredentials") | 109 if (group_name == "DisallowSyncCredentials") |
110 return DISALLOW_SYNC_CREDENTIALS; | 110 return DISALLOW_SYNC_CREDENTIALS; |
111 | 111 |
112 // Allow by default. | 112 // Allow by default. |
113 return ALLOW_SYNC_CREDENTIALS; | 113 return ALLOW_SYNC_CREDENTIALS; |
114 } | 114 } |
115 | 115 |
116 } // namespace password_manager | 116 } // namespace password_manager |
OLD | NEW |