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_SETTINGS_PRIVATE_SETTINGS_PRIVATE_EVENT_RO
UTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_EVENT_RO
UTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_EVENT_RO
UTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_EVENT_RO
UTER_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "chrome/browser/chromeos/settings/cros_settings.h" | 11 #include "chrome/browser/chromeos/settings/cros_settings.h" |
10 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" | 12 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" |
11 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
12 #include "components/prefs/pref_change_registrar.h" | 14 #include "components/prefs/pref_change_registrar.h" |
13 #include "extensions/browser/event_router.h" | 15 #include "extensions/browser/event_router.h" |
14 | 16 |
15 namespace content { | 17 namespace content { |
16 class BrowserContext; | 18 class BrowserContext; |
17 } | 19 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // Decide if we should listen for pref changes or not. If there are any | 52 // Decide if we should listen for pref changes or not. If there are any |
51 // JavaScript listeners registered for the onPrefsChanged event, then we | 53 // JavaScript listeners registered for the onPrefsChanged event, then we |
52 // want to register for change notification from the PrefChangeRegistrar. | 54 // want to register for change notification from the PrefChangeRegistrar. |
53 // Otherwise, we want to unregister and not be listening for pref changes. | 55 // Otherwise, we want to unregister and not be listening for pref changes. |
54 void StartOrStopListeningForPrefsChanges(); | 56 void StartOrStopListeningForPrefsChanges(); |
55 | 57 |
56 void OnPreferenceChanged(const std::string& pref_name); | 58 void OnPreferenceChanged(const std::string& pref_name); |
57 | 59 |
58 PrefChangeRegistrar* FindRegistrarForPref(const std::string& pref_name); | 60 PrefChangeRegistrar* FindRegistrarForPref(const std::string& pref_name); |
59 | 61 |
60 typedef std::map<std::string, | 62 using SubscriptionMap = |
61 linked_ptr<chromeos::CrosSettings::ObserverSubscription>> | 63 std::map<std::string, |
62 SubscriptionMap; | 64 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>>; |
63 SubscriptionMap cros_settings_subscription_map_; | 65 SubscriptionMap cros_settings_subscription_map_; |
64 | 66 |
65 content::BrowserContext* context_; | 67 content::BrowserContext* context_; |
66 bool listening_; | 68 bool listening_; |
67 | 69 |
68 std::unique_ptr<PrefsUtil> prefs_util_; | 70 std::unique_ptr<PrefsUtil> prefs_util_; |
69 | 71 |
70 DISALLOW_COPY_AND_ASSIGN(SettingsPrivateEventRouter); | 72 DISALLOW_COPY_AND_ASSIGN(SettingsPrivateEventRouter); |
71 }; | 73 }; |
72 | 74 |
73 } // namespace extensions | 75 } // namespace extensions |
74 | 76 |
75 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_EVENT
_ROUTER_H_ | 77 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_EVENT
_ROUTER_H_ |
OLD | NEW |