Skip to content

Commit

Permalink
Move Web Discovery Android prefs to separate target
Browse files Browse the repository at this point in the history
  • Loading branch information
DJAndries committed Oct 25, 2024
1 parent 4aaff0b commit fecbbfd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down
1 change: 0 additions & 1 deletion browser/android/preferences/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down
1 change: 1 addition & 0 deletions build/android/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
12 changes: 12 additions & 0 deletions components/web_discovery/android/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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() {{}}
}}

0 comments on commit fecbbfd

Please sign in to comment.