Luc Nguyen | 97ad3ae | 2022-05-20 19:54:43 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_LOCAL_STATE_LOCAL_STATE_UTILS_H_ |
| 6 | #define COMPONENTS_LOCAL_STATE_LOCAL_STATE_UTILS_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "base/values.h" |
| 12 | #include "components/prefs/pref_service.h" |
| 13 | |
| 14 | // Namespace for exposing the method for unit tests. |
| 15 | namespace internal { |
| 16 | |
| 17 | // Removes elements from |prefs| where the key does not match any of the |
| 18 | // prefixes in |valid_prefixes|. |
| 19 | void FilterPrefs(const std::vector<std::string>& valid_prefixes, |
| 20 | base::Value& prefs); |
| 21 | |
| 22 | } // namespace internal |
| 23 | |
| 24 | // Gets a pretty-printed string representation of the input |pref_service|. |
| 25 | // If the return value is true, the result will have been written to |
| 26 | // |json_string|. On ChromeOS, the local state file contains some information |
| 27 | // about other user accounts which we don't want to expose to other users. In |
| 28 | // that case, this will filter out the prefs to only include variations and UMA |
| 29 | // related fields, which don't contain PII. |
| 30 | bool GetPrefsAsJson(PrefService* pref_service, std::string* json_string); |
| 31 | |
| 32 | #endif // COMPONENTS_LOCAL_STATE_LOCAL_STATE_UTILS_H_ |