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> |
Ken MacKay | 3beca95 | 2021-04-21 18:41:02 | [diff] [blame] | 11 | #include <set> |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 12 | #include <string> |
| 13 | |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 14 | #include "base/memory/ref_counted.h" |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 15 | #include "base/threading/thread_checker.h" |
Junbo Ke | 8c484e7 | 2021-12-08 02:26:22 | [diff] [blame] | 16 | #include "chromecast/base/process_types.h" |
brettw | 06650868 | 2016-02-03 08:22:02 | [diff] [blame] | 17 | #include "components/prefs/pref_service.h" |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 18 | |
| 19 | class PrefRegistrySimple; |
| 20 | |
| 21 | namespace chromecast { |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 22 | namespace shell { |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 23 | |
| 24 | // It uses JsonPrefStore internally and/so the format of config file is same to |
| 25 | // that of JsonPrefStore. |
| 26 | class PrefServiceHelper { |
| 27 | public: |
| 28 | // Loads configs from config file. Returns true if successful. |
dcheng | 3c3c93d5 | 2016-04-08 05:12:31 | [diff] [blame] | 29 | static std::unique_ptr<PrefService> CreatePrefService( |
Junbo Ke | 8c484e7 | 2021-12-08 02:26:22 | [diff] [blame] | 30 | PrefRegistrySimple* registry, |
Junbo Ke | ca6dc20 | 2021-12-14 01:07:27 | [diff] [blame] | 31 | ProcessType process_type = ProcessType::kCastService); |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 32 | |
Ken MacKay | 3beca95 | 2021-04-21 18:41:02 | [diff] [blame] | 33 | // Provides names of prefs that take a large amount of storage, and are |
| 34 | // therefore stored in a different file. |
| 35 | static std::set<std::string> LargePrefNames() __attribute__((weak)); |
| 36 | |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 37 | private: |
| 38 | // Registers any needed preferences for the current platform. |
| 39 | static void RegisterPlatformPrefs(PrefRegistrySimple* registry); |
| 40 | |
| 41 | // Called after the pref file has been loaded. |
| 42 | static void OnPrefsLoaded(PrefService* pref_service); |
| 43 | }; |
| 44 | |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 45 | } // namespace shell |
byungchul | ba825256 | 2014-12-05 21:01:27 | [diff] [blame] | 46 | } // namespace chromecast |
| 47 | |
derekjchow | e54ff59 | 2016-01-06 01:05:50 | [diff] [blame] | 48 | #endif // CHROMECAST_BROWSER_PREF_SERVICE_HELPER_H_ |