brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.56k stars 2.28k forks source link

Use PrefService Java class for local state prefs from BravePrefServiceBridge #27632

Closed AlexeyBarabash closed 1 year ago

AlexeyBarabash commented 1 year ago

Follow-up for https://github.com/brave/brave-core/pull/16386

Edit BravePrefServiceBridge for local state based prefs is not perfect by following reasons:

The good solution would be to re-use Chromium PrefService class and auto-generated pref names, which is now done for profile-based prefs.

Uni-verse commented 1 year ago

Verified on Samsung Galaxy S21 using version:

Brave   1.48.157 Chromium: 110.0.5481.77 (Official Build) (64-bit) 
Revision    65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839}
OS  Android 13; Build/TP1A.220624.014

Test Plan: https://github.com/brave/brave-core/pull/16486#issue-1513225161

brave.p3a.enabled 1. Ensured that unchecking P3A in the onboarding flow will show below in `brave://local-state` ``` "p3a": { "enabled": false, ``` 2. Ensured that enabling P3A switch in privacy settings will display below in `brave://local-state` 3. Ensured that relaunching the browser does not reset the P3A preference in the settings ``` "p3a": { "enabled": true, ``` Step 1 | Step 2 -|- ![screenshot-1675720301647](https://user-images.githubusercontent.com/17885425/217101563-d8f9cb13-ac60-4bb4-a34e-78f68bc3519e.png) | ![screenshot-1675720273364](https://user-images.githubusercontent.com/17885425/217101588-a3db7455-73a1-49fa-ba01-46c3b61413d8.png)
brave.stats.reporting_enabled 1. Ensured that turning off `Automatically send daily usage pings` in privacy settings will display `reporting_enabled: false` follow in `brave://local-state` 2. Ensured that relaunching the browser does not reset the setting Example | Example -|- ![screenshot-1675720364276](https://user-images.githubusercontent.com/17885425/217102393-15a7525a-9c02-45e0-afa3-f856e0a44f13.png) | ![screenshot-1675720583355](https://user-images.githubusercontent.com/17885425/217102397-2b935dc6-a595-4645-a536-3a31cc94dacf.png)
safetynet.status 1. Ensured that the Brave Rewards grant should is retrieved successfully to verify it works as before. safetynet.status
brave.unstoppable_domains.resolve_method 1. Ensured that enabling Unstoppable Domains in privacy settings will display below in local-state ``` "unstoppable_domains": { "resolve_method": 3 }, ``` 2. Ensured that relaunching the browser does not reset the setting Example | Example -|- ![screenshot-1675720699223](https://user-images.githubusercontent.com/17885425/217103246-43e468f6-f6c3-4060-995e-8c271e85ee82.png) | ![screenshot-1675720713739](https://user-images.githubusercontent.com/17885425/217103247-f9877770-a90a-42c2-a5bf-093f43b3829a.png)
brave.ens.resolve_method 1. Ensured that enabling Ethereum Name Service in privacy settings will display the following under `brave://local-state` ``` "ens": { "resolve_method": 3 }, ``` 2. Ensured that relaunching the browser does not reset the setting Example | Example -|- ![screenshot-1675721366658](https://user-images.githubusercontent.com/17885425/217103876-e6d25aac-142e-4fc0-8fd4-9dfacaa5116b.png) | ![screenshot-1675723250944](https://user-images.githubusercontent.com/17885425/217103929-1f39630b-4b1b-4125-a101-320446479b19.png)
brave.sns.resolve_method 1. Enable `Solana Name Service` in `brave://flags` 2. Ensured `Solana Name Service` shows up in the privacy settings 3. Ensured enabling SNS will display the following in `brave://local-state` ``` "sns": { "resolve_method": 3 }, ``` Example | Example | Example -|-|- ![screenshot-1675720851382](https://user-images.githubusercontent.com/17885425/217104316-3e0a5cf0-adcf-4c55-8dd6-4f100ea940ae.png) | ![screenshot-1675720903837](https://user-images.githubusercontent.com/17885425/217104318-11adfa5b-3473-4fa0-bd1e-7bf3b6087252.png) | ![screenshot-1675721142038](https://user-images.githubusercontent.com/17885425/217104349-f9f1da26-e1aa-4031-bb5b-d3ae9acf7de4.png)
brave.ens.offchain_resolve_method 1. Enable ENS offchain lookup under Ethereum Name Service in the privacy settings 2. Check brave://localstate to ensure that the follow log is displayed ``` "ens": { "offchain_resolve_method": 2, ``` 3. Relaunch browser to make sure setting preference is retained Example | Example -|- ![screenshot-1675721366658](https://user-images.githubusercontent.com/17885425/217104865-e5fd7e71-742d-4d1c-82e1-2829e6d7dec0.png) | ![screenshot-1675723250944](https://user-images.githubusercontent.com/17885425/217104886-0f15270b-d868-4a19-a66f-85be1d43e4e2.png)