Sync of default search engine between Android and Desktop

Android uses native code to save DSE for normal tab
This commit is contained in:
AlexeyBarabash
2022-08-12 15:35:32 +03:00
parent 1d76e1d38b
commit 362af0ade3
@@ -37,6 +37,12 @@ public class BraveSearchEngineAdapter extends SearchEngineAdapter {
}
static public void updateActiveDSE(boolean isPrivate) {
// For the regular tab, trust the native Chromium's TemplateUrlService and
// don't overwrite with our value to make sync work
if (isPrivate == false) {
return;
}
TemplateUrl templateUrl = getTemplateUrlByShortName(getDSEShortName(isPrivate));
if (templateUrl == null) {
return;
@@ -51,6 +57,12 @@ public class BraveSearchEngineAdapter extends SearchEngineAdapter {
TemplateUrlServiceFactory.get().getDefaultSearchEngineTemplateUrl();
if (dseTemplateUrl != null) defaultSearchEngineName = dseTemplateUrl.getShortName();
if (isPrivate == false) {
// For the regular tab, rely on the value from the native Chromium's
// TemplateUrlService to make sync work
return defaultSearchEngineName;
}
// TODO(sergz): A check, do we need to fetch a default SE from native and avoid
// overwrite.
if (BraveSearchEnginePrefHelper.getInstance().getFetchSEFromNative()) {