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 <string> | 10 #include <string> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/common/extensions/api/settings_private.h" | 14 #include "chrome/common/extensions/api/settings_private.h" |
15 | 15 |
16 class PrefService; | 16 class PrefService; |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace extensions { | 19 namespace extensions { |
20 | 20 |
21 class PrefsUtil { | 21 class PrefsUtil { |
22 | 22 |
(...skipping 13 matching lines...) Expand all Loading... |
36 explicit PrefsUtil(Profile* profile); | 36 explicit PrefsUtil(Profile* profile); |
37 virtual ~PrefsUtil(); | 37 virtual ~PrefsUtil(); |
38 | 38 |
39 // Gets the list of whitelisted pref keys -- that is, those which correspond | 39 // Gets the list of whitelisted pref keys -- that is, those which correspond |
40 // to prefs that clients of the settingsPrivate API may retrieve and | 40 // to prefs that clients of the settingsPrivate API may retrieve and |
41 // manipulate. | 41 // manipulate. |
42 const TypedPrefMap& GetWhitelistedKeys(); | 42 const TypedPrefMap& GetWhitelistedKeys(); |
43 | 43 |
44 // Gets the value of the pref with the given |name|. Returns a pointer to an | 44 // Gets the value of the pref with the given |name|. Returns a pointer to an |
45 // empty PrefObject if no pref is found for |name|. | 45 // empty PrefObject if no pref is found for |name|. |
46 virtual scoped_ptr<api::settings_private::PrefObject> GetPref( | 46 virtual std::unique_ptr<api::settings_private::PrefObject> GetPref( |
47 const std::string& name); | 47 const std::string& name); |
48 | 48 |
49 // Sets the pref with the given name and value in the proper PrefService. | 49 // Sets the pref with the given name and value in the proper PrefService. |
50 virtual SetPrefResult SetPref(const std::string& name, | 50 virtual SetPrefResult SetPref(const std::string& name, |
51 const base::Value* value); | 51 const base::Value* value); |
52 | 52 |
53 // Appends the given |value| to the list setting specified by the path in | 53 // Appends the given |value| to the list setting specified by the path in |
54 // |pref_name|. | 54 // |pref_name|. |
55 virtual bool AppendToListCrosSetting(const std::string& pref_name, | 55 virtual bool AppendToListCrosSetting(const std::string& pref_name, |
56 const base::Value& value); | 56 const base::Value& value); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // a supervisor, and |profile_| is supervised. | 89 // a supervisor, and |profile_| is supervised. |
90 bool IsPrefSupervisorControlled(const std::string& pref_name); | 90 bool IsPrefSupervisorControlled(const std::string& pref_name); |
91 | 91 |
92 // Returns whether |pref_name| corresponds to a pref that is user modifiable | 92 // Returns whether |pref_name| corresponds to a pref that is user modifiable |
93 // (i.e., not made restricted by a user or device policy). | 93 // (i.e., not made restricted by a user or device policy). |
94 bool IsPrefUserModifiable(const std::string& pref_name); | 94 bool IsPrefUserModifiable(const std::string& pref_name); |
95 | 95 |
96 api::settings_private::PrefType GetType(const std::string& name, | 96 api::settings_private::PrefType GetType(const std::string& name, |
97 base::Value::Type type); | 97 base::Value::Type type); |
98 | 98 |
99 scoped_ptr<api::settings_private::PrefObject> GetCrosSettingsPref( | 99 std::unique_ptr<api::settings_private::PrefObject> GetCrosSettingsPref( |
100 const std::string& name); | 100 const std::string& name); |
101 | 101 |
102 SetPrefResult SetCrosSettingsPref(const std::string& name, | 102 SetPrefResult SetCrosSettingsPref(const std::string& name, |
103 const base::Value* value); | 103 const base::Value* value); |
104 | 104 |
105 Profile* profile_; // weak | 105 Profile* profile_; // weak |
106 }; | 106 }; |
107 | 107 |
108 } // namespace extensions | 108 } // namespace extensions |
109 | 109 |
110 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_ | 110 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_ |
OLD | NEW |