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_PREFS_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 24 matching lines...) Expand all Loading... |
35 using TypedPrefMap = std::map<std::string, api::settings_private::PrefType>; | 35 using TypedPrefMap = std::map<std::string, api::settings_private::PrefType>; |
36 | 36 |
37 explicit PrefsUtil(Profile* profile); | 37 explicit PrefsUtil(Profile* profile); |
38 virtual ~PrefsUtil(); | 38 virtual ~PrefsUtil(); |
39 | 39 |
40 // Gets the list of whitelisted pref keys -- that is, those which correspond | 40 // Gets the list of whitelisted pref keys -- that is, those which correspond |
41 // to prefs that clients of the settingsPrivate API may retrieve and | 41 // to prefs that clients of the settingsPrivate API may retrieve and |
42 // manipulate. | 42 // manipulate. |
43 const TypedPrefMap& GetWhitelistedKeys(); | 43 const TypedPrefMap& GetWhitelistedKeys(); |
44 | 44 |
| 45 // Returns the pref type for |pref_name| or PREF_TYPE_NONE if not in the |
| 46 // whitelist. |
| 47 api::settings_private::PrefType GetWhitelistedPrefType( |
| 48 const std::string& pref_name); |
| 49 |
45 // Gets the value of the pref with the given |name|. Returns a pointer to an | 50 // Gets the value of the pref with the given |name|. Returns a pointer to an |
46 // empty PrefObject if no pref is found for |name|. | 51 // empty PrefObject if no pref is found for |name|. |
47 virtual std::unique_ptr<api::settings_private::PrefObject> GetPref( | 52 virtual std::unique_ptr<api::settings_private::PrefObject> GetPref( |
48 const std::string& name); | 53 const std::string& name); |
49 | 54 |
50 // Sets the pref with the given name and value in the proper PrefService. | 55 // Sets the pref with the given name and value in the proper PrefService. |
51 virtual SetPrefResult SetPref(const std::string& name, | 56 virtual SetPrefResult SetPref(const std::string& name, |
52 const base::Value* value); | 57 const base::Value* value); |
53 | 58 |
54 // Appends the given |value| to the list setting specified by the path in | 59 // Appends the given |value| to the list setting specified by the path in |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 private: | 111 private: |
107 const Extension* GetExtensionControllingPref( | 112 const Extension* GetExtensionControllingPref( |
108 const api::settings_private::PrefObject& pref_object); | 113 const api::settings_private::PrefObject& pref_object); |
109 | 114 |
110 Profile* profile_; // weak | 115 Profile* profile_; // weak |
111 }; | 116 }; |
112 | 117 |
113 } // namespace extensions | 118 } // namespace extensions |
114 | 119 |
115 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_ | 120 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_ |
OLD | NEW |