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

Side by Side Diff: components/browsing_data/core/counters/passwords_counter.h

Issue 2798243004: Show password sync status in CBD (Closed)
Patch Set: add sync test Created 3 years, 8 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 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 #ifndef COMPONENTS_BROWSING_DATA_CORE_COUNTERS_PASSWORDS_COUNTER_H_ 5 #ifndef COMPONENTS_BROWSING_DATA_CORE_COUNTERS_PASSWORDS_COUNTER_H_
6 #define COMPONENTS_BROWSING_DATA_CORE_COUNTERS_PASSWORDS_COUNTER_H_ 6 #define COMPONENTS_BROWSING_DATA_CORE_COUNTERS_PASSWORDS_COUNTER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "components/browsing_data/core/counters/browsing_data_counter.h" 11 #include "components/browsing_data/core/counters/browsing_data_counter.h"
12 #include "components/password_manager/core/browser/password_store.h" 12 #include "components/password_manager/core/browser/password_store.h"
13 #include "components/password_manager/core/browser/password_store_consumer.h" 13 #include "components/password_manager/core/browser/password_store_consumer.h"
14 #include "components/sync/driver/sync_service_observer.h"
14 15
15 namespace browsing_data { 16 namespace browsing_data {
16 17
17 class PasswordsCounter : public browsing_data::BrowsingDataCounter, 18 class PasswordsCounter : public browsing_data::BrowsingDataCounter,
18 public password_manager::PasswordStoreConsumer, 19 public password_manager::PasswordStoreConsumer,
19 public password_manager::PasswordStore::Observer { 20 public password_manager::PasswordStore::Observer,
21 public syncer::SyncServiceObserver {
20 public: 22 public:
23 class PasswordResult : public FinishedResult {
24 public:
25 PasswordResult(const PasswordsCounter* source,
26 ResultInt value,
27 bool password_sync_enabled);
28 ~PasswordResult() override;
29
30 bool password_sync_enabled() const { return password_sync_enabled_; }
31
32 private:
33 bool password_sync_enabled_;
34 };
35
21 explicit PasswordsCounter( 36 explicit PasswordsCounter(
22 scoped_refptr<password_manager::PasswordStore> store); 37 scoped_refptr<password_manager::PasswordStore> store,
38 syncer::SyncService* sync_service);
23 ~PasswordsCounter() override; 39 ~PasswordsCounter() override;
24 40
25 const char* GetPrefName() const override; 41 const char* GetPrefName() const override;
26 42
27 private: 43 private:
28 void OnInitialized() override; 44 void OnInitialized() override;
29 45
30 // Counting is done asynchronously in a request to PasswordStore. 46 // Counting is done asynchronously in a request to PasswordStore.
31 // This callback returns the results, which are subsequently reported. 47 // This callback returns the results, which are subsequently reported.
32 void OnGetPasswordStoreResults( 48 void OnGetPasswordStoreResults(
33 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; 49 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override;
34 50
35 // Called when the contents of the password store change. Triggers new 51 // Called when the contents of the password store change. Triggers new
36 // counting. 52 // counting.
37 void OnLoginsChanged( 53 void OnLoginsChanged(
38 const password_manager::PasswordStoreChangeList& changes) override; 54 const password_manager::PasswordStoreChangeList& changes) override;
39 55
56 // SyncServiceObserver implementation.
57 void OnStateChanged(syncer::SyncService* sync) override;
58
40 void Count() override; 59 void Count() override;
41 60
42 base::CancelableTaskTracker cancelable_task_tracker_; 61 base::CancelableTaskTracker cancelable_task_tracker_;
43 scoped_refptr<password_manager::PasswordStore> store_; 62 scoped_refptr<password_manager::PasswordStore> store_;
63 syncer::SyncService* sync_service_;
64 bool password_sync_enabled_;
44 }; 65 };
45 66
46 } // namespace browsing_data 67 } // namespace browsing_data
47 68
48 #endif // COMPONENTS_BROWSING_DATA_CORE_COUNTERS_PASSWORDS_COUNTER_H_ 69 #endif // COMPONENTS_BROWSING_DATA_CORE_COUNTERS_PASSWORDS_COUNTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698