Port chrome://local-state to iOS
* Move local_state.html and local_state.ts from
//chrome/browser/resources/local_state to the shared
//components/local_state (note that local_state.ts is now compiled into
local_state.js by //components/resources/BUILD.gn instead of
//chrome/browser/BUILD.gn)
* Move resource IDs (IDRs) from
chrome/browser/dev_ui_browser_resources.grd to the shared
components/resources/dev_ui_components_resources.grd
* Added components/local_state/local_state_utils.{h,cc}, which has
common code between the iOS local_state_ui.mm and non-iOS
local_state_ui.cc
* Added //ios/chrome/browser/ui/webui/local_state/local_state_ui.{h,mm},
which is the same as
//chrome/browser/ui/webui/local_state/local_state_ui.{h,cc}, but adapted
for iOS. The common code between these files were moved to
local_state_utils.{h,cc}
Screenshot on iOS:
https://screenshot.googleplex.com/8FYy8XNLTb5qGfs
Still working on Linux:
https://screenshot.googleplex.com/A7VoHeh94xCnS7h
Still working on Clank:
https://screenshot.googleplex.com/76EyEqXrHP7tGNL
Bug: 1312103
Change-Id: Ic2ed2ae1bc0507ec5843a7c57187a65dff0f8659
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3584866
Reviewed-by: Colin Blundell <[email protected]>
Commit-Queue: Luc Nguyen <[email protected]>
Reviewed-by: Rohit Rao <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1005919}
diff --git a/components/local_state/local_state_utils.h b/components/local_state/local_state_utils.h
new file mode 100644
index 0000000..7ee0b48
--- /dev/null
+++ b/components/local_state/local_state_utils.h
@@ -0,0 +1,32 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_LOCAL_STATE_LOCAL_STATE_UTILS_H_
+#define COMPONENTS_LOCAL_STATE_LOCAL_STATE_UTILS_H_
+
+#include <string>
+#include <vector>
+
+#include "base/values.h"
+#include "components/prefs/pref_service.h"
+
+// Namespace for exposing the method for unit tests.
+namespace internal {
+
+// Removes elements from |prefs| where the key does not match any of the
+// prefixes in |valid_prefixes|.
+void FilterPrefs(const std::vector<std::string>& valid_prefixes,
+ base::Value& prefs);
+
+} // namespace internal
+
+// Gets a pretty-printed string representation of the input |pref_service|.
+// If the return value is true, the result will have been written to
+// |json_string|. On ChromeOS, the local state file contains some information
+// about other user accounts which we don't want to expose to other users. In
+// that case, this will filter out the prefs to only include variations and UMA
+// related fields, which don't contain PII.
+bool GetPrefsAsJson(PrefService* pref_service, std::string* json_string);
+
+#endif // COMPONENTS_LOCAL_STATE_LOCAL_STATE_UTILS_H_
\ No newline at end of file