| 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT_RO
UTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT_RO
UTER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT_RO
UTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT_RO
UTER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 9 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 10 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 static AutofillPrivateEventRouter* Create( | 31 static AutofillPrivateEventRouter* Create( |
| 32 content::BrowserContext* browser_context); | 32 content::BrowserContext* browser_context); |
| 33 ~AutofillPrivateEventRouter() override; | 33 ~AutofillPrivateEventRouter() override; |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 explicit AutofillPrivateEventRouter(content::BrowserContext* context); | 36 explicit AutofillPrivateEventRouter(content::BrowserContext* context); |
| 37 | 37 |
| 38 // KeyedService overrides: | 38 // KeyedService overrides: |
| 39 void Shutdown() override; | 39 void Shutdown() override; |
| 40 | 40 |
| 41 // EventRouter::Observer overrides: | |
| 42 void OnListenerAdded(const EventListenerInfo& details) override; | |
| 43 void OnListenerRemoved(const EventListenerInfo& details) override; | |
| 44 | |
| 45 // PersonalDataManagerObserver implementation. | 41 // PersonalDataManagerObserver implementation. |
| 46 void OnPersonalDataChanged() override; | 42 void OnPersonalDataChanged() override; |
| 47 | 43 |
| 48 private: | 44 private: |
| 49 // Either listens or unlistens for changes to |personal_data_|, depending on | |
| 50 // whether clients are listening to the autofillPrivate API events. | |
| 51 void StartOrStopListeningForChanges(); | |
| 52 | |
| 53 content::BrowserContext* context_; | 45 content::BrowserContext* context_; |
| 54 | 46 |
| 55 EventRouter* event_router_; | 47 EventRouter* event_router_; |
| 56 | 48 |
| 57 autofill::PersonalDataManager* personal_data_; | 49 autofill::PersonalDataManager* personal_data_; |
| 58 | 50 |
| 59 // Whether this class is currently listening for changes to |personal_data_|. | 51 // Whether this class is currently listening for changes to |personal_data_|. |
| 60 bool listening_; | 52 bool listening_; |
| 61 | 53 |
| 62 DISALLOW_COPY_AND_ASSIGN(AutofillPrivateEventRouter); | 54 DISALLOW_COPY_AND_ASSIGN(AutofillPrivateEventRouter); |
| 63 }; | 55 }; |
| 64 | 56 |
| 65 } // namespace extensions | 57 } // namespace extensions |
| 66 | 58 |
| 67 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT
_ROUTER_H_ | 59 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_PRIVATE_EVENT
_ROUTER_H_ |
| OLD | NEW |