From 1fbb56c05c2a98a4e0ca25314e9409bb6f260577 Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Thu, 29 Dec 2022 01:00:26 +0200 Subject: [PATCH 1/8] BraveLocalState Java class --- android/brave_java_sources.gni | 1 + .../chrome/browser/BraveLocalState.java | 35 +++++++++++++++++++ browser/android/BUILD.gn | 1 + browser/android/brave_local_state_android.cc | 23 ++++++++++++ build/android/BUILD.gn | 1 + 5 files changed, 61 insertions(+) create mode 100644 android/java/org/chromium/chrome/browser/BraveLocalState.java create mode 100644 browser/android/brave_local_state_android.cc diff --git a/android/brave_java_sources.gni b/android/brave_java_sources.gni index 782218aefab5..79f3d7baef56 100644 --- a/android/brave_java_sources.gni +++ b/android/brave_java_sources.gni @@ -24,6 +24,7 @@ brave_java_sources = [ "../../brave/android/java/org/chromium/chrome/browser/BraveHelper.java", "../../brave/android/java/org/chromium/chrome/browser/BraveIntentHandler.java", "../../brave/android/java/org/chromium/chrome/browser/BraveLaunchIntentDispatcher.java", + "../../brave/android/java/org/chromium/chrome/browser/BraveLocalState.java", "../../brave/android/java/org/chromium/chrome/browser/BraveRelaunchUtils.java", "../../brave/android/java/org/chromium/chrome/browser/BraveRewardsBalance.java", "../../brave/android/java/org/chromium/chrome/browser/BraveRewardsDonationSentActivity.java", diff --git a/android/java/org/chromium/chrome/browser/BraveLocalState.java b/android/java/org/chromium/chrome/browser/BraveLocalState.java new file mode 100644 index 000000000000..40a59f835264 --- /dev/null +++ b/android/java/org/chromium/chrome/browser/BraveLocalState.java @@ -0,0 +1,35 @@ +/* Copyright (c) 2022 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +package org.chromium.chrome.browser; + +import org.chromium.base.annotations.JNINamespace; +import org.chromium.base.annotations.NativeMethods; +import org.chromium.components.prefs.PrefService; + +/** + * Helper for retrieving a {@link PrefService} from a browser local state. + */ +@JNINamespace("chrome::android") +public class BraveLocalState { + /** Returns the {@link PrefService} associated with the browser's local state */ + public static PrefService get() { + return BraveLocalStateJni.get().getPrefService(); + } + + /** Makes local state data be written to the disk asap */ + public static void commitPendingWrite() { + BraveLocalStateJni.get().commitPendingWrite(); + } + + @NativeMethods + public interface Natives { + // this method cannot be called 'get', because of the error: + // method get() is already defined in class BraveLocalStateJni + PrefService getPrefService(); + + void commitPendingWrite(); + } +} diff --git a/browser/android/BUILD.gn b/browser/android/BUILD.gn index b81e81564206..35900c576c74 100644 --- a/browser/android/BUILD.gn +++ b/browser/android/BUILD.gn @@ -7,6 +7,7 @@ source_set("android_browser_process") { sources = [ "//brave/browser/brave_ads/android/brave_ads_native_helper.cc", "brave_feature_util.cc", + "brave_local_state_android.cc", "brave_relaunch_utils.cc", "brave_shields_content_settings.cc", "brave_shields_content_settings.h", diff --git a/browser/android/brave_local_state_android.cc b/browser/android/brave_local_state_android.cc new file mode 100644 index 000000000000..90c695b02fb9 --- /dev/null +++ b/browser/android/brave_local_state_android.cc @@ -0,0 +1,23 @@ +/* Copyright (c) 2022 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/build/android/jni_headers/BraveLocalState_jni.h" +#include "chrome/browser/browser_process.h" +#include "components/prefs/pref_service.h" + +namespace chrome { +namespace android { + +static base::android::ScopedJavaLocalRef +JNI_BraveLocalState_GetPrefService(JNIEnv* env) { + return g_browser_process->local_state()->GetJavaObject(); +} + +static void JNI_BraveLocalState_CommitPendingWrite(JNIEnv* env) { + g_browser_process->local_state()->CommitPendingWrite(); +} + +} // namespace android +} // namespace chrome diff --git a/build/android/BUILD.gn b/build/android/BUILD.gn index 8f370cb5718b..f0122dbea1d5 100644 --- a/build/android/BUILD.gn +++ b/build/android/BUILD.gn @@ -182,6 +182,7 @@ brave_xml_preprocessor("brave_java_xml_preprocess_resources") { generate_jni("jni_headers") { sources = [ "//brave/android/java/org/chromium/chrome/browser/BraveFeatureUtil.java", + "//brave/android/java/org/chromium/chrome/browser/BraveLocalState.java", "//brave/android/java/org/chromium/chrome/browser/BraveRelaunchUtils.java", "//brave/android/java/org/chromium/chrome/browser/BraveRewardsNativeWorker.java", "//brave/android/java/org/chromium/chrome/browser/BraveSyncWorker.java", From 26afec45957e0dd0ea4d8c243bb8dfc0493aa355 Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Thu, 29 Dec 2022 16:52:12 +0200 Subject: [PATCH 2/8] Move P3A prefs from BravePrefServiceBridge to BraveLocalState Java wrapper --- .../crypto_wallet/util/BalanceHelper.java | 4 +- .../firstrun/WelcomeOnboardingActivity.java | 9 ++-- .../preferences/BravePrefServiceBridge.java | 26 ---------- .../settings/BravePrivacySettings.java | 6 ++- browser/android/preferences/BUILD.gn | 1 + .../preferences/brave_pref_service_bridge.cc | 50 ------------------- 6 files changed, 14 insertions(+), 82 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/util/BalanceHelper.java b/android/java/org/chromium/chrome/browser/crypto_wallet/util/BalanceHelper.java index c3975d1b6e16..9ed6f4673c60 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/util/BalanceHelper.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/util/BalanceHelper.java @@ -19,8 +19,10 @@ import org.chromium.brave_wallet.mojom.NetworkInfo; import org.chromium.brave_wallet.mojom.ProviderError; import org.chromium.chrome.browser.BraveConfig; +import org.chromium.chrome.browser.BraveLocalState; import org.chromium.chrome.browser.crypto_wallet.activities.BraveWalletBaseActivity; import org.chromium.chrome.browser.crypto_wallet.util.AssetUtils; +import org.chromium.chrome.browser.preferences.BravePref; import org.chromium.chrome.browser.preferences.BravePrefServiceBridge; import org.chromium.mojo.bindings.Callbacks; @@ -192,7 +194,7 @@ public static void getP3ABalances(BraveWalletBaseActivity activity, NetworkInfo[ && jsonRpcService != null; boolean P3AEnabled = - BraveConfig.P3A_ENABLED && BravePrefServiceBridge.getInstance().getP3AEnabled(); + BraveConfig.P3A_ENABLED && BraveLocalState.get().getBoolean(BravePref.P3A_ENABLED); HashMap> activeAddresses = new HashMap>(); for (int coinType : Utils.P3ACoinTypes) diff --git a/android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java b/android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java index 929f81b917d8..e6101f5826ad 100644 --- a/android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java +++ b/android/java/org/chromium/chrome/browser/firstrun/WelcomeOnboardingActivity.java @@ -27,9 +27,11 @@ import org.chromium.base.Log; import org.chromium.base.ThreadUtils; import org.chromium.chrome.R; +import org.chromium.chrome.browser.BraveLocalState; import org.chromium.chrome.browser.customtabs.CustomTabActivity; import org.chromium.chrome.browser.metrics.UmaSessionStats; import org.chromium.chrome.browser.onboarding.OnboardingPrefManager; +import org.chromium.chrome.browser.preferences.BravePref; import org.chromium.chrome.browser.preferences.BravePrefServiceBridge; import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.SharedPreferencesManager; @@ -233,7 +235,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { boolean isP3aEnabled = true; try { - isP3aEnabled = BravePrefServiceBridge.getInstance().getP3AEnabled(); + isP3aEnabled = BraveLocalState.get().getBoolean(BravePref.P3A_ENABLED); } catch (Exception e) { Log.e("P3aOnboarding", e.getMessage()); } @@ -243,8 +245,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { try { - BravePrefServiceBridge.getInstance().setP3AEnabled(isChecked); - BravePrefServiceBridge.getInstance().setP3ANoticeAcknowledged(true); + BraveLocalState.get().setBoolean(BravePref.P3A_ENABLED, isChecked); + BraveLocalState.get().setBoolean(BravePref.P3A_NOTICE_ACKNOWLEDGED, true); + BraveLocalState.commitPendingWrite(); } catch (Exception e) { Log.e("P3aOnboarding", e.getMessage()); } diff --git a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java index 36717524e43e..f9407dd87cf1 100644 --- a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java +++ b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java @@ -186,14 +186,6 @@ public void setReferralDownloadId(String downloadId) { BravePrefServiceBridgeJni.get().setReferralDownloadId(downloadId); } - public void setP3AEnabled(boolean value) { - BravePrefServiceBridgeJni.get().setP3AEnabled(value); - } - - public boolean getP3AEnabled() { - return BravePrefServiceBridgeJni.get().getP3AEnabled(); - } - public void setStatsReportingEnabled(boolean value) { BravePrefServiceBridgeJni.get().setStatsReportingEnabled(value); } @@ -202,18 +194,6 @@ public boolean getStatsReportingEnabled() { return BravePrefServiceBridgeJni.get().getStatsReportingEnabled(); } - public boolean hasPathP3AEnabled() { - return BravePrefServiceBridgeJni.get().hasPathP3AEnabled(); - } - - public void setP3ANoticeAcknowledged(boolean value) { - BravePrefServiceBridgeJni.get().setP3ANoticeAcknowledged(value); - } - - public boolean getP3ANoticeAcknowledged() { - return BravePrefServiceBridgeJni.get().getP3ANoticeAcknowledged(); - } - public void setUnstoppableDomainsResolveMethod(int method) { BravePrefServiceBridgeJni.get().setUnstoppableDomainsResolveMethod(method); } @@ -321,12 +301,6 @@ interface Natives { void setReferralPromoCode(String promoCode); void setReferralDownloadId(String downloadId); - void setP3AEnabled(boolean value); - boolean getP3AEnabled(); - boolean hasPathP3AEnabled(); - void setP3ANoticeAcknowledged(boolean value); - boolean getP3ANoticeAcknowledged(); - void setStatsReportingEnabled(boolean value); boolean getStatsReportingEnabled(); diff --git a/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java b/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java index 1a62c1304c7e..0afd9d57d333 100644 --- a/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java +++ b/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java @@ -19,6 +19,7 @@ import org.chromium.brave_shields.mojom.CookieListOptInPageAndroidHandler; import org.chromium.chrome.R; import org.chromium.chrome.browser.BraveConfig; +import org.chromium.chrome.browser.BraveLocalState; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.metrics.UmaSessionStats; import org.chromium.chrome.browser.preferences.BravePref; @@ -428,7 +429,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } else if (PREF_CLOSE_TABS_ON_EXIT.equals(key)) { sharedPreferencesEditor.putBoolean(PREF_CLOSE_TABS_ON_EXIT, (boolean) newValue); } else if (PREF_SEND_P3A.equals(key)) { - BravePrefServiceBridge.getInstance().setP3AEnabled((boolean) newValue); + BraveLocalState.get().setBoolean(BravePref.P3A_ENABLED, (boolean) newValue); + BraveLocalState.commitPendingWrite(); } else if (PREF_SEND_CRASH_REPORTS.equals(key)) { UmaSessionStats.changeMetricsReportingConsent((boolean) newValue); } else if (PREF_BRAVE_STATS_USAGE_PING.equals(key)) { @@ -565,7 +567,7 @@ private void updateBravePreferences() { getActivity().getResources().getString(R.string.send_p3a_analytics_summary)); if (BraveConfig.P3A_ENABLED) { - mSendP3A.setChecked(BravePrefServiceBridge.getInstance().getP3AEnabled()); + mSendP3A.setChecked(BraveLocalState.get().getBoolean(BravePref.P3A_ENABLED)); } else { getPreferenceScreen().removePreference(mSendP3A); } diff --git a/browser/android/preferences/BUILD.gn b/browser/android/preferences/BUILD.gn index aa9e87cb564a..efc9fab0f4c9 100644 --- a/browser/android/preferences/BUILD.gn +++ b/browser/android/preferences/BUILD.gn @@ -44,6 +44,7 @@ java_cpp_strings("java_pref_names_srcjar") { "//brave/components/debounce/common/pref_names.cc", "//brave/components/ntp_background_images/common/pref_names.cc", "//brave/components/omnibox/browser/brave_omnibox_prefs.cc", + "//brave/components/p3a/pref_names.cc", "//components/translate/core/browser/translate_pref_names.cc", ] diff --git a/browser/android/preferences/brave_pref_service_bridge.cc b/browser/android/preferences/brave_pref_service_bridge.cc index 715beef146c5..6e7556d1f369 100644 --- a/browser/android/preferences/brave_pref_service_bridge.cc +++ b/browser/android/preferences/brave_pref_service_bridge.cc @@ -18,7 +18,6 @@ #include "brave/components/de_amp/common/pref_names.h" #include "brave/components/decentralized_dns/core/pref_names.h" #include "brave/components/ipfs/buildflags/buildflags.h" -#include "brave/components/p3a/buildflags.h" #include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/cookie_settings_factory.h" @@ -33,10 +32,6 @@ #include "third_party/blink/public/common/peerconnection/webrtc_ip_handling_policy.h" #include "url/gurl.h" -#if BUILDFLAG(BRAVE_P3A_ENABLED) -#include "brave/components/p3a/pref_names.h" -#endif - #if BUILDFLAG(ENABLE_IPFS) #include "brave/components/ipfs/ipfs_constants.h" #include "brave/components/ipfs/pref_names.h" @@ -422,51 +417,6 @@ void JNI_BravePrefServiceBridge_SetWebrtcPolicy(JNIEnv* env, jint policy) { GetWebRTCIPHandlingPreference((WebRTCIPHandlingPolicy)policy)); } -#if BUILDFLAG(BRAVE_P3A_ENABLED) -void JNI_BravePrefServiceBridge_SetP3AEnabled(JNIEnv* env, jboolean value) { - /* Saving pref value to the disk as soon as the pref value - * is set to avoid delay in pref value update.*/ - g_browser_process->local_state()->SetBoolean(brave::kP3AEnabled, value); - g_browser_process->local_state()->CommitPendingWrite(); -} - -static jboolean JNI_BravePrefServiceBridge_GetP3AEnabled(JNIEnv* env) { - return g_browser_process->local_state()->GetBoolean(brave::kP3AEnabled); -} - -jboolean JNI_BravePrefServiceBridge_HasPathP3AEnabled(JNIEnv* env) { - return g_browser_process->local_state()->HasPrefPath(brave::kP3AEnabled); -} - -void JNI_BravePrefServiceBridge_SetP3ANoticeAcknowledged(JNIEnv* env, - jboolean value) { - return g_browser_process->local_state()->SetBoolean( - brave::kP3ANoticeAcknowledged, value); -} - -jboolean JNI_BravePrefServiceBridge_GetP3ANoticeAcknowledged(JNIEnv* env) { - return g_browser_process->local_state()->GetBoolean( - brave::kP3ANoticeAcknowledged); -} - -#else - -void JNI_BravePrefServiceBridge_SetP3AEnabled(JNIEnv* env, jboolean value) {} - -static jboolean JNI_BravePrefServiceBridge_GetP3AEnabled(JNIEnv* env) { - return false; -} - -jboolean JNI_BravePrefServiceBridge_HasPathP3AEnabled(JNIEnv* env) {} - -void JNI_BravePrefServiceBridge_SetP3ANoticeAcknowledged(JNIEnv* env, - jboolean value) {} - -jboolean JNI_BravePrefServiceBridge_GetP3ANoticeAcknowledged(JNIEnv* env) { - return false; -} -#endif // BUILDFLAG(BRAVE_P3A_ENABLED) - void JNI_BravePrefServiceBridge_SetStatsReportingEnabled(JNIEnv* env, jboolean value) { g_browser_process->local_state()->SetBoolean(kStatsReportingEnabled, value); From 11635472da3f48eec973c7f407bcbf549fc90056 Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Thu, 29 Dec 2022 20:35:48 +0200 Subject: [PATCH 3/8] Fix presubmit errors --- browser/android/BUILD.gn | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/browser/android/BUILD.gn b/browser/android/BUILD.gn index 35900c576c74..fbcf351e4f6d 100644 --- a/browser/android/BUILD.gn +++ b/browser/android/BUILD.gn @@ -1,3 +1,8 @@ +# Copyright (c) 2022 The Brave Authors. All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at https://mozilla.org/MPL/2.0/. + import("//brave/build/config.gni") import("//build/config/android/rules.gni") From 1e7774c17960c7a33d76b8449371f1329257ab0e Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Tue, 3 Jan 2023 17:25:27 +0200 Subject: [PATCH 4/8] Move stats reporting pref from BravePrefServiceBridge to BraveLocalState Java wrapper --- .../browser/preferences/BravePrefServiceBridge.java | 11 ----------- .../privacy/settings/BravePrivacySettings.java | 4 ++-- .../android/preferences/brave_pref_service_bridge.cc | 9 --------- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java index f9407dd87cf1..69a9639d7804 100644 --- a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java +++ b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java @@ -186,14 +186,6 @@ public void setReferralDownloadId(String downloadId) { BravePrefServiceBridgeJni.get().setReferralDownloadId(downloadId); } - public void setStatsReportingEnabled(boolean value) { - BravePrefServiceBridgeJni.get().setStatsReportingEnabled(value); - } - - public boolean getStatsReportingEnabled() { - return BravePrefServiceBridgeJni.get().getStatsReportingEnabled(); - } - public void setUnstoppableDomainsResolveMethod(int method) { BravePrefServiceBridgeJni.get().setUnstoppableDomainsResolveMethod(method); } @@ -301,9 +293,6 @@ interface Natives { void setReferralPromoCode(String promoCode); void setReferralDownloadId(String downloadId); - void setStatsReportingEnabled(boolean value); - boolean getStatsReportingEnabled(); - void setUnstoppableDomainsResolveMethod(int method); int getUnstoppableDomainsResolveMethod(); void setENSResolveMethod(int method); diff --git a/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java b/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java index 0afd9d57d333..8b17fd1307aa 100644 --- a/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java +++ b/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java @@ -434,7 +434,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } else if (PREF_SEND_CRASH_REPORTS.equals(key)) { UmaSessionStats.changeMetricsReportingConsent((boolean) newValue); } else if (PREF_BRAVE_STATS_USAGE_PING.equals(key)) { - BravePrefServiceBridge.getInstance().setStatsReportingEnabled((boolean) newValue); + BraveLocalState.get().setBoolean(BravePref.STATS_REPORTING_ENABLED, (boolean) newValue); } else if (PREF_SEARCH_SUGGESTIONS.equals(key)) { mPrefServiceBridge.setBoolean(Pref.SEARCH_SUGGEST_ENABLED, (boolean) newValue); } else if (PREF_SHOW_AUTOCOMPLETE_IN_ADDRESS_BAR.equals(key)) { @@ -575,7 +575,7 @@ private void updateBravePreferences() { mSendCrashReports.setChecked(mPrivacyPrefManager.isUsageAndCrashReportingPermittedByUser()); mBraveStatsUsagePing.setChecked( - BravePrefServiceBridge.getInstance().getStatsReportingEnabled()); + BraveLocalState.get().getBoolean(BravePref.STATS_REPORTING_ENABLED)); mWebrtcPolicy.setSummary( webrtcPolicyToString(BravePrefServiceBridge.getInstance().getWebrtcPolicy())); diff --git a/browser/android/preferences/brave_pref_service_bridge.cc b/browser/android/preferences/brave_pref_service_bridge.cc index 6e7556d1f369..a893b99a4545 100644 --- a/browser/android/preferences/brave_pref_service_bridge.cc +++ b/browser/android/preferences/brave_pref_service_bridge.cc @@ -417,15 +417,6 @@ void JNI_BravePrefServiceBridge_SetWebrtcPolicy(JNIEnv* env, jint policy) { GetWebRTCIPHandlingPreference((WebRTCIPHandlingPolicy)policy)); } -void JNI_BravePrefServiceBridge_SetStatsReportingEnabled(JNIEnv* env, - jboolean value) { - g_browser_process->local_state()->SetBoolean(kStatsReportingEnabled, value); -} - -jboolean JNI_BravePrefServiceBridge_GetStatsReportingEnabled(JNIEnv* env) { - return g_browser_process->local_state()->GetBoolean(kStatsReportingEnabled); -} - void JNI_BravePrefServiceBridge_SetUnstoppableDomainsResolveMethod( JNIEnv* env, jint method) { From 0d73687b060134feb48ddf5433f1a9065e46abad Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Tue, 3 Jan 2023 19:11:25 +0200 Subject: [PATCH 5/8] Move safetynet status pref from BravePrefServiceBridge to BraveLocalState Java wrapper --- .../browser/preferences/BravePrefServiceBridge.java | 6 ------ .../preferences/brave_pref_service_bridge.cc | 7 ------- .../chrome/browser/util/SafetyNetCheck.java | 13 +++++++------ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java index 69a9639d7804..fedbf696a538 100644 --- a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java +++ b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java @@ -142,10 +142,6 @@ public boolean getSafetynetCheckFailed() { return BravePrefServiceBridgeJni.get().getSafetynetCheckFailed(); } - public void setSafetynetStatus(String status) { - BravePrefServiceBridgeJni.get().setSafetynetStatus(status); - } - public void resetPromotionLastFetchStamp() { BravePrefServiceBridgeJni.get().resetPromotionLastFetchStamp(); } @@ -282,8 +278,6 @@ interface Natives { void setSafetynetCheckFailed(boolean value); boolean getSafetynetCheckFailed(); - void setSafetynetStatus(String status); - void resetPromotionLastFetchStamp(); boolean getBooleanForContentSetting(int content_type); diff --git a/browser/android/preferences/brave_pref_service_bridge.cc b/browser/android/preferences/brave_pref_service_bridge.cc index a893b99a4545..6dd9fae53217 100644 --- a/browser/android/preferences/brave_pref_service_bridge.cc +++ b/browser/android/preferences/brave_pref_service_bridge.cc @@ -345,13 +345,6 @@ jboolean JNI_BravePrefServiceBridge_GetSafetynetCheckFailed(JNIEnv* env) { return GetOriginalProfile()->GetPrefs()->GetBoolean(kSafetynetCheckFailed); } -void JNI_BravePrefServiceBridge_SetSafetynetStatus( - JNIEnv* env, - const JavaParamRef& status) { - g_browser_process->local_state()->SetString( - kSafetynetStatus, ConvertJavaStringToUTF8(env, status)); -} - void JNI_BravePrefServiceBridge_ResetPromotionLastFetchStamp(JNIEnv* env) { GetOriginalProfile()->GetPrefs()->SetUint64( brave_rewards::prefs::kPromotionLastFetchStamp, 0); diff --git a/components/safetynet/java/org/chromium/chrome/browser/util/SafetyNetCheck.java b/components/safetynet/java/org/chromium/chrome/browser/util/SafetyNetCheck.java index 6723a8dd13cd..99b59224a7e1 100644 --- a/components/safetynet/java/org/chromium/chrome/browser/util/SafetyNetCheck.java +++ b/components/safetynet/java/org/chromium/chrome/browser/util/SafetyNetCheck.java @@ -29,8 +29,9 @@ import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.NativeMethods; +import org.chromium.chrome.browser.BraveLocalState; import org.chromium.chrome.browser.BraveRewardsHelper; -import org.chromium.chrome.browser.preferences.BravePrefServiceBridge; +import org.chromium.chrome.browser.preferences.BravePref; import java.security.SecureRandom; import java.util.Calendar; @@ -171,16 +172,16 @@ private void clientAttestationResult( Log.e(TAG, "Unable to perform SafetyNet attestation: " + e); } attestationPassed = ctsProfileMatch && basicIntegrity; - BravePrefServiceBridge.getInstance().setSafetynetStatus(attestationPassed - ? SAFETYNET_STATUS_VERIFIED_PASSED - : SAFETYNET_STATUS_VERIFIED_NOT_PASSED); + BraveLocalState.get().setString(BravePref.SAFETYNET_STATUS, + attestationPassed ? SAFETYNET_STATUS_VERIFIED_PASSED + : SAFETYNET_STATUS_VERIFIED_NOT_PASSED); if (mSafetyNetCheckCallback != null) { mSafetyNetCheckCallback.onResult(attestationPassed); } } } else { - BravePrefServiceBridge.getInstance().setSafetynetStatus( - SAFETYNET_STATUS_NOT_VERIFIED); + BraveLocalState.get().setString( + BravePref.SAFETYNET_STATUS, SAFETYNET_STATUS_NOT_VERIFIED); } } if (mNativeSafetyNetCheck == 0) return; From 121f8d576b2e1545defb962e2d1309f639b9ae3f Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Tue, 3 Jan 2023 20:06:23 +0200 Subject: [PATCH 6/8] Removed unused Java/JNI methods: - BravePrefServiceBridge.setReferralAndroidFirstRunTimestamp; - BravePrefServiceBridge.setReferralCheckedForPromoCodeFile; - BravePrefServiceBridge.setReferralInitialization; - BravePrefServiceBridge.setReferralPromoCode; - BravePrefServiceBridge.setReferralDownloadId. --- .../preferences/BravePrefServiceBridge.java | 26 -------------- .../preferences/brave_pref_service_bridge.cc | 34 ------------------- 2 files changed, 60 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java index fedbf696a538..f14015401a1c 100644 --- a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java +++ b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java @@ -162,26 +162,6 @@ public boolean GetBooleanForContentSetting(int content_type) { return BravePrefServiceBridgeJni.get().getBooleanForContentSetting(content_type); } - public void setReferralAndroidFirstRunTimestamp(long time) { - BravePrefServiceBridgeJni.get().setReferralAndroidFirstRunTimestamp(time); - } - - public void setReferralCheckedForPromoCodeFile(boolean value) { - BravePrefServiceBridgeJni.get().setReferralCheckedForPromoCodeFile(value); - } - - public void setReferralInitialization(boolean value) { - BravePrefServiceBridgeJni.get().setReferralInitialization(value); - } - - public void setReferralPromoCode(String promoCode) { - BravePrefServiceBridgeJni.get().setReferralPromoCode(promoCode); - } - - public void setReferralDownloadId(String downloadId) { - BravePrefServiceBridgeJni.get().setReferralDownloadId(downloadId); - } - public void setUnstoppableDomainsResolveMethod(int method) { BravePrefServiceBridgeJni.get().setUnstoppableDomainsResolveMethod(method); } @@ -281,12 +261,6 @@ interface Natives { void resetPromotionLastFetchStamp(); boolean getBooleanForContentSetting(int content_type); - void setReferralAndroidFirstRunTimestamp(long time); - void setReferralCheckedForPromoCodeFile(boolean value); - void setReferralInitialization(boolean value); - void setReferralPromoCode(String promoCode); - void setReferralDownloadId(String downloadId); - void setUnstoppableDomainsResolveMethod(int method); int getUnstoppableDomainsResolveMethod(); void setENSResolveMethod(int method); diff --git a/browser/android/preferences/brave_pref_service_bridge.cc b/browser/android/preferences/brave_pref_service_bridge.cc index 6dd9fae53217..0dbf17ae58ea 100644 --- a/browser/android/preferences/brave_pref_service_bridge.cc +++ b/browser/android/preferences/brave_pref_service_bridge.cc @@ -364,40 +364,6 @@ jboolean JNI_BravePrefServiceBridge_GetBooleanForContentSetting(JNIEnv* env, } } -void JNI_BravePrefServiceBridge_SetReferralAndroidFirstRunTimestamp( - JNIEnv* env, - jlong time) { - return g_browser_process->local_state()->SetTime( - kReferralAndroidFirstRunTimestamp, base::Time::FromJavaTime(time)); -} - -void JNI_BravePrefServiceBridge_SetReferralCheckedForPromoCodeFile( - JNIEnv* env, - jboolean value) { - return g_browser_process->local_state()->SetBoolean( - kReferralCheckedForPromoCodeFile, value); -} - -void JNI_BravePrefServiceBridge_SetReferralInitialization(JNIEnv* env, - jboolean value) { - return g_browser_process->local_state()->SetBoolean(kReferralInitialization, - value); -} - -void JNI_BravePrefServiceBridge_SetReferralPromoCode( - JNIEnv* env, - const JavaParamRef& promoCode) { - return g_browser_process->local_state()->SetString( - kReferralPromoCode, ConvertJavaStringToUTF8(env, promoCode)); -} - -void JNI_BravePrefServiceBridge_SetReferralDownloadId( - JNIEnv* env, - const JavaParamRef& downloadId) { - return g_browser_process->local_state()->SetString( - kReferralDownloadID, ConvertJavaStringToUTF8(env, downloadId)); -} - jint JNI_BravePrefServiceBridge_GetWebrtcPolicy(JNIEnv* env) { return static_cast( GetWebRTCIPHandlingPolicy(GetOriginalProfile()->GetPrefs()->GetString( From 0b343380305da14346c899e58a0bf48637cfec00 Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Wed, 4 Jan 2023 00:00:14 +0200 Subject: [PATCH 7/8] Move UD/ENS/SNS prefs from BravePrefServiceBridge to BraveLocalState Java wrapper --- .../activities/BuySendSwapActivity.java | 7 +-- .../settings/ENSSettingsFragment.java | 13 +++--- .../settings/SnsSettingsFragment.java | 7 +-- .../UnstoppableDomainsSettingsFragment.java | 8 ++-- .../preferences/BravePrefServiceBridge.java | 41 ----------------- browser/android/preferences/BUILD.gn | 1 + .../preferences/brave_pref_service_bridge.cc | 44 ------------------- components/decentralized_dns/core/BUILD.gn | 1 + .../decentralized_dns/core/pref_names.cc | 19 ++++++++ .../decentralized_dns/core/pref_names.h | 10 ++--- 10 files changed, 45 insertions(+), 106 deletions(-) create mode 100644 components/decentralized_dns/core/pref_names.cc diff --git a/android/java/org/chromium/chrome/browser/crypto_wallet/activities/BuySendSwapActivity.java b/android/java/org/chromium/chrome/browser/crypto_wallet/activities/BuySendSwapActivity.java index 285b91caee14..8890d9396c6b 100644 --- a/android/java/org/chromium/chrome/browser/crypto_wallet/activities/BuySendSwapActivity.java +++ b/android/java/org/chromium/chrome/browser/crypto_wallet/activities/BuySendSwapActivity.java @@ -69,6 +69,7 @@ import org.chromium.brave_wallet.mojom.TxData1559; import org.chromium.brave_wallet.mojom.TxDataUnion; import org.chromium.chrome.R; +import org.chromium.chrome.browser.BraveLocalState; import org.chromium.chrome.browser.app.BraveActivity; import org.chromium.chrome.browser.app.domain.SendModel; import org.chromium.chrome.browser.app.domain.WalletModel; @@ -88,7 +89,7 @@ import org.chromium.chrome.browser.crypto_wallet.util.WalletUtils; import org.chromium.chrome.browser.decentralized_dns.EnsOffchainResolveMethod; import org.chromium.chrome.browser.flags.ChromeFeatureList; -import org.chromium.chrome.browser.preferences.BravePrefServiceBridge; +import org.chromium.chrome.browser.preferences.BravePref; import org.chromium.chrome.browser.qrreader.BarcodeTracker; import org.chromium.chrome.browser.qrreader.BarcodeTrackerFactory; import org.chromium.chrome.browser.qrreader.CameraSource; @@ -1220,8 +1221,8 @@ private void onResolveWalletAddressDone( Button mBtnEnableEnsOffchainLookup = findViewById(R.id.btn_enable_ens_offchain_lookup); mBtnEnableEnsOffchainLookup.setOnClickListener(v -> { - BravePrefServiceBridge.getInstance().setENSOffchainResolveMethod( - EnsOffchainResolveMethod.ENABLED); + BraveLocalState.get().setInteger( + BravePref.ENS_OFFCHAIN_RESOLVE_METHOD, EnsOffchainResolveMethod.ENABLED); mEnsOffchainLookupSection.setVisibility(View.GONE); maybeResolveWalletAddress(); }); diff --git a/android/java/org/chromium/chrome/browser/decentralized_dns/settings/ENSSettingsFragment.java b/android/java/org/chromium/chrome/browser/decentralized_dns/settings/ENSSettingsFragment.java index 1d61dc02bf36..cc18b8b2ea9e 100644 --- a/android/java/org/chromium/chrome/browser/decentralized_dns/settings/ENSSettingsFragment.java +++ b/android/java/org/chromium/chrome/browser/decentralized_dns/settings/ENSSettingsFragment.java @@ -11,7 +11,8 @@ import androidx.preference.PreferenceFragmentCompat; import org.chromium.chrome.R; -import org.chromium.chrome.browser.preferences.BravePrefServiceBridge; +import org.chromium.chrome.browser.BraveLocalState; +import org.chromium.chrome.browser.preferences.BravePref; import org.chromium.components.browser_ui.settings.SettingsUtils; public class ENSSettingsFragment extends PreferenceFragmentCompat { @@ -27,10 +28,10 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, String root (RadioButtonGroupDDnsResolveMethodPreference) findPreference( PREF_ENS_RESOLVE_METHOD); radioButtonGroupDDnsResolveMethodPreference.initialize( - BravePrefServiceBridge.getInstance().getENSResolveMethod()); + BraveLocalState.get().getInteger(BravePref.ENS_RESOLVE_METHOD)); radioButtonGroupDDnsResolveMethodPreference.setOnPreferenceChangeListener( (preference, newValue) -> { - BravePrefServiceBridge.getInstance().setENSResolveMethod((int) newValue); + BraveLocalState.get().setInteger(BravePref.ENS_RESOLVE_METHOD, (int) newValue); return true; }); @@ -39,11 +40,11 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, String root (RadioButtonGroupEnsOffchainResolveMethodPreference) findPreference( PREF_ENS_OFFCHAIN_LOOKUP_METHOD); radioButtonGroupEnsOffchainResolveMethodPreference.initialize( - BravePrefServiceBridge.getInstance().getENSOffchainResolveMethod()); + BraveLocalState.get().getInteger(BravePref.ENS_OFFCHAIN_RESOLVE_METHOD)); radioButtonGroupEnsOffchainResolveMethodPreference.setOnPreferenceChangeListener( (preference, newValue) -> { - BravePrefServiceBridge.getInstance().setENSOffchainResolveMethod( - (int) newValue); + BraveLocalState.get().setInteger( + BravePref.ENS_OFFCHAIN_RESOLVE_METHOD, (int) newValue); return true; }); } diff --git a/android/java/org/chromium/chrome/browser/decentralized_dns/settings/SnsSettingsFragment.java b/android/java/org/chromium/chrome/browser/decentralized_dns/settings/SnsSettingsFragment.java index da42b39d866d..4d7a651b40f5 100644 --- a/android/java/org/chromium/chrome/browser/decentralized_dns/settings/SnsSettingsFragment.java +++ b/android/java/org/chromium/chrome/browser/decentralized_dns/settings/SnsSettingsFragment.java @@ -11,7 +11,8 @@ import androidx.preference.PreferenceFragmentCompat; import org.chromium.chrome.R; -import org.chromium.chrome.browser.preferences.BravePrefServiceBridge; +import org.chromium.chrome.browser.BraveLocalState; +import org.chromium.chrome.browser.preferences.BravePref; import org.chromium.components.browser_ui.settings.SettingsUtils; public class SnsSettingsFragment extends PreferenceFragmentCompat { @@ -27,12 +28,12 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, String root PREF_SNS_RESOLVE_METHOD); radioButtonGroupDDnsResolveMethodPreference.initialize( - BravePrefServiceBridge.getInstance().getSnsResolveMethod()); + BraveLocalState.get().getInteger(BravePref.SNS_RESOLVE_METHOD)); radioButtonGroupDDnsResolveMethodPreference.setOnPreferenceChangeListener( (preference, newValue) -> { int method = (int) newValue; - BravePrefServiceBridge.getInstance().setSnsResolveMethod(method); + BraveLocalState.get().setInteger(BravePref.SNS_RESOLVE_METHOD, method); return true; }); } diff --git a/android/java/org/chromium/chrome/browser/decentralized_dns/settings/UnstoppableDomainsSettingsFragment.java b/android/java/org/chromium/chrome/browser/decentralized_dns/settings/UnstoppableDomainsSettingsFragment.java index d8f36f82ee8e..35f6c52b86db 100644 --- a/android/java/org/chromium/chrome/browser/decentralized_dns/settings/UnstoppableDomainsSettingsFragment.java +++ b/android/java/org/chromium/chrome/browser/decentralized_dns/settings/UnstoppableDomainsSettingsFragment.java @@ -11,7 +11,8 @@ import androidx.preference.PreferenceFragmentCompat; import org.chromium.chrome.R; -import org.chromium.chrome.browser.preferences.BravePrefServiceBridge; +import org.chromium.chrome.browser.BraveLocalState; +import org.chromium.chrome.browser.preferences.BravePref; import org.chromium.components.browser_ui.settings.SettingsUtils; public class UnstoppableDomainsSettingsFragment extends PreferenceFragmentCompat { @@ -28,12 +29,13 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, String root PREF_UNSTOPPABLE_DOMAINS_RESOLVE_METHOD); radioButtonGroupDDnsResolveMethodPreference.initialize( - BravePrefServiceBridge.getInstance().getUnstoppableDomainsResolveMethod()); + BraveLocalState.get().getInteger(BravePref.UNSTOPPABLE_DOMAINS_RESOLVE_METHOD)); radioButtonGroupDDnsResolveMethodPreference.setOnPreferenceChangeListener( (preference, newValue) -> { int method = (int) newValue; - BravePrefServiceBridge.getInstance().setUnstoppableDomainsResolveMethod(method); + BraveLocalState.get().setInteger( + BravePref.UNSTOPPABLE_DOMAINS_RESOLVE_METHOD, method); return true; }); } diff --git a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java index f14015401a1c..3f2df53b3112 100644 --- a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java +++ b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java @@ -162,38 +162,6 @@ public boolean GetBooleanForContentSetting(int content_type) { return BravePrefServiceBridgeJni.get().getBooleanForContentSetting(content_type); } - public void setUnstoppableDomainsResolveMethod(int method) { - BravePrefServiceBridgeJni.get().setUnstoppableDomainsResolveMethod(method); - } - - public int getUnstoppableDomainsResolveMethod() { - return BravePrefServiceBridgeJni.get().getUnstoppableDomainsResolveMethod(); - } - - public void setENSResolveMethod(int method) { - BravePrefServiceBridgeJni.get().setENSResolveMethod(method); - } - - public int getENSResolveMethod() { - return BravePrefServiceBridgeJni.get().getENSResolveMethod(); - } - - public void setENSOffchainResolveMethod(int method) { - BravePrefServiceBridgeJni.get().setENSOffchainResolveMethod(method); - } - - public int getENSOffchainResolveMethod() { - return BravePrefServiceBridgeJni.get().getENSOffchainResolveMethod(); - } - - public void setSnsResolveMethod(int method) { - BravePrefServiceBridgeJni.get().setSnsResolveMethod(method); - } - - public int getSnsResolveMethod() { - return BravePrefServiceBridgeJni.get().getSnsResolveMethod(); - } - public void setWebrtcPolicy(int policy) { BravePrefServiceBridgeJni.get().setWebrtcPolicy(policy); } @@ -261,15 +229,6 @@ interface Natives { void resetPromotionLastFetchStamp(); boolean getBooleanForContentSetting(int content_type); - void setUnstoppableDomainsResolveMethod(int method); - int getUnstoppableDomainsResolveMethod(); - void setENSResolveMethod(int method); - int getENSResolveMethod(); - void setENSOffchainResolveMethod(int method); - int getENSOffchainResolveMethod(); - void setSnsResolveMethod(int method); - int getSnsResolveMethod(); - void setWebrtcPolicy(int policy); int getWebrtcPolicy(); diff --git a/browser/android/preferences/BUILD.gn b/browser/android/preferences/BUILD.gn index efc9fab0f4c9..049582853580 100644 --- a/browser/android/preferences/BUILD.gn +++ b/browser/android/preferences/BUILD.gn @@ -42,6 +42,7 @@ java_cpp_strings("java_pref_names_srcjar") { "//brave/components/constants/pref_names.cc", "//brave/components/de_amp/common/pref_names.cc", "//brave/components/debounce/common/pref_names.cc", + "//brave/components/decentralized_dns/core/pref_names.cc", "//brave/components/ntp_background_images/common/pref_names.cc", "//brave/components/omnibox/browser/brave_omnibox_prefs.cc", "//brave/components/p3a/pref_names.cc", diff --git a/browser/android/preferences/brave_pref_service_bridge.cc b/browser/android/preferences/brave_pref_service_bridge.cc index 0dbf17ae58ea..b892eefac4c7 100644 --- a/browser/android/preferences/brave_pref_service_bridge.cc +++ b/browser/android/preferences/brave_pref_service_bridge.cc @@ -376,50 +376,6 @@ void JNI_BravePrefServiceBridge_SetWebrtcPolicy(JNIEnv* env, jint policy) { GetWebRTCIPHandlingPreference((WebRTCIPHandlingPolicy)policy)); } -void JNI_BravePrefServiceBridge_SetUnstoppableDomainsResolveMethod( - JNIEnv* env, - jint method) { - g_browser_process->local_state()->SetInteger( - decentralized_dns::kUnstoppableDomainsResolveMethod, method); -} - -jint JNI_BravePrefServiceBridge_GetUnstoppableDomainsResolveMethod( - JNIEnv* env) { - return g_browser_process->local_state()->GetInteger( - decentralized_dns::kUnstoppableDomainsResolveMethod); -} - -void JNI_BravePrefServiceBridge_SetENSResolveMethod(JNIEnv* env, jint method) { - g_browser_process->local_state()->SetInteger( - decentralized_dns::kENSResolveMethod, method); -} - -jint JNI_BravePrefServiceBridge_GetENSResolveMethod(JNIEnv* env) { - return g_browser_process->local_state()->GetInteger( - decentralized_dns::kENSResolveMethod); -} - -void JNI_BravePrefServiceBridge_SetENSOffchainResolveMethod(JNIEnv* env, - jint method) { - g_browser_process->local_state()->SetInteger( - decentralized_dns::kEnsOffchainResolveMethod, method); -} - -jint JNI_BravePrefServiceBridge_GetENSOffchainResolveMethod(JNIEnv* env) { - return g_browser_process->local_state()->GetInteger( - decentralized_dns::kEnsOffchainResolveMethod); -} - -void JNI_BravePrefServiceBridge_SetSnsResolveMethod(JNIEnv* env, jint method) { - g_browser_process->local_state()->SetInteger( - decentralized_dns::kSnsResolveMethod, method); -} - -jint JNI_BravePrefServiceBridge_GetSnsResolveMethod(JNIEnv* env) { - return g_browser_process->local_state()->GetInteger( - decentralized_dns::kSnsResolveMethod); -} - void JNI_BravePrefServiceBridge_SetNewsOptIn(JNIEnv* env, jboolean value) { GetOriginalProfile()->GetPrefs()->SetBoolean( brave_news::prefs::kBraveTodayOptedIn, value); diff --git a/components/decentralized_dns/core/BUILD.gn b/components/decentralized_dns/core/BUILD.gn index 450cb4ed6e5e..b5ff1b73e2f2 100644 --- a/components/decentralized_dns/core/BUILD.gn +++ b/components/decentralized_dns/core/BUILD.gn @@ -6,6 +6,7 @@ static_library("core") { sources = [ "constants.h", + "pref_names.cc", "pref_names.h", "utils.cc", "utils.h", diff --git a/components/decentralized_dns/core/pref_names.cc b/components/decentralized_dns/core/pref_names.cc new file mode 100644 index 000000000000..ed80f53b66ea --- /dev/null +++ b/components/decentralized_dns/core/pref_names.cc @@ -0,0 +1,19 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/decentralized_dns/core/pref_names.h" + +namespace decentralized_dns { + +const char kUnstoppableDomainsResolveMethod[] = + "brave.unstoppable_domains.resolve_method"; + +const char kENSResolveMethod[] = "brave.ens.resolve_method"; + +const char kEnsOffchainResolveMethod[] = "brave.ens.offchain_resolve_method"; + +const char kSnsResolveMethod[] = "brave.sns.resolve_method"; + +} // namespace decentralized_dns diff --git a/components/decentralized_dns/core/pref_names.h b/components/decentralized_dns/core/pref_names.h index 7a91429db1c7..946a44732f37 100644 --- a/components/decentralized_dns/core/pref_names.h +++ b/components/decentralized_dns/core/pref_names.h @@ -13,25 +13,23 @@ namespace decentralized_dns { // Disabled: Disable all unstoppable domains resolution. // Ask: Ask users if they want to enable support of unstoppable domains. // Enabled: Resolve domain name using Ethereum JSON-RPC server. -constexpr char kUnstoppableDomainsResolveMethod[] = - "brave.unstoppable_domains.resolve_method"; +extern const char kUnstoppableDomainsResolveMethod[]; // Used to determine which method should be used to resolve ENS domains, // between: // Disabled: Disable all ENS domains resolution. // Ask: Ask users if they want to enable support of ENS. // Enabled: Resolve domain name using Ethereum JSON-RPC server. -constexpr char kENSResolveMethod[] = "brave.ens.resolve_method"; +extern const char kENSResolveMethod[]; -constexpr char kEnsOffchainResolveMethod[] = - "brave.ens.offchain_resolve_method"; +extern const char kEnsOffchainResolveMethod[]; // Used to determine which method should be used to resolve SNS domains, // between: // Disabled: Disable all SNS domains resolution. // Ask: Ask users if they want to enable support of SNS. // Enabled: Resolve domain name using Solana JSON-RPC server. -constexpr char kSnsResolveMethod[] = "brave.sns.resolve_method"; +extern const char kSnsResolveMethod[]; } // namespace decentralized_dns From 429de7644cd602636e57a61af3350dedde0d9280 Mon Sep 17 00:00:00 2001 From: AlexeyBarabash Date: Wed, 4 Jan 2023 16:28:12 +0200 Subject: [PATCH 8/8] Updated comment for BravePrefServiceBridge class --- .../chrome/browser/preferences/BravePrefServiceBridge.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java index 3f2df53b3112..260846bb99a3 100644 --- a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java +++ b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java @@ -15,11 +15,11 @@ /** * Please don't add anything in that file. We are going to refactor it soon. - * The only exceptions are preferences that are stored in a local_state - * g_browser_process->local_state(). * Check this PRs on how to handle preferences correctly: * https://github.com/brave/brave-core/pull/16356 * https://github.com/brave/brave-core/pull/15905 + * For the local_state based prefs please look on the PR: + * https://github.com/brave/brave-core/pull/16486 * Contact code owners if you have additional questions. */