[Android] Remove deprecated getLastUsedRegularProfile from Profile
Chromium change: https://source.chromium.org/chromium/chromium/src/+/913e0498eac18b4cd078eb402e04dbe985ac18e0 Remove deprecated getLastUsedRegularProfile from Profile.java Bug: 40254448
This commit is contained in:
@@ -8,6 +8,7 @@ package org.chromium.chrome.browser;
|
||||
import org.chromium.base.ContextUtils;
|
||||
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridge;
|
||||
import org.chromium.components.content_settings.ContentSettingValues;
|
||||
import org.chromium.components.content_settings.ContentSettingsType;
|
||||
@@ -29,7 +30,7 @@ public class BraveHelper {
|
||||
public static void maybeMigrateSettings() {
|
||||
// False is the default value, so we want to migrate it only when it's true.
|
||||
if (BravePrefServiceBridge.getInstance().getDesktopModeEnabled()) {
|
||||
Profile profile = Profile.getLastUsedRegularProfile();
|
||||
Profile profile = ProfileManager.getLastUsedRegularProfile();
|
||||
WebsitePreferenceBridge.setDefaultContentSetting(
|
||||
profile, ContentSettingsType.REQUEST_DESKTOP_SITE, ContentSettingValues.ALLOW);
|
||||
// Reset old flag to default value, so we don't migrate it anymore.
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.chromium.base.IntentUtils;
|
||||
import org.chromium.base.Log;
|
||||
import org.chromium.base.ThreadUtils;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
|
||||
import org.chromium.content_public.browser.BrowserStartupController;
|
||||
|
||||
@@ -69,7 +70,7 @@ public class BraveIntentHandler {
|
||||
@Override
|
||||
public String call() {
|
||||
return TemplateUrlServiceFactory
|
||||
.getForProfile(Profile.getLastUsedRegularProfile())
|
||||
.getForProfile(ProfileManager.getLastUsedRegularProfile())
|
||||
.getUrlForSearchQuery(query);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.chromium.chrome.browser.app.BraveActivity;
|
||||
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.tab.Tab;
|
||||
import org.chromium.components.browser_ui.widget.RoundedIconGenerator;
|
||||
import org.chromium.components.favicon.IconType;
|
||||
@@ -235,7 +236,7 @@ public class BraveRewardsHelper implements LargeIconBridge.LargeIconCallback {
|
||||
public BraveRewardsHelper(Tab tab) {
|
||||
mTab = tab;
|
||||
assert mTab != null;
|
||||
mProfile = Profile.getLastUsedRegularProfile();
|
||||
mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
if (sLargeIconBridge == null && mTab != null && mProfile != null) {
|
||||
sLargeIconBridge = new LargeIconBridge(mProfile);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.google.android.material.slider.Slider;
|
||||
import org.chromium.base.ContextUtils;
|
||||
import org.chromium.base.Log;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -145,7 +145,7 @@ public class BraveRewardsOnboardingPagerAdapter extends PagerAdapter {
|
||||
adsValue));
|
||||
}
|
||||
if (BraveAdsNativeHelper.nativeIsOptedInToNotificationAds(
|
||||
Profile.getLastUsedRegularProfile())) {
|
||||
ProfileManager.getLastUsedRegularProfile())) {
|
||||
BraveRewardsNativeWorker.getInstance()
|
||||
.setAdsPerHour((int) slider.getValue());
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ import org.chromium.chrome.browser.prefetch.settings.PreloadPagesSettingsBridge;
|
||||
import org.chromium.chrome.browser.prefetch.settings.PreloadPagesState;
|
||||
import org.chromium.chrome.browser.privacy.settings.BravePrivacySettings;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.rate.BraveRateDialogFragment;
|
||||
import org.chromium.chrome.browser.rate.RateUtils;
|
||||
import org.chromium.chrome.browser.rewards.adaptive_captcha.AdaptiveCaptchaHelper;
|
||||
@@ -789,7 +790,7 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
|
||||
if (isClearBrowsingDataOnExit()) {
|
||||
List<Integer> dataTypes = Arrays.asList(
|
||||
BrowsingDataType.HISTORY, BrowsingDataType.COOKIES, BrowsingDataType.CACHE);
|
||||
BrowsingDataType.HISTORY, BrowsingDataType.SITE_DATA, BrowsingDataType.CACHE);
|
||||
|
||||
int[] dataTypesArray = CollectionUtil.integerCollectionToIntArray(dataTypes);
|
||||
|
||||
@@ -900,10 +901,12 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
|
||||
@Override
|
||||
public void onPreferenceChange() {
|
||||
String captchaID = UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
.getString(BravePref.SCHEDULED_CAPTCHA_ID);
|
||||
String paymentID = UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
.getString(BravePref.SCHEDULED_CAPTCHA_PAYMENT_ID);
|
||||
String captchaID =
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getString(BravePref.SCHEDULED_CAPTCHA_ID);
|
||||
String paymentID =
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getString(BravePref.SCHEDULED_CAPTCHA_PAYMENT_ID);
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(AdaptiveCaptchaHelper.TAG,
|
||||
"captchaID : " + captchaID + " Payment ID : " + paymentID);
|
||||
@@ -927,10 +930,12 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
}
|
||||
|
||||
public void maybeSolveAdaptiveCaptcha() {
|
||||
String captchaID = UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
.getString(BravePref.SCHEDULED_CAPTCHA_ID);
|
||||
String paymentID = UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
.getString(BravePref.SCHEDULED_CAPTCHA_PAYMENT_ID);
|
||||
String captchaID =
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getString(BravePref.SCHEDULED_CAPTCHA_ID);
|
||||
String paymentID =
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getString(BravePref.SCHEDULED_CAPTCHA_PAYMENT_ID);
|
||||
if (!TextUtils.isEmpty(captchaID) && !TextUtils.isEmpty(paymentID)
|
||||
&& !BravePrefServiceBridge.getInstance().getSafetynetCheckFailed()) {
|
||||
AdaptiveCaptchaHelper.startAttestation(captchaID, paymentID);
|
||||
@@ -953,21 +958,22 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
PrefChangeRegistrar mPrefChangeRegistrar = new PrefChangeRegistrar();
|
||||
mPrefChangeRegistrar.addObserver(BravePref.SCHEDULED_CAPTCHA_ID, this);
|
||||
|
||||
if (UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
if (UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS)
|
||||
>= MAX_FAILED_CAPTCHA_ATTEMPTS) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.SCHEDULED_CAPTCHA_PAUSED, true);
|
||||
}
|
||||
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(AdaptiveCaptchaHelper.TAG,
|
||||
Log.e(
|
||||
AdaptiveCaptchaHelper.TAG,
|
||||
"Failed attempts : "
|
||||
+ UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
.getInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS));
|
||||
+ UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS));
|
||||
}
|
||||
if (!UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.SCHEDULED_CAPTCHA_PAUSED)) {
|
||||
if (!UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.SCHEDULED_CAPTCHA_PAUSED)) {
|
||||
maybeSolveAdaptiveCaptcha();
|
||||
}
|
||||
|
||||
@@ -1369,13 +1375,19 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
ChromeSharedPreferences.getInstance()
|
||||
.readBoolean(BravePrivacySettings.PREF_FINGERPRINTING_PROTECTION, true);
|
||||
if (value) {
|
||||
BraveShieldsContentSettings.setShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
ProfileManager.getLastUsedRegularProfile(),
|
||||
"",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING,
|
||||
BraveShieldsContentSettings.DEFAULT, false);
|
||||
BraveShieldsContentSettings.DEFAULT,
|
||||
false);
|
||||
} else {
|
||||
BraveShieldsContentSettings.setShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
ProfileManager.getLastUsedRegularProfile(),
|
||||
"",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING,
|
||||
BraveShieldsContentSettings.ALLOW_RESOURCE, false);
|
||||
BraveShieldsContentSettings.ALLOW_RESOURCE,
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1444,7 +1456,7 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
private void checkForYandexSE() {
|
||||
String countryCode = Locale.getDefault().getCountry();
|
||||
if (sYandexRegions.contains(countryCode)) {
|
||||
Profile lastUsedRegularProfile = Profile.getLastUsedRegularProfile();
|
||||
Profile lastUsedRegularProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
TemplateUrl yandexTemplateUrl = BraveSearchEngineUtils.getTemplateUrlByShortName(
|
||||
lastUsedRegularProfile, OnboardingPrefManager.YANDEX);
|
||||
if (yandexTemplateUrl != null) {
|
||||
@@ -1610,7 +1622,7 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
public Profile getCurrentProfile() {
|
||||
Tab tab = getActivityTab();
|
||||
if (tab == null) {
|
||||
return Profile.getLastUsedRegularProfile();
|
||||
return ProfileManager.getLastUsedRegularProfile();
|
||||
}
|
||||
|
||||
return Profile.fromWebContents(tab.getWebContents());
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.app.BraveActivity;
|
||||
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.misc_metrics.mojom.MiscAndroidMetrics;
|
||||
|
||||
import java.io.File;
|
||||
@@ -301,7 +302,7 @@ public class BraveStatsUtil {
|
||||
|
||||
public static List<Pair<String, String>> getStatsPairs() {
|
||||
List<Pair<String, String>> statsPair = new ArrayList<>();
|
||||
Profile mProfile = Profile.getLastUsedRegularProfile();
|
||||
Profile mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
long trackersBlockedCount =
|
||||
BravePrefServiceBridge.getInstance().getTrackersBlockedCount(mProfile);
|
||||
long adsBlockedCount = BravePrefServiceBridge.getInstance().getAdsBlockedCount(mProfile);
|
||||
@@ -323,7 +324,7 @@ public class BraveStatsUtil {
|
||||
}
|
||||
|
||||
public static Pair<String, String> getAdsTrackersBlocked() {
|
||||
Profile mProfile = Profile.getLastUsedRegularProfile();
|
||||
Profile mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
long trackersBlockedCount =
|
||||
BravePrefServiceBridge.getInstance().getTrackersBlockedCount(mProfile);
|
||||
long adsBlockedCount = BravePrefServiceBridge.getInstance().getAdsBlockedCount(mProfile);
|
||||
|
||||
@@ -72,6 +72,7 @@ import org.chromium.chrome.browser.app.ChromeActivity;
|
||||
import org.chromium.chrome.browser.crypto_wallet.activities.BraveWalletBaseActivity;
|
||||
import org.chromium.chrome.browser.crypto_wallet.model.AccountSelectorItemModel;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.util.TabUtils;
|
||||
import org.chromium.ui.text.NoUnderlineClickableSpan;
|
||||
import org.chromium.ui.widget.Toast;
|
||||
@@ -1070,7 +1071,7 @@ public class Utils {
|
||||
Log.e(TAG, "getProfile " + e);
|
||||
}
|
||||
if (chromeActivity == null) chromeActivity = BraveActivity.getChromeTabbedActivity();
|
||||
if (chromeActivity == null) return Profile.getLastUsedRegularProfile(); // Last resort
|
||||
if (chromeActivity == null) return ProfileManager.getLastUsedRegularProfile(); // Last resort
|
||||
|
||||
return chromeActivity.getTabModelSelector().getModel(isIncognito).getProfile();
|
||||
}
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ import androidx.preference.PreferenceCategory;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.BraveRelaunchUtils;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
|
||||
import org.chromium.components.user_prefs.UserPrefs;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BraveLanguageSettings extends LanguageSettings {
|
||||
(PreferenceCategory) findPreference(APP_LANGUAGE_SECTION);
|
||||
if (appLanguageSection != null) {
|
||||
boolean isBraveTranslateEnabled =
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.OFFER_TRANSLATE_ENABLED);
|
||||
ChromeSwitchPreference braveTranslateFeaturePreference =
|
||||
new ChromeSwitchPreference(getContext());
|
||||
@@ -43,7 +43,7 @@ public class BraveLanguageSettings extends LanguageSettings {
|
||||
braveTranslateFeaturePreference.setChecked(isBraveTranslateEnabled);
|
||||
braveTranslateFeaturePreference.setOnPreferenceChangeListener(
|
||||
(preference, newValue) -> {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.OFFER_TRANSLATE_ENABLED, (boolean) newValue);
|
||||
if (getActivity() != null) {
|
||||
BraveRelaunchUtils.askForRelaunch(getActivity());
|
||||
|
||||
+4
-3
@@ -22,6 +22,7 @@ import org.chromium.chrome.browser.night_mode.WebContentsDarkModeController;
|
||||
import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.components.browser_ui.settings.SettingsUtils;
|
||||
|
||||
public class BraveThemePreferences extends ThemeSettingsFragment {
|
||||
@@ -35,7 +36,7 @@ public class BraveThemePreferences extends ThemeSettingsFragment {
|
||||
SettingsUtils.addPreferencesFromResource(this, R.xml.brave_theme_preferences);
|
||||
getActivity().setTitle(getResources().getString(R.string.theme_settings));
|
||||
|
||||
Profile mProfile = Profile.getLastUsedRegularProfile();
|
||||
Profile mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
NTPBackgroundImagesBridge mNTPBackgroundImagesBridge = NTPBackgroundImagesBridge.getInstance(mProfile);
|
||||
if (!NTPBackgroundImagesBridge.enableSponsoredImages()
|
||||
|| (mNTPBackgroundImagesBridge != null
|
||||
@@ -59,7 +60,7 @@ public class BraveThemePreferences extends ThemeSettingsFragment {
|
||||
}
|
||||
|
||||
mWebContentsDarkModeEnabled = WebContentsDarkModeController.isGlobalUserSettingsEnabled(
|
||||
Profile.getLastUsedRegularProfile());
|
||||
ProfileManager.getLastUsedRegularProfile());
|
||||
radioButtonGroupThemePreference.initialize(
|
||||
sharedPreferencesManager.readInt(UI_THEME_SETTING, defaultThemePref),
|
||||
mWebContentsDarkModeEnabled);
|
||||
@@ -72,7 +73,7 @@ public class BraveThemePreferences extends ThemeSettingsFragment {
|
||||
mWebContentsDarkModeEnabled =
|
||||
radioButtonGroupThemePreference.isDarkenWebsitesEnabled();
|
||||
WebContentsDarkModeController.setGlobalUserSettings(
|
||||
Profile.getLastUsedRegularProfile(), mWebContentsDarkModeEnabled);
|
||||
ProfileManager.getLastUsedRegularProfile(), mWebContentsDarkModeEnabled);
|
||||
}
|
||||
}
|
||||
int theme = (int) newValue;
|
||||
|
||||
@@ -192,7 +192,7 @@ public class BraveNewTabPageLayout
|
||||
super(context, attrs);
|
||||
|
||||
mContext = context;
|
||||
mProfile = Profile.getLastUsedRegularProfile();
|
||||
mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
mNTPBackgroundImagesBridge = NTPBackgroundImagesBridge.getInstance(mProfile);
|
||||
mNTPBackgroundImagesBridge.setNewTabPageListener(mNewTabPageListener);
|
||||
mDatabaseHelper = DatabaseHelper.getInstance();
|
||||
@@ -1232,7 +1232,7 @@ public class BraveNewTabPageLayout
|
||||
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
setBackgroundImage(ntpImage);
|
||||
|
||||
} else if (UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
} else if (UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE)
|
||||
&& mSponsoredTab != null && NTPUtil.shouldEnableNTPFeature()) {
|
||||
setBackgroundImage(ntpImage);
|
||||
@@ -1488,7 +1488,7 @@ public class BraveNewTabPageLayout
|
||||
protected boolean isScrollableMvtEnabled() {
|
||||
return ChromeFeatureList.isEnabled(ChromeFeatureList.SHOW_SCROLLABLE_MVT_ON_NTP_ANDROID)
|
||||
&& !DeviceFormFactor.isNonMultiDisplayContextOnTablet(mContext)
|
||||
&& UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
&& UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ import org.chromium.chrome.browser.ntp_background_images.model.Wallpaper;
|
||||
import org.chromium.chrome.browser.ntp_background_images.util.NTPUtil;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.settings.BackgroundImagesPreferences;
|
||||
import org.chromium.chrome.browser.util.BraveConstants;
|
||||
import org.chromium.chrome.browser.util.BraveTouchUtils;
|
||||
@@ -209,7 +209,7 @@ public class BraveNtpAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||
"QRCodeShareDialogFragment");
|
||||
});
|
||||
|
||||
} else if (UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
} else if (UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE)
|
||||
&& mSponsoredTab != null && NTPUtil.shouldEnableNTPFeature()) {
|
||||
if (mNtpImage instanceof BackgroundImage) {
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.chromium.chrome.browser.ntp_background_images.model.SponsoredTab;
|
||||
import org.chromium.chrome.browser.ntp_background_images.model.Wallpaper;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.settings.BackgroundImagesPreferences;
|
||||
import org.chromium.chrome.browser.util.ConfigurationUtils;
|
||||
import org.chromium.chrome.browser.util.ImageUtils;
|
||||
@@ -464,9 +465,16 @@ public class NTPUtil {
|
||||
}
|
||||
|
||||
public static boolean isReferralEnabled() {
|
||||
Profile mProfile = Profile.getLastUsedRegularProfile();
|
||||
NTPBackgroundImagesBridge mNTPBackgroundImagesBridge = NTPBackgroundImagesBridge.getInstance(mProfile);
|
||||
boolean isReferralEnabled = UserPrefs.get(Profile.getLastUsedRegularProfile()).getInteger(BravePref.NEW_TAB_PAGE_SUPER_REFERRAL_THEMES_OPTION) == 1 ? true : false;
|
||||
Profile mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
NTPBackgroundImagesBridge mNTPBackgroundImagesBridge =
|
||||
NTPBackgroundImagesBridge.getInstance(mProfile);
|
||||
boolean isReferralEnabled =
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getInteger(
|
||||
BravePref.NEW_TAB_PAGE_SUPER_REFERRAL_THEMES_OPTION)
|
||||
== 1
|
||||
? true
|
||||
: false;
|
||||
return mNTPBackgroundImagesBridge.isSuperReferral() && isReferralEnabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.chromium.chrome.browser.app.BraveActivity;
|
||||
import org.chromium.chrome.browser.app.BraveActivity.BraveActivityNotFoundException;
|
||||
import org.chromium.chrome.browser.notifications.BraveOnboardingNotification;
|
||||
import org.chromium.chrome.browser.notifications.retention.RetentionNotificationUtil;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.misc_metrics.mojom.MiscAndroidMetrics;
|
||||
|
||||
import java.util.Calendar;
|
||||
@@ -216,7 +216,7 @@ public class OnboardingPrefManager {
|
||||
}
|
||||
|
||||
public boolean isAdsAvailable() {
|
||||
return BraveAdsNativeHelper.nativeIsSupportedRegion(Profile.getLastUsedRegularProfile());
|
||||
return BraveAdsNativeHelper.nativeIsSupportedRegion(ProfileManager.getLastUsedRegularProfile());
|
||||
}
|
||||
|
||||
public void showOnboarding(Context context) {
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
|
||||
import org.chromium.chrome.browser.settings.BraveSearchEngineUtils;
|
||||
import org.chromium.components.search_engines.TemplateUrl;
|
||||
@@ -52,7 +53,7 @@ public class SearchEngineOnboardingFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mProfile = Profile.getLastUsedRegularProfile();
|
||||
mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.chromium.base.task.PostTask;
|
||||
import org.chromium.base.task.TaskTraits;
|
||||
import org.chromium.chrome.browser.playlist.PlaylistServiceFactoryAndroid;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.mojo.bindings.ConnectionErrorHandler;
|
||||
import org.chromium.mojo.system.MojoException;
|
||||
import org.chromium.playlist.mojom.PlaylistService;
|
||||
@@ -226,7 +226,7 @@ public class HlsServiceImpl extends HlsService.Impl implements ConnectionErrorHa
|
||||
mPlaylistService =
|
||||
PlaylistServiceFactoryAndroid.getInstance()
|
||||
.getPlaylistService(
|
||||
Profile.getLastUsedRegularProfile(), HlsServiceImpl.this);
|
||||
ProfileManager.getLastUsedRegularProfile(), HlsServiceImpl.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-11
@@ -10,6 +10,7 @@ import org.jni_zero.JNINamespace;
|
||||
import org.jni_zero.NativeMethods;
|
||||
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -148,58 +149,58 @@ public class BraveShieldsContentSettings {
|
||||
}
|
||||
|
||||
public static void setFingerprintingPref(String value) {
|
||||
setShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
setShieldsValue(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING, value, false);
|
||||
}
|
||||
|
||||
public static void setHttpsUpgradePref(String value) {
|
||||
setShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
setShieldsValue(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_HTTPS_UPGRADE, value, false);
|
||||
}
|
||||
|
||||
public static void setCookiesPref(String value) {
|
||||
setShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
setShieldsValue(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_COOKIES, value, false);
|
||||
}
|
||||
|
||||
public static void setTrackersPref(String value) {
|
||||
setShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
setShieldsValue(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_TRACKERS, value, false);
|
||||
}
|
||||
|
||||
public static void setJavascriptPref(boolean value) {
|
||||
setShields(Profile.getLastUsedRegularProfile(), "",
|
||||
setShields(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_JAVASCRIPTS, value, false);
|
||||
}
|
||||
|
||||
public static void setForgetFirstPartyStoragePref(boolean value) {
|
||||
setShields(Profile.getLastUsedRegularProfile(), "",
|
||||
setShields(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FORGET_FIRST_PARTY_STORAGE, value,
|
||||
false);
|
||||
}
|
||||
|
||||
public static boolean getJavascriptPref() {
|
||||
return getShields(Profile.getLastUsedRegularProfile(), "",
|
||||
return getShields(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_JAVASCRIPTS);
|
||||
}
|
||||
|
||||
public static String getTrackersPref() {
|
||||
return getShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
return getShieldsValue(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_TRACKERS);
|
||||
}
|
||||
|
||||
public static String getFingerprintingPref() {
|
||||
return getShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
return getShieldsValue(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING);
|
||||
}
|
||||
|
||||
public static String getHttpsUpgradePref() {
|
||||
return getShieldsValue(Profile.getLastUsedRegularProfile(), "",
|
||||
return getShieldsValue(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_HTTPS_UPGRADE);
|
||||
}
|
||||
|
||||
public static boolean getForgetFirstPartyStoragePref() {
|
||||
return getShields(Profile.getLastUsedRegularProfile(), "",
|
||||
return getShields(ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FORGET_FIRST_PARTY_STORAGE);
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -27,7 +27,7 @@ import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.preferences.Pref;
|
||||
import org.chromium.chrome.browser.preferences.website.BraveShieldsContentSettings;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.safe_browsing.settings.NoGooglePlayServicesDialog;
|
||||
import org.chromium.chrome.browser.settings.BraveDialogPreference;
|
||||
import org.chromium.chrome.browser.settings.BravePreferenceDialogFragment;
|
||||
@@ -170,7 +170,7 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
private static final int ALLOW = 2;
|
||||
|
||||
private final PrefService mPrefServiceBridge =
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile());
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile());
|
||||
private final PrivacyPreferencesManagerImpl mPrivacyPrefManager =
|
||||
PrivacyPreferencesManagerImpl.getInstance();
|
||||
private ChromeManagedPreferenceDelegate mManagedPreferenceDelegate;
|
||||
@@ -435,7 +435,7 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
SharedPreferences.Editor sharedPreferencesEditor =
|
||||
ContextUtils.getAppSharedPreferences().edit();
|
||||
if (PREF_HTTPS_FIRST_MODE.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(Pref.HTTPS_ONLY_MODE_ENABLED, (boolean) newValue);
|
||||
} else if (PREF_HTTPS_UPGRADE.equals(key)) {
|
||||
switch ((int) newValue) {
|
||||
@@ -463,10 +463,10 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
break;
|
||||
}
|
||||
} else if (PREF_DE_AMP.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.DE_AMP_PREF_ENABLED, (boolean) newValue);
|
||||
} else if (PREF_DEBOUNCE.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.DEBOUNCE_ENABLED, (boolean) newValue);
|
||||
} else if (PREF_IPFS_GATEWAY.equals(key)) {
|
||||
BravePrivacySettingsIPFSUtils.setIPFSGatewayPref((boolean) newValue);
|
||||
@@ -516,11 +516,11 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
? BraveShieldsContentSettings.DEFAULT
|
||||
: BraveShieldsContentSettings.ALLOW_RESOURCE);
|
||||
} else if (PREF_REQUEST_OTR.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setInteger(BravePref.REQUEST_OTR_ACTION_OPTION, (int) newValue);
|
||||
updateRequestOtrPref();
|
||||
} else if (PREF_FINGERPRINT_LANGUAGE.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.REDUCE_LANGUAGE_ENABLED, (boolean) newValue);
|
||||
} else if (PREF_BLOCK_CROSS_SITE_COOKIES.equals(key)) {
|
||||
switch ((int) newValue) {
|
||||
@@ -567,22 +567,22 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
boolean autocompleteEnabled = (boolean) newValue;
|
||||
mSearchSuggestions.setEnabled(autocompleteEnabled);
|
||||
mAutocompleteTopSites.setEnabled(autocompleteEnabled);
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.AUTOCOMPLETE_ENABLED, autocompleteEnabled);
|
||||
} else if (PREF_AUTOCOMPLETE_TOP_SITES.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.TOP_SITE_SUGGESTIONS_ENABLED, (boolean) newValue);
|
||||
} else if (PREF_SOCIAL_BLOCKING_GOOGLE.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.GOOGLE_LOGIN_CONTROL_TYPE, (boolean) newValue);
|
||||
} else if (PREF_SOCIAL_BLOCKING_FACEBOOK.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.FB_EMBED_CONTROL_TYPE, (boolean) newValue);
|
||||
} else if (PREF_SOCIAL_BLOCKING_TWITTER.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.TWITTER_EMBED_CONTROL_TYPE, (boolean) newValue);
|
||||
} else if (PREF_SOCIAL_BLOCKING_LINKEDIN.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.LINKED_IN_EMBED_CONTROL_TYPE, (boolean) newValue);
|
||||
} else if (PREF_CLEAR_ON_EXIT.equals(key)) {
|
||||
sharedPreferencesEditor.putBoolean(
|
||||
@@ -645,7 +645,7 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
ChromeFeatureList.isEnabled(BraveFeatureList.HTTPS_BY_DEFAULT);
|
||||
mHttpsFirstModePref.setVisible(!httpsByDefaultIsEnabled);
|
||||
mHttpsFirstModePref.setChecked(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(Pref.HTTPS_ONLY_MODE_ENABLED));
|
||||
|
||||
// IPFS Gateway
|
||||
@@ -739,18 +739,18 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
webrtcPolicyToString(BravePrefServiceBridge.getInstance().getWebrtcPolicy()));
|
||||
|
||||
mAutocompleteTopSites.setChecked(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.TOP_SITE_SUGGESTIONS_ENABLED));
|
||||
|
||||
mClearBrowsingDataOnExit.setChecked(
|
||||
sharedPreferences.getBoolean(BravePreferenceKeys.BRAVE_CLEAR_ON_EXIT, false));
|
||||
|
||||
boolean autocompleteEnabled = UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
boolean autocompleteEnabled = UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.AUTOCOMPLETE_ENABLED);
|
||||
mShowAutocompleteInAddressBar.setChecked(autocompleteEnabled);
|
||||
mSearchSuggestions.setEnabled(autocompleteEnabled);
|
||||
mAutocompleteTopSites.setEnabled(autocompleteEnabled);
|
||||
mFingerprntLanguagePref.setChecked(UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
mFingerprntLanguagePref.setChecked(UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.REDUCE_LANGUAGE_ENABLED));
|
||||
if (mFilterListAndroidHandler != null) {
|
||||
mFilterListAndroidHandler.isFilterListEnabled(FilterListConstants.COOKIE_LIST_UUID,
|
||||
@@ -760,34 +760,34 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
}
|
||||
// Debounce
|
||||
if (mDebouncePref != null) {
|
||||
mDebouncePref.setChecked(UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
mDebouncePref.setChecked(UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.DEBOUNCE_ENABLED));
|
||||
}
|
||||
|
||||
// Social blocking
|
||||
if (mSocialBlockingGoogle != null) {
|
||||
mSocialBlockingGoogle.setChecked(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.GOOGLE_LOGIN_CONTROL_TYPE));
|
||||
}
|
||||
if (mSocialBlockingFacebook != null) {
|
||||
mSocialBlockingFacebook.setChecked(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.FB_EMBED_CONTROL_TYPE));
|
||||
}
|
||||
if (mSocialBlockingTwitter != null) {
|
||||
mSocialBlockingTwitter.setChecked(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.TWITTER_EMBED_CONTROL_TYPE));
|
||||
}
|
||||
if (mSocialBlockingLinkedin != null) {
|
||||
mSocialBlockingLinkedin.setChecked(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.LINKED_IN_EMBED_CONTROL_TYPE));
|
||||
}
|
||||
|
||||
if (mDeAmpPref != null) {
|
||||
mDeAmpPref.setChecked(UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
mDeAmpPref.setChecked(UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.DE_AMP_PREF_ENABLED));
|
||||
}
|
||||
|
||||
@@ -799,7 +799,7 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
|
||||
}
|
||||
|
||||
private void updateRequestOtrPref() {
|
||||
int requestOtrPrefValue = UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
int requestOtrPrefValue = UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getInteger(BravePref.REQUEST_OTR_ACTION_OPTION);
|
||||
if (requestOtrPrefValue == BraveShieldsContentSettings.ALWAYS) {
|
||||
mRequestOtrPref.setCheckedIndex(0);
|
||||
|
||||
+3
-3
@@ -7,13 +7,13 @@ package org.chromium.chrome.browser.privacy.settings;
|
||||
|
||||
import org.chromium.chrome.browser.BraveConfig;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.components.user_prefs.UserPrefs;
|
||||
|
||||
public class BravePrivacySettingsIPFSUtils {
|
||||
public static void setIPFSGatewayPref(boolean preference) {
|
||||
if (BraveConfig.IPFS_ENABLED) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setInteger(BravePref.IPFS_RESOLVE_METHOD,
|
||||
preference ? IPFSResolveMethodTypes.IPFS_ASK
|
||||
: IPFSResolveMethodTypes.IPFS_DISABLED);
|
||||
@@ -22,7 +22,7 @@ public class BravePrivacySettingsIPFSUtils {
|
||||
|
||||
public static boolean getIPFSGatewayPref() {
|
||||
if (BraveConfig.IPFS_ENABLED) {
|
||||
return UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
return UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getInteger(BravePref.IPFS_RESOLVE_METHOD)
|
||||
!= IPFSResolveMethodTypes.IPFS_DISABLED;
|
||||
} else {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ProfileUtils {
|
||||
} catch (BraveActivity.BraveActivityNotFoundException e) {
|
||||
Log.e(TAG, "getProfile " + e);
|
||||
}
|
||||
if (braveActivity == null) return Profile.getLastUsedRegularProfile();
|
||||
if (braveActivity == null) return ProfileManager.getLastUsedRegularProfile();
|
||||
return braveActivity.getCurrentProfile();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.chromium.chrome.browser.about_settings.AboutChromeSettings;
|
||||
import org.chromium.chrome.browser.about_settings.AboutSettingsBridge;
|
||||
import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.net.ChromiumNetworkAdapter;
|
||||
import org.chromium.net.NetworkTrafficAnnotationTag;
|
||||
|
||||
@@ -72,7 +73,7 @@ public class RateFeedbackUtils {
|
||||
context, AboutSettingsBridge.getApplicationVersion());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Profile mProfile = Profile.getLastUsedRegularProfile();
|
||||
Profile mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
NTPBackgroundImagesBridge mNTPBackgroundImagesBridge =
|
||||
NTPBackgroundImagesBridge.getInstance(mProfile);
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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/.
|
||||
*/
|
||||
/* Copyright (c) 2021 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.rewards;
|
||||
|
||||
@@ -74,7 +72,7 @@ import org.chromium.chrome.browser.customtabs.CustomTabActivity;
|
||||
import org.chromium.chrome.browser.notifications.BraveNotificationWarningDialog;
|
||||
import org.chromium.chrome.browser.notifications.BravePermissionUtils;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.rewards.onboarding.RewardsOnboarding;
|
||||
import org.chromium.chrome.browser.rewards.tipping.PopupWindowTippingTabletUI;
|
||||
import org.chromium.chrome.browser.rewards.tipping.RewardsTippingBannerActivity;
|
||||
@@ -1484,7 +1482,7 @@ public class BraveRewardsPanel
|
||||
BraveTouchUtils.ensureMinTouchTarget(learnMoreUnverifiedText);
|
||||
|
||||
if (BraveAdsNativeHelper.nativeIsOptedInToNotificationAds(
|
||||
Profile.getLastUsedRegularProfile())) {
|
||||
ProfileManager.getLastUsedRegularProfile())) {
|
||||
if (mRewardsMainLayout != null) {
|
||||
mRewardsMainLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
+101
-100
@@ -20,7 +20,7 @@ import org.chromium.base.task.PostTask;
|
||||
import org.chromium.base.task.TaskTraits;
|
||||
import org.chromium.chrome.browser.BraveRewardsNativeWorker;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.settings.developer.BraveQAPreferences;
|
||||
import org.chromium.components.user_prefs.UserPrefs;
|
||||
import org.chromium.net.ChromiumNetworkAdapter;
|
||||
@@ -108,124 +108,125 @@ public class AdaptiveCaptchaHelper {
|
||||
|
||||
private static void attestPaymentId(
|
||||
String captchaId, String paymentId, String integrityToken, String uniqueValue) {
|
||||
PostTask.postTask(TaskTraits.BEST_EFFORT_MAY_BLOCK, () -> {
|
||||
HttpURLConnection urlConnection = null;
|
||||
String attestPaymentIdUrl =
|
||||
BraveRewardsNativeWorker.getInstance().getAttestationURLWithPaymentId(
|
||||
paymentId);
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(TAG, attestPaymentIdUrl);
|
||||
}
|
||||
NetworkTrafficAnnotationTag annotation = NetworkTrafficAnnotationTag.createComplete(
|
||||
"Brave attestation api android",
|
||||
"semantics {"
|
||||
+ " sender: 'Brave Android app'"
|
||||
+ " description: "
|
||||
+ " 'This api attests play integrity token for the given payment ID'"
|
||||
+ " trigger: 'When payment id as captcha scheduled with integrity token'"
|
||||
+ " data:"
|
||||
+ " 'integrity token, unique value, package name'"
|
||||
+ " destination: Brave grant endpoint"
|
||||
+ "}"
|
||||
+ "policy {"
|
||||
+ " cookies_allowed: NO"
|
||||
+ " policy_exception_justification: 'Not implemented.'"
|
||||
+ "}");
|
||||
String logMessage = "";
|
||||
try {
|
||||
URL url = new URL(attestPaymentIdUrl);
|
||||
urlConnection = getUrlConnection(PUT_METHOD, url, annotation);
|
||||
PostTask.postTask(
|
||||
TaskTraits.BEST_EFFORT_MAY_BLOCK,
|
||||
() -> {
|
||||
HttpURLConnection urlConnection = null;
|
||||
String attestPaymentIdUrl =
|
||||
BraveRewardsNativeWorker.getInstance()
|
||||
.getAttestationURLWithPaymentId(paymentId);
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(TAG, attestPaymentIdUrl);
|
||||
}
|
||||
NetworkTrafficAnnotationTag annotation =
|
||||
NetworkTrafficAnnotationTag.createComplete(
|
||||
"Brave attestation api android",
|
||||
"semantics { sender: 'Brave Android app' description: "
|
||||
+ " 'This api attests play integrity token for the given"
|
||||
+ " payment ID' trigger: 'When payment id as captcha"
|
||||
+ " scheduled with integrity token' data: 'integrity"
|
||||
+ " token, unique value, package name' destination: Brave"
|
||||
+ " grant endpoint}policy { cookies_allowed: NO "
|
||||
+ " policy_exception_justification: 'Not implemented.'}");
|
||||
String logMessage = "";
|
||||
try {
|
||||
URL url = new URL(attestPaymentIdUrl);
|
||||
urlConnection = getUrlConnection(PUT_METHOD, url, annotation);
|
||||
|
||||
writeRequestOutput(
|
||||
getAttestPaymentIdBody(integrityToken, uniqueValue), urlConnection);
|
||||
writeRequestOutput(
|
||||
getAttestPaymentIdBody(integrityToken, uniqueValue), urlConnection);
|
||||
|
||||
int responseCode = urlConnection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
solveCaptcha(captchaId, paymentId);
|
||||
logMessage = "Attest payment Id call is successful";
|
||||
} else {
|
||||
logMessage = "Attest payment Id failed with " + responseCode + " : "
|
||||
+ urlConnection.getResponseMessage();
|
||||
recordFailureAttempt();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
} finally {
|
||||
if (urlConnection != null) urlConnection.disconnect();
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(TAG, logMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
int responseCode = urlConnection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
solveCaptcha(captchaId, paymentId);
|
||||
logMessage = "Attest payment Id call is successful";
|
||||
} else {
|
||||
logMessage =
|
||||
"Attest payment Id failed with "
|
||||
+ responseCode
|
||||
+ " : "
|
||||
+ urlConnection.getResponseMessage();
|
||||
recordFailureAttempt();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
} finally {
|
||||
if (urlConnection != null) urlConnection.disconnect();
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(TAG, logMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void solveCaptcha(String captchaId, String paymentId) {
|
||||
PostTask.postTask(TaskTraits.BEST_EFFORT_MAY_BLOCK, () -> {
|
||||
HttpURLConnection urlConnection = null;
|
||||
String solveCaptchaUrl = BraveRewardsNativeWorker.getInstance().getCaptchaSolutionURL(
|
||||
paymentId, captchaId);
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(TAG, solveCaptchaUrl);
|
||||
}
|
||||
NetworkTrafficAnnotationTag annotation = NetworkTrafficAnnotationTag.createComplete(
|
||||
"Brave attestation api android",
|
||||
"semantics {"
|
||||
+ " sender: 'Brave Android app'"
|
||||
+ " description: "
|
||||
+ " 'This api solves captcha for the given payment ID'"
|
||||
+ " trigger: 'When attestation is successful with the give integrity token for provided payment id'"
|
||||
+ " data:"
|
||||
+ " 'payment id'"
|
||||
+ " destination: Brave grant endpoint"
|
||||
+ "}"
|
||||
+ "policy {"
|
||||
+ " cookies_allowed: NO"
|
||||
+ " policy_exception_justification: 'Not implemented.'"
|
||||
+ "}");
|
||||
PostTask.postTask(
|
||||
TaskTraits.BEST_EFFORT_MAY_BLOCK,
|
||||
() -> {
|
||||
HttpURLConnection urlConnection = null;
|
||||
String solveCaptchaUrl =
|
||||
BraveRewardsNativeWorker.getInstance()
|
||||
.getCaptchaSolutionURL(paymentId, captchaId);
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(TAG, solveCaptchaUrl);
|
||||
}
|
||||
NetworkTrafficAnnotationTag annotation =
|
||||
NetworkTrafficAnnotationTag.createComplete(
|
||||
"Brave attestation api android",
|
||||
"semantics { sender: 'Brave Android app' description: "
|
||||
+ " 'This api solves captcha for the given payment ID' "
|
||||
+ " trigger: 'When attestation is successful with the give"
|
||||
+ " integrity token for provided payment id' data: "
|
||||
+ " 'payment id' destination: Brave grant endpoint}policy"
|
||||
+ " { cookies_allowed: NO policy_exception_justification:"
|
||||
+ " 'Not implemented.'}");
|
||||
|
||||
String logMessage = "";
|
||||
try {
|
||||
URL url = new URL(String.format(solveCaptchaUrl, paymentId, captchaId));
|
||||
urlConnection = getUrlConnection(POST_METHOD, url, annotation);
|
||||
urlConnection.connect();
|
||||
String logMessage = "";
|
||||
try {
|
||||
URL url = new URL(String.format(solveCaptchaUrl, paymentId, captchaId));
|
||||
urlConnection = getUrlConnection(POST_METHOD, url, annotation);
|
||||
urlConnection.connect();
|
||||
|
||||
writeRequestOutput(getSolveCaptchaBody(paymentId), urlConnection);
|
||||
writeRequestOutput(getSolveCaptchaBody(paymentId), urlConnection);
|
||||
|
||||
int responseCode = urlConnection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
clearCaptchaPrefs();
|
||||
logMessage = "Captcha has been solved.";
|
||||
} else {
|
||||
recordFailureAttempt();
|
||||
logMessage = "Captcha solution failed with " + responseCode + " : "
|
||||
+ urlConnection.getResponseMessage();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
} finally {
|
||||
if (urlConnection != null) urlConnection.disconnect();
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(TAG, logMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
int responseCode = urlConnection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
clearCaptchaPrefs();
|
||||
logMessage = "Captcha has been solved.";
|
||||
} else {
|
||||
recordFailureAttempt();
|
||||
logMessage =
|
||||
"Captcha solution failed with "
|
||||
+ responseCode
|
||||
+ " : "
|
||||
+ urlConnection.getResponseMessage();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
} finally {
|
||||
if (urlConnection != null) urlConnection.disconnect();
|
||||
if (BraveQAPreferences.shouldVlogRewards()) {
|
||||
Log.e(TAG, logMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void clearCaptchaPrefs() {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS, 0);
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setString(BravePref.SCHEDULED_CAPTCHA_ID, "");
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setString(BravePref.SCHEDULED_CAPTCHA_PAYMENT_ID, "");
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.SCHEDULED_CAPTCHA_PAUSED, false);
|
||||
}
|
||||
|
||||
private static void recordFailureAttempt() {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS,
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS)
|
||||
+ 1);
|
||||
}
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ import android.widget.TextView;
|
||||
import org.chromium.base.ContextUtils;
|
||||
import org.chromium.base.Log;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.search_engines.R;
|
||||
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
|
||||
import org.chromium.components.search_engines.TemplateUrl;
|
||||
@@ -83,7 +84,7 @@ public class BraveSearchEngineAdapter extends SearchEngineAdapter {
|
||||
// overwrite.
|
||||
if (BraveSearchEnginePrefHelper.getInstance().getFetchSEFromNative()) {
|
||||
// Set it for normal tab only
|
||||
setDSEPrefs(dseTemplateUrl, Profile.getLastUsedRegularProfile());
|
||||
setDSEPrefs(dseTemplateUrl, ProfileManager.getLastUsedRegularProfile());
|
||||
BraveSearchEnginePrefHelper.getInstance().setFetchSEFromNative(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.chromium.chrome.browser.flags.ChromeFeatureList;
|
||||
import org.chromium.chrome.browser.night_mode.NightModeUtils;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.tasks.tab_management.BraveTabUiFeatureUtilities;
|
||||
import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration;
|
||||
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
|
||||
@@ -147,7 +147,7 @@ public class AppearancePreferences extends BravePreferenceFragment
|
||||
enableSpeedreader.setOnPreferenceChangeListener(this);
|
||||
if (enableSpeedreader instanceof ChromeSwitchPreference) {
|
||||
((ChromeSwitchPreference) enableSpeedreader)
|
||||
.setChecked(UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
.setChecked(UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.SPEEDREADER_PREF_ENABLED));
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public class AppearancePreferences extends BravePreferenceFragment
|
||||
ChromeSharedPreferences.getInstance()
|
||||
.writeBoolean(BravePreferenceKeys.BRAVE_TAB_GROUPS_ENABLED, (boolean) newValue);
|
||||
} else if (PREF_BRAVE_ENABLE_SPEEDREADER.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.SPEEDREADER_PREF_ENABLED, (boolean) newValue);
|
||||
shouldRelaunch = true;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.BraveRelaunchUtils;
|
||||
import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
|
||||
import org.chromium.components.browser_ui.settings.SettingsUtils;
|
||||
import org.chromium.components.user_prefs.UserPrefs;
|
||||
@@ -56,7 +56,7 @@ public class BackgroundImagesPreferences
|
||||
if (mShowBackgroundImagesPref != null) {
|
||||
mShowBackgroundImagesPref.setEnabled(true);
|
||||
mShowBackgroundImagesPref.setChecked(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE));
|
||||
mShowBackgroundImagesPref.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
@@ -64,10 +64,10 @@ public class BackgroundImagesPreferences
|
||||
(ChromeSwitchPreference) findPreference(PREF_SHOW_SPONSORED_IMAGES);
|
||||
if (mShowSponsoredImagesPref != null) {
|
||||
mShowSponsoredImagesPref.setEnabled(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE));
|
||||
mShowSponsoredImagesPref.setChecked(
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(
|
||||
BravePref.NEW_TAB_PAGE_SHOW_SPONSORED_IMAGES_BACKGROUND_IMAGE));
|
||||
mShowSponsoredImagesPref.setOnPreferenceChangeListener(this);
|
||||
@@ -107,9 +107,9 @@ public class BackgroundImagesPreferences
|
||||
|
||||
public static void setOnPreferenceValue(String preferenceName, boolean newValue) {
|
||||
if (PREF_SHOW_BACKGROUND_IMAGES.equals(preferenceName)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile()).setBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE, newValue);
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile()).setBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE, newValue);
|
||||
} else if (PREF_SHOW_SPONSORED_IMAGES.equals(preferenceName)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile()).setBoolean(BravePref.NEW_TAB_PAGE_SHOW_SPONSORED_IMAGES_BACKGROUND_IMAGE, (boolean)newValue);
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile()).setBoolean(BravePref.NEW_TAB_PAGE_SHOW_SPONSORED_IMAGES_BACKGROUND_IMAGE, (boolean)newValue);
|
||||
} else {
|
||||
SharedPreferences sharedPreferences = ContextUtils.getAppSharedPreferences();
|
||||
SharedPreferences.Editor sharedPreferencesEditor = sharedPreferences.edit();
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.chromium.chrome.browser.onboarding.OnboardingPrefManager;
|
||||
import org.chromium.chrome.browser.partnercustomizations.CloseBraveManager;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.privacy.settings.BravePrivacySettings;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.rate.BraveRateDialogFragment;
|
||||
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
|
||||
import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration;
|
||||
@@ -401,7 +401,7 @@ public class BraveMainPreferencesBase
|
||||
}
|
||||
|
||||
private void updateSearchEnginePreference() {
|
||||
if (!TemplateUrlServiceFactory.getForProfile(Profile.getLastUsedRegularProfile())
|
||||
if (!TemplateUrlServiceFactory.getForProfile(ProfileManager.getLastUsedRegularProfile())
|
||||
.isLoaded()) {
|
||||
ChromeBasePreference searchEnginePref =
|
||||
(ChromeBasePreference) findPreference(PREF_BRAVE_SEARCH_ENGINES);
|
||||
|
||||
+9
-9
@@ -22,7 +22,7 @@ import org.chromium.base.ContextUtils;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.preferences.website.BraveShieldsContentSettings;
|
||||
import org.chromium.chrome.browser.privacy.settings.BravePrivacySettings;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
|
||||
public class BravePreferenceDialogFragment extends PreferenceDialogFragmentCompat {
|
||||
public static final String TAG = "BravePreferenceDialogFragment";
|
||||
@@ -61,12 +61,12 @@ public class BravePreferenceDialogFragment extends PreferenceDialogFragmentCompa
|
||||
if (currentPreference.equals(BravePrivacySettings.PREF_FINGERPRINTING_PROTECTION)) {
|
||||
onPreferenceChangeListener.onPreferenceChange(dialogPreference,
|
||||
BraveShieldsContentSettings.getShieldsValue(
|
||||
Profile.getLastUsedRegularProfile(), "",
|
||||
ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING));
|
||||
} else if (currentPreference.equals(BravePrivacySettings.PREF_BLOCK_TRACKERS_ADS)) {
|
||||
onPreferenceChangeListener.onPreferenceChange(dialogPreference,
|
||||
BraveShieldsContentSettings.getShieldsValue(
|
||||
Profile.getLastUsedRegularProfile(), "",
|
||||
ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_TRACKERS));
|
||||
} else {
|
||||
onPreferenceChangeListener.onPreferenceChange(
|
||||
@@ -90,17 +90,17 @@ public class BravePreferenceDialogFragment extends PreferenceDialogFragmentCompa
|
||||
BravePrivacySettings.PREF_FINGERPRINTING_PROTECTION)) {
|
||||
if ((int) newValue == 0) {
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
Profile.getLastUsedRegularProfile(), "",
|
||||
ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING,
|
||||
BraveShieldsContentSettings.BLOCK_RESOURCE, false);
|
||||
} else if ((int) newValue == 1) {
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
Profile.getLastUsedRegularProfile(), "",
|
||||
ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING,
|
||||
BraveShieldsContentSettings.DEFAULT, false);
|
||||
} else {
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
Profile.getLastUsedRegularProfile(), "",
|
||||
ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING,
|
||||
BraveShieldsContentSettings.ALLOW_RESOURCE, false);
|
||||
}
|
||||
@@ -109,19 +109,19 @@ public class BravePreferenceDialogFragment extends PreferenceDialogFragmentCompa
|
||||
switch ((int) newValue) {
|
||||
case 0:
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
Profile.getLastUsedRegularProfile(), "",
|
||||
ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_TRACKERS,
|
||||
BraveShieldsContentSettings.BLOCK_RESOURCE, false);
|
||||
break;
|
||||
case 1:
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
Profile.getLastUsedRegularProfile(), "",
|
||||
ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_TRACKERS,
|
||||
BraveShieldsContentSettings.DEFAULT, false);
|
||||
break;
|
||||
default:
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
Profile.getLastUsedRegularProfile(), "",
|
||||
ProfileManager.getLastUsedRegularProfile(), "",
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_TRACKERS,
|
||||
BraveShieldsContentSettings.ALLOW_RESOURCE, false);
|
||||
break;
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.content.SharedPreferences;
|
||||
|
||||
import org.chromium.base.ContextUtils;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
|
||||
import org.chromium.chrome.browser.search_engines.settings.BraveSearchEngineAdapter;
|
||||
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
|
||||
@@ -27,7 +28,7 @@ public class BraveSearchEngineUtils {
|
||||
// so do it after TemplateUrlService is loaded to get it if it isn't loaded yet.
|
||||
// Init on regular profile only, leave the rest to listener, since
|
||||
// user shouldn't be able to go directly into a private tab on first run.
|
||||
final Profile profile = Profile.getLastUsedRegularProfile();
|
||||
final Profile profile = ProfileManager.getLastUsedRegularProfile();
|
||||
initializeBraveSearchEngineStates(profile);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ import androidx.preference.Preference;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.components.browser_ui.settings.SettingsUtils;
|
||||
|
||||
public class BraveSearchEnginesPreferences extends BravePreferenceFragment {
|
||||
@@ -32,7 +33,7 @@ public class BraveSearchEnginesPreferences extends BravePreferenceFragment {
|
||||
}
|
||||
|
||||
private void updateSearchEnginePreference() {
|
||||
Profile lastUsedRegularProfile = Profile.getLastUsedRegularProfile();
|
||||
Profile lastUsedRegularProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
Preference searchEnginePreference = findPreference(PREF_STANDARD_SEARCH_ENGINE);
|
||||
searchEnginePreference.setEnabled(true);
|
||||
searchEnginePreference.setSummary(
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.chromium.chrome.browser.BraveRewardsObserver;
|
||||
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.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.rewards.BraveRewardsPanel;
|
||||
import org.chromium.chrome.browser.settings.BravePreferenceFragment;
|
||||
import org.chromium.chrome.browser.util.BraveDbUtil;
|
||||
@@ -110,7 +110,7 @@ public class BraveQAPreferences extends BravePreferenceFragment
|
||||
if (mIsStagingServer != null) {
|
||||
mIsStagingServer.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
mIsStagingServer.setChecked(UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
mIsStagingServer.setChecked(UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.USE_REWARDS_STAGING_SERVER));
|
||||
|
||||
mIsSyncStagingServer =
|
||||
@@ -389,7 +389,7 @@ public class BraveQAPreferences extends BravePreferenceFragment
|
||||
sharedPreferencesEditor.apply();
|
||||
|
||||
BravePrefServiceBridge.getInstance().setSafetynetCheckFailed(false);
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setBoolean(BravePref.USE_REWARDS_STAGING_SERVER, mUseRewardsStagingServer);
|
||||
BraveRewardsHelper.setRewardsEnvChange(true);
|
||||
|
||||
|
||||
+4
-3
@@ -18,6 +18,7 @@ import org.chromium.chrome.browser.night_mode.settings.RadioButtonGroupThemePref
|
||||
import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.components.browser_ui.widget.RadioButtonWithDescription;
|
||||
import org.chromium.components.user_prefs.UserPrefs;
|
||||
|
||||
@@ -29,7 +30,7 @@ public class BraveRadioButtonGroupCustomHomepageThemePreference extends RadioBut
|
||||
|
||||
public BraveRadioButtonGroupCustomHomepageThemePreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
Profile mProfile = Profile.getLastUsedRegularProfile();
|
||||
Profile mProfile = ProfileManager.getLastUsedRegularProfile();
|
||||
mNTPBackgroundImagesBridge = NTPBackgroundImagesBridge.getInstance(mProfile);
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ public class BraveRadioButtonGroupCustomHomepageThemePreference extends RadioBut
|
||||
RadioButtonWithDescription refView = (RadioButtonWithDescription)holder.findViewById(R.id.dark);
|
||||
if (mNTPBackgroundImagesBridge != null && mNTPBackgroundImagesBridge.isSuperReferral()) {
|
||||
refView.setPrimaryText(mNTPBackgroundImagesBridge.getSuperReferralThemeName());
|
||||
if(UserPrefs.get(Profile.getLastUsedRegularProfile()).getInteger(BravePref.NEW_TAB_PAGE_SUPER_REFERRAL_THEMES_OPTION) == 1 ? true : false) {
|
||||
if(UserPrefs.get(ProfileManager.getLastUsedRegularProfile()).getInteger(BravePref.NEW_TAB_PAGE_SUPER_REFERRAL_THEMES_OPTION) == 1 ? true : false) {
|
||||
refView.setChecked(true);
|
||||
braveDefaultView.setChecked(false);
|
||||
} else {
|
||||
@@ -58,7 +59,7 @@ public class BraveRadioButtonGroupCustomHomepageThemePreference extends RadioBut
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
super.onCheckedChanged(group, checkedId);
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile()).setInteger(BravePref.NEW_TAB_PAGE_SUPER_REFERRAL_THEMES_OPTION, checkedId == R.id.light ? 0 : 1 );
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile()).setInteger(BravePref.NEW_TAB_PAGE_SUPER_REFERRAL_THEMES_OPTION, checkedId == R.id.light ? 0 : 1 );
|
||||
BraveRelaunchUtils.askForRelaunch(getContext());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.chromium.base.supplier.Supplier;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.flags.ChromeFeatureList;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.tab.EmptyTabObserver;
|
||||
import org.chromium.chrome.browser.tab.Tab;
|
||||
import org.chromium.chrome.browser.tab.TabSelectionType;
|
||||
@@ -174,7 +174,7 @@ public class BraveSpeedReaderManager extends EmptyTabObserver implements UserDat
|
||||
boolean isFeatureEnabled = ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SPEEDREADER);
|
||||
if (!isFeatureEnabled) return false;
|
||||
|
||||
boolean isPrefEnabled = UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
boolean isPrefEnabled = UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.SPEEDREADER_PREF_ENABLED);
|
||||
return isPrefEnabled;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class BraveTileView extends TileView {
|
||||
super.setTitle(title, titleLines);
|
||||
if (ProfileManager.isInitialized()) {
|
||||
TextView mTitleView = findViewById(R.id.tile_view_title);
|
||||
if (UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
if (UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE)) {
|
||||
mTitleView.setTextColor(
|
||||
getContext().getColor(R.color.brave_state_time_count_color));
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.chromium.chrome.browser.new_tab_url.DseNewTabUrlManager;
|
||||
import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge;
|
||||
import org.chromium.chrome.browser.ntp_background_images.util.SponsoredImageUtil;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.profiles.ProfileProvider;
|
||||
import org.chromium.chrome.browser.tab.Tab;
|
||||
import org.chromium.chrome.browser.tab.TabDelegateFactory;
|
||||
@@ -65,7 +65,7 @@ public class BraveTabCreator extends ChromeTabCreator {
|
||||
if (chromeTabbedActivity != null && Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
|
||||
TabModel tabModel = chromeTabbedActivity.getCurrentTabModel();
|
||||
if (tabModel.getCount() >= SponsoredImageUtil.MAX_TABS
|
||||
&& UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
&& UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.getBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE)) {
|
||||
Tab tab = BraveActivity.class.cast(chromeTabbedActivity)
|
||||
.selectExistingTab(UrlConstants.NTP_URL);
|
||||
@@ -90,7 +90,7 @@ public class BraveTabCreator extends ChromeTabCreator {
|
||||
}
|
||||
|
||||
private void registerPageView() {
|
||||
NTPBackgroundImagesBridge.getInstance(Profile.getLastUsedRegularProfile())
|
||||
NTPBackgroundImagesBridge.getInstance(ProfileManager.getLastUsedRegularProfile())
|
||||
.registerPageView();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ package org.chromium.chrome.browser.vpn.utils;
|
||||
import org.chromium.base.ContextUtils;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.vpn.models.BraveVpnPrefModel;
|
||||
import org.chromium.components.user_prefs.UserPrefs;
|
||||
|
||||
@@ -136,9 +136,9 @@ public class BraveVpnPrefUtils {
|
||||
|
||||
public static void setPurchaseToken(String value) {
|
||||
ChromeSharedPreferences.getInstance().writeString(PREF_BRAVE_VPN_PURCHASE_TOKEN, value);
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setString(BravePref.BRAVE_VPN_PURCHASE_TOKEN_ANDROID, value);
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setString(BravePref.BRAVE_VPN_PACKAGE_ANDROID,
|
||||
ContextUtils.getApplicationContext().getPackageName());
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class BraveVpnPrefUtils {
|
||||
|
||||
public static void setProductId(String value) {
|
||||
ChromeSharedPreferences.getInstance().writeString(PREF_BRAVE_VPN_PRODUCT_ID, value);
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
|
||||
.setString(BravePref.BRAVE_VPN_PRODUCT_ID_ANDROID, value);
|
||||
}
|
||||
|
||||
|
||||
+8
-7
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
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/.
|
||||
*/
|
||||
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.widget.quickactionsearchandbookmark;
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
|
||||
import org.chromium.chrome.browser.init.EmptyBrowserParts;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.profiles.ProfileManager;
|
||||
import org.chromium.chrome.browser.searchwidget.SearchActivity;
|
||||
import org.chromium.chrome.browser.settings.BraveSearchEngineUtils;
|
||||
import org.chromium.chrome.browser.suggestions.tile.Tile;
|
||||
@@ -289,7 +290,7 @@ public class QuickActionSearchAndBookmarkWidgetProvider extends AppWidgetProvide
|
||||
}
|
||||
|
||||
private static void setDefaultSearchEngineString(RemoteViews views) {
|
||||
final Profile profile = Profile.getLastUsedRegularProfile();
|
||||
final Profile profile = ProfileManager.getLastUsedRegularProfile();
|
||||
TemplateUrl templateUrl = BraveSearchEngineUtils.getTemplateUrlByShortName(
|
||||
profile, BraveSearchEngineUtils.getDSEShortName(profile, false));
|
||||
if (templateUrl != null) {
|
||||
@@ -341,7 +342,7 @@ public class QuickActionSearchAndBookmarkWidgetProvider extends AppWidgetProvide
|
||||
}
|
||||
|
||||
private static void fetchGurlIcon(final int imageViewId, GURL gurl) {
|
||||
LargeIconBridge largeIconBridge = new LargeIconBridge(Profile.getLastUsedRegularProfile());
|
||||
LargeIconBridge largeIconBridge = new LargeIconBridge(ProfileManager.getLastUsedRegularProfile());
|
||||
LargeIconCallback callback = new LargeIconCallback() {
|
||||
@Override
|
||||
public void onLargeIconAvailable(Bitmap icon, int fallbackColor,
|
||||
|
||||
Reference in New Issue
Block a user