Add an always-incognito mode: saves search engines in incognito mode when the user decides to save the history (#1981)

This commit is contained in:
Carmelo Messina
2025-04-16 21:21:24 +02:00
parent 74634fab70
commit 823a8fd176
@@ -72,6 +72,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
.../browser/toolbar/LocationBarModel.java | 5 +-
chrome/browser/ui/messages/android/BUILD.gn | 1 +
.../snackbar/INeedSnackbarManager.java | 28 +++
.../search_engine_tab_helper.cc | 6 +
chrome/common/pref_names.h | 6 +
.../browser/content_settings_pref_provider.cc | 6 +-
.../browser/content_settings_pref_provider.h | 2 +
@@ -85,7 +86,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
.../add-an-always-incognito-mode.inc | 1 +
.../add-an-always-incognito-mode.inc | 3 +
.../add-an-always-incognito-mode.inc | 1 +
66 files changed, 791 insertions(+), 112 deletions(-)
67 files changed, 797 insertions(+), 112 deletions(-)
create mode 100644 chrome/android/java/res/xml/incognito_preferences.xml
create mode 100644 chrome/android/java/src/org/chromium/chrome/browser/AlwaysIncognitoLinkInterceptor.java
create mode 100644 chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/IncognitoSettings.java
@@ -2031,6 +2032,29 @@ new file mode 100644
+public interface INeedSnackbarManager {
+ void setSnackbarManagerSupplier(Supplier<SnackbarManager> manager);
+}
diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
--- a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
+++ b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/search_engines/template_url_fetcher_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/search_engines/edit_search_engine_controller.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_fetcher.h"
@@ -165,6 +166,11 @@ void SearchEngineTabHelper::PageHasOpenSearchDescriptionDocument(
// Download the OpenSearch description document. If this is successful, a
// new keyword will be created when done.
+#if BUILDFLAG(IS_ANDROID)
+ if (profile->GetOriginalProfile()->GetPrefs()->GetBoolean(prefs::kIncognitoTabHistoryEnabled)) {
+ is_off_the_record = false;
+ }
+#endif
TemplateURLFetcherFactory::GetForProfile(profile)->ScheduleDownload(
keyword, osdd_url, entry->GetFavicon().url,
frame->GetLastCommittedOrigin(), url_loader_factory.get(),
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h