Avi Drissman | d878a501 | 2022-09-12 19:13:30 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | // |
| 5 | // Helper to initialize PrefService for cast shell. |
| 6 | |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 7 | #ifndef CHROMECAST_BROWSER_PREF_SERVICE_HELPER_H_ |
| 8 | #define CHROMECAST_BROWSER_PREF_SERVICE_HELPER_H_ |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 9 | |
dcheng | 3c3c93d5 | 2016-04-08 05:12:31 | [diff] [blame] | 10 | #include <memory> |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 11 | |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 12 | #include "base/threading/thread_checker.h" |
Junbo Ke | 8c484e7 | 2021-12-08 02:26:22 | [diff] [blame] | 13 | #include "chromecast/base/process_types.h" |
Roland Bock | 24a7c86 | 2022-09-26 07:29:48 | [diff] [blame] | 14 | #include "components/prefs/pref_name_set.h" |
brettw | 06650868 | 2016-02-03 08:22:02 | [diff] [blame] | 15 | #include "components/prefs/pref_service.h" |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 16 | |
| 17 | class PrefRegistrySimple; |
| 18 | |
| 19 | namespace chromecast { |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 20 | namespace shell { |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 21 | |
| 22 | // It uses JsonPrefStore internally and/so the format of config file is same to |
| 23 | // that of JsonPrefStore. |
| 24 | class PrefServiceHelper { |
| 25 | public: |
| 26 | // Loads configs from config file. Returns true if successful. |
dcheng | 3c3c93d5 | 2016-04-08 05:12:31 | [diff] [blame] | 27 | static std::unique_ptr<PrefService> CreatePrefService( |
Junbo Ke | 8c484e7 | 2021-12-08 02:26:22 | [diff] [blame] | 28 | PrefRegistrySimple* registry, |
Junbo Ke | ca6dc20 | 2021-12-14 01:07:27 | [diff] [blame] | 29 | ProcessType process_type = ProcessType::kCastService); |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 30 | |
Ken MacKay | 3beca95 | 2021-04-21 18:41:02 | [diff] [blame] | 31 | // Provides names of prefs that take a large amount of storage, and are |
| 32 | // therefore stored in a different file. |
Roland Bock | 24a7c86 | 2022-09-26 07:29:48 | [diff] [blame] | 33 | static PrefNameSet LargePrefNames() __attribute__((weak)); |
Ken MacKay | 3beca95 | 2021-04-21 18:41:02 | [diff] [blame] | 34 | |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 35 | private: |
| 36 | // Registers any needed preferences for the current platform. |
| 37 | static void RegisterPlatformPrefs(PrefRegistrySimple* registry); |
| 38 | |
| 39 | // Called after the pref file has been loaded. |
| 40 | static void OnPrefsLoaded(PrefService* pref_service); |
| 41 | }; |
| 42 | |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 43 | } // namespace shell |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 44 | } // namespace chromecast |
| 45 | |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 46 | #endif // CHROMECAST_BROWSER_PREF_SERVICE_HELPER_H_ |