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/browsing_data/core/counters/passwords_counter.h" | 5 #include "components/browsing_data/core/counters/passwords_counter.h" |
6 | 6 |
7 #include "components/browsing_data/core/pref_names.h" | 7 #include "components/browsing_data/core/pref_names.h" |
8 #include "components/password_manager/core/browser/password_manager_util.h" | 8 #include "components/password_manager/core/browser/password_manager_util.h" |
9 #include "components/password_manager/core/browser/password_store.h" | 9 #include "components/password_manager/core/browser/password_store.h" |
10 #include "components/sync/driver/sync_service.h" | 10 #include "components/sync/driver/sync_service.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 void PasswordsCounter::OnGetPasswordStoreResults( | 58 void PasswordsCounter::OnGetPasswordStoreResults( |
59 std::vector<std::unique_ptr<autofill::PasswordForm>> results) { | 59 std::vector<std::unique_ptr<autofill::PasswordForm>> results) { |
60 base::Time start = GetPeriodStart(); | 60 base::Time start = GetPeriodStart(); |
61 int num_passwords = std::count_if( | 61 int num_passwords = std::count_if( |
62 results.begin(), results.end(), | 62 results.begin(), results.end(), |
63 [start](const std::unique_ptr<autofill::PasswordForm>& form) { | 63 [start](const std::unique_ptr<autofill::PasswordForm>& form) { |
64 return form->date_created >= start; | 64 return form->date_created >= start; |
65 }); | 65 }); |
66 ReportResult(base::MakeUnique<PasswordResult>(this, num_passwords, | 66 ReportResult(base::MakeUnique<SyncResult>(this, num_passwords, |
67 password_sync_enabled_)); | 67 password_sync_enabled_)); |
68 } | 68 } |
69 | 69 |
70 void PasswordsCounter::OnLoginsChanged( | 70 void PasswordsCounter::OnLoginsChanged( |
71 const password_manager::PasswordStoreChangeList& changes) { | 71 const password_manager::PasswordStoreChangeList& changes) { |
72 Restart(); | 72 Restart(); |
73 } | 73 } |
74 | 74 |
75 void PasswordsCounter::OnStateChanged(syncer::SyncService* sync) { | 75 void PasswordsCounter::OnStateChanged(syncer::SyncService* sync) { |
76 bool sync_enabled_new = IsPasswordSyncEnabled(sync_service_); | 76 bool sync_enabled_new = IsPasswordSyncEnabled(sync_service_); |
77 | 77 |
78 if (password_sync_enabled_ != sync_enabled_new) { | 78 if (password_sync_enabled_ != sync_enabled_new) { |
79 password_sync_enabled_ = sync_enabled_new; | 79 password_sync_enabled_ = sync_enabled_new; |
80 Restart(); | 80 Restart(); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 // PasswordsCounter::PasswordResult | |
85 | |
86 PasswordsCounter::PasswordResult::PasswordResult(const PasswordsCounter* source, | |
87 ResultInt value, | |
88 bool password_sync_enabled) | |
89 : FinishedResult(source, value), | |
90 password_sync_enabled_(password_sync_enabled) {} | |
91 | |
92 PasswordsCounter::PasswordResult::~PasswordResult() {} | |
93 | |
94 } // namespace browsing_data | 84 } // namespace browsing_data |
OLD | NEW |