Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / api / autofill_private / autofill_private_event_router.h
blob65be92081c567ab84152aebb5a1d06bf199a189b
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT_ROUTER_H_
8 #include "components/autofill/core/browser/personal_data_manager_observer.h"
9 #include "components/keyed_service/core/keyed_service.h"
10 #include "extensions/browser/event_router.h"
12 namespace autofill {
13 class PersonalDataManager;
16 namespace content {
17 class BrowserContext;
20 namespace extensions {
22 // An event router that observes changes to autofill addresses and credit cards
23 // and notifies listeners to the onAddressListChanged and
24 // onCreditCardListChanged events of changes.
25 class AutofillPrivateEventRouter :
26 public KeyedService,
27 public EventRouter::Observer,
28 public autofill::PersonalDataManagerObserver {
29 public:
30 static AutofillPrivateEventRouter* Create(
31 content::BrowserContext* browser_context);
32 ~AutofillPrivateEventRouter() override;
34 protected:
35 explicit AutofillPrivateEventRouter(content::BrowserContext* context);
37 // KeyedService overrides:
38 void Shutdown() override;
40 // EventRouter::Observer overrides:
41 void OnListenerAdded(const EventListenerInfo& details) override;
42 void OnListenerRemoved(const EventListenerInfo& details) override;
44 // PersonalDataManagerObserver implementation.
45 void OnPersonalDataChanged() override;
47 private:
48 // Either listens or unlistens for changes to |personal_data_|, depending on
49 // whether clients are listening to the autofillPrivate API events.
50 void StartOrStopListeningForChanges();
52 content::BrowserContext* context_;
54 EventRouter* event_router_;
56 autofill::PersonalDataManager* personal_data_;
58 // Whether this class is currently listening for changes to |personal_data_|.
59 bool listening_;
61 DISALLOW_COPY_AND_ASSIGN(AutofillPrivateEventRouter);
64 } // namespace extensions
66 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT_ROUTER_H_