OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/browsing_data/passwords_counter.h" | 5 #include "chrome/browser/browsing_data/passwords_counter.h" |
6 #include "chrome/browser/password_manager/password_store_factory.h" | 6 #include "chrome/browser/password_manager/password_store_factory.h" |
7 #include "chrome/browser/profiles/profile.h" | |
7 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
8 #include "components/password_manager/core/browser/password_store.h" | 9 #include "components/password_manager/core/browser/password_store.h" |
9 | 10 |
10 PasswordsCounter::PasswordsCounter() : pref_name_(prefs::kDeletePasswords) {} | 11 PasswordsCounter::PasswordsCounter(Profile* profile) |
12 : BrowsingDataCounter(prefs::kDeletePasswords), profile_(profile) {} | |
11 | 13 |
12 PasswordsCounter::~PasswordsCounter() { | 14 PasswordsCounter::~PasswordsCounter() { |
13 if (store_) | 15 if (store_) |
Bernhard Bauer
2016/06/28 14:29:39
Now that we're asserting that |store_| can never b
ioanap
2016/06/29 10:55:20
Done.
| |
14 store_->RemoveObserver(this); | 16 store_->RemoveObserver(this); |
15 } | 17 } |
16 | 18 |
17 void PasswordsCounter::OnInitialized() { | 19 void PasswordsCounter::OnInitialized() { |
18 store_ = PasswordStoreFactory::GetForProfile( | 20 store_ = PasswordStoreFactory::GetForProfile( |
19 GetProfile(), ServiceAccessType::EXPLICIT_ACCESS).get(); | 21 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
20 if (store_) | 22 DCHECK(store_); |
21 store_->AddObserver(this); | 23 store_->AddObserver(this); |
22 else | |
23 LOG(ERROR) << "No password store! Cannot count passwords."; | |
24 } | |
25 | |
26 const std::string& PasswordsCounter::GetPrefName() const { | |
27 return pref_name_; | |
28 } | 24 } |
29 | 25 |
30 void PasswordsCounter::Count() { | 26 void PasswordsCounter::Count() { |
31 if (!store_) { | 27 if (!store_) { |
32 ReportResult(0); | 28 ReportResult(0); |
33 return; | 29 return; |
34 } | 30 } |
35 | 31 |
36 cancelable_task_tracker()->TryCancelAll(); | 32 cancelable_task_tracker()->TryCancelAll(); |
37 // TODO(msramek): We don't actually need the logins themselves, just their | 33 // TODO(msramek): We don't actually need the logins themselves, just their |
(...skipping 11 matching lines...) Expand all Loading... | |
49 results.end(), | 45 results.end(), |
50 [start](const autofill::PasswordForm* form) { | 46 [start](const autofill::PasswordForm* form) { |
51 return form->date_created >= start; | 47 return form->date_created >= start; |
52 })); | 48 })); |
53 } | 49 } |
54 | 50 |
55 void PasswordsCounter::OnLoginsChanged( | 51 void PasswordsCounter::OnLoginsChanged( |
56 const password_manager::PasswordStoreChangeList& changes) { | 52 const password_manager::PasswordStoreChangeList& changes) { |
57 Restart(); | 53 Restart(); |
58 } | 54 } |
OLD | NEW |