summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browsing_data/passwords_counter.h
blob: 85ed1e6a31a2ceb3fcca6b89b6ee4d028c869715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_BROWSING_DATA_PASSWORDS_COUNTER_H_
#define CHROME_BROWSER_BROWSING_DATA_PASSWORDS_COUNTER_H_

#include "chrome/browser/browsing_data/browsing_data_counter.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_store_consumer.h"

class PasswordsCounter: public BrowsingDataCounter,
                        public password_manager::PasswordStoreConsumer,
                        public password_manager::PasswordStore::Observer {
 public:
  PasswordsCounter();
  ~PasswordsCounter() override;

  const std::string& GetPrefName() const override;

 private:
  const std::string pref_name_;
  base::CancelableTaskTracker cancelable_task_tracker_;
  password_manager::PasswordStore* store_ = nullptr;

  void OnInitialized() override;

  // Counting is done asynchronously in a request to PasswordStore.
  // This callback returns the results, which are subsequently reported.
  void OnGetPasswordStoreResults(
      ScopedVector<autofill::PasswordForm> results) override;

  // Called when the contents of the password store change. Triggers new
  // counting.
  void OnLoginsChanged(
      const password_manager::PasswordStoreChangeList& changes) override;

  void Count() override;
};

#endif  // CHROME_BROWSER_BROWSING_DATA_PASSWORDS_COUNTER_H_