[cr137][Android] Temporary fix for Utils.getProfile
This function should be removed and proper profile should be passed https://github.com/brave/brave-browser/issues/45937
This commit is contained in:
@@ -1104,6 +1104,7 @@ public class Utils {
|
||||
return AndroidUtils.formatHTML(geteTldHtmlString(originInfo));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Profile getProfile(boolean isIncognito) {
|
||||
ChromeActivity chromeActivity = null;
|
||||
try {
|
||||
@@ -1115,23 +1116,32 @@ public class Utils {
|
||||
chromeActivity = BraveActivity.getChromeTabbedActivity();
|
||||
}
|
||||
if (chromeActivity == null) {
|
||||
return ProfileManager.getLastUsedRegularProfile(); // Last resort
|
||||
return getLastUsedProfile(isIncognito); // Last resort
|
||||
}
|
||||
|
||||
ObservableSupplier<TabModelSelector> supplier =
|
||||
chromeActivity.getTabModelSelectorSupplier();
|
||||
TabModelSelector selector = supplier.get();
|
||||
if (selector == null) {
|
||||
return ProfileManager.getLastUsedRegularProfile();
|
||||
return getLastUsedProfile(isIncognito);
|
||||
}
|
||||
|
||||
Profile profile = selector.getModel(isIncognito).getProfile();
|
||||
if (profile == null) {
|
||||
return ProfileManager.getLastUsedRegularProfile();
|
||||
return getLastUsedProfile(isIncognito);
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Profile getLastUsedProfile(boolean isIncognito) {
|
||||
if (!isIncognito) {
|
||||
return ProfileManager.getLastUsedRegularProfile();
|
||||
} else {
|
||||
return ProfileManager.getLastUsedRegularProfile().getPrimaryOtrProfile(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatErc721TokenTitle(String title, String id) {
|
||||
if (id.isEmpty() || id.equals("0")) {
|
||||
return title;
|
||||
|
||||
Reference in New Issue
Block a user