From fecbbfd27fce70a82e95e157614fe09bb7709271 Mon Sep 17 00:00:00 2001 From: Darnell Andries Date: Thu, 22 Aug 2024 17:54:38 -0700 Subject: [PATCH] Move Web Discovery Android prefs to separate target --- .../privacy/settings/BravePrivacySettings.java | 5 +++-- browser/android/preferences/BUILD.gn | 1 - build/android/config.gni | 1 + components/web_discovery/android/BUILD.gn | 12 ++++++++++++ .../java_templates/WebDiscoveryPrefs.java.tmpl | 15 +++++++++++++++ 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 components/web_discovery/android/BUILD.gn create mode 100644 components/web_discovery/android/java_templates/WebDiscoveryPrefs.java.tmpl 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 5cd65887f143..f545dd43e523 100644 --- a/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java +++ b/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java @@ -38,6 +38,7 @@ import org.chromium.components.browser_ui.settings.SettingsUtils; import org.chromium.components.prefs.PrefService; import org.chromium.components.user_prefs.UserPrefs; +import org.chromium.components.web_discovery.WebDiscoveryPrefs; import org.chromium.gms.ChromiumPlayServicesAvailability; import org.chromium.mojo.bindings.ConnectionErrorHandler; import org.chromium.mojo.system.MojoException; @@ -535,7 +536,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { BraveLocalState.commitPendingWrite(); } else if (PREF_SEND_WEB_DISCOVERY.equals(key)) { UserPrefs.get(ProfileManager.getLastUsedRegularProfile()) - .setBoolean(BravePref.WEB_DISCOVERY_NATIVE_ENABLED, (boolean) newValue); + .setBoolean(WebDiscoveryPrefs.WEB_DISCOVERY_NATIVE_ENABLED, (boolean) newValue); } else if (PREF_SEND_CRASH_REPORTS.equals(key)) { UmaSessionStats.changeMetricsReportingConsent( (boolean) newValue, ChangeMetricsReportingStateCalledFrom.UI_SETTINGS); @@ -703,7 +704,7 @@ private void updateBravePreferences() { getActivity().getResources().getString(R.string.send_web_discovery_summary)); mSendWebDiscovery.setChecked( UserPrefs.get(ProfileManager.getLastUsedRegularProfile()) - .getBoolean(BravePref.WEB_DISCOVERY_NATIVE_ENABLED)); + .getBoolean(WebDiscoveryPrefs.WEB_DISCOVERY_NATIVE_ENABLED)); } mSendCrashReports.setChecked(mPrivacyPrefManager.isUsageAndCrashReportingPermittedByUser()); diff --git a/browser/android/preferences/BUILD.gn b/browser/android/preferences/BUILD.gn index 8b17806592a2..8c2e03b5987a 100644 --- a/browser/android/preferences/BUILD.gn +++ b/browser/android/preferences/BUILD.gn @@ -51,7 +51,6 @@ java_cpp_strings("java_pref_names_srcjar") { "//brave/components/request_otr/common/pref_names.h", "//brave/components/search_engines/brave_search_engines_pref_names.h", "//brave/components/speedreader/speedreader_pref_names.h", - "//brave/components/web_discovery/browser/pref_names.h", "//components/translate/core/browser/translate_pref_names.h", ] diff --git a/build/android/config.gni b/build/android/config.gni index 4c9258611191..e153c4af0c1e 100644 --- a/build/android/config.gni +++ b/build/android/config.gni @@ -81,6 +81,7 @@ brave_chrome_java_srcjar_deps = [ "//brave/android:brave_android_java_enums_srcjar", "//brave/android:brave_config_java", "//brave/browser/android/preferences:java_pref_names_srcjar", + "//brave/components/web_discovery/android:java_pref_names_srcjar", ] brave_chrome_app_java_resources_deps = [ diff --git a/components/web_discovery/android/BUILD.gn b/components/web_discovery/android/BUILD.gn new file mode 100644 index 000000000000..27966758aebb --- /dev/null +++ b/components/web_discovery/android/BUILD.gn @@ -0,0 +1,12 @@ +# Copyright (c) 2024 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("//build/config/android/rules.gni") + +java_cpp_strings("java_pref_names_srcjar") { + sources = [ "//brave/components/web_discovery/browser/pref_names.h" ] + + template = "//brave/components/web_discovery/android/java_templates/WebDiscoveryPrefs.java.tmpl" +} diff --git a/components/web_discovery/android/java_templates/WebDiscoveryPrefs.java.tmpl b/components/web_discovery/android/java_templates/WebDiscoveryPrefs.java.tmpl new file mode 100644 index 000000000000..9bc52c2ae618 --- /dev/null +++ b/components/web_discovery/android/java_templates/WebDiscoveryPrefs.java.tmpl @@ -0,0 +1,15 @@ +/* Copyright (c) 2024 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.components.web_discovery; + +/** Contains Web Discovery preference names. */ +public final class WebDiscoveryPrefs {{ + +{NATIVE_STRINGS} + + // Prevents instantiation. + private WebDiscoveryPrefs() {{}} +}}