Added preference in native

This commit is contained in:
Carmelo Messina 2022-02-23 13:30:45 +01:00 committed by Yifeng Wu
parent e271710ff0
commit df36b9d9f1
3 changed files with 381 additions and 258 deletions

View file

@ -6,28 +6,35 @@ More specifically, add a preference that causes all new tabs and all
clicked links to launch as incognito.
Make sure initial incognito status is correctly recognized.
Enable incognito custom tabs and fix crashes for incognito/custom tab intents (credits to @uazo)
A flag for native management has been inserted
---
chrome/android/chrome_java_sources.gni | 1 +
.../java/res/xml/privacy_preferences.xml | 5 ++
.../AlwaysIncognitoLinkInterceptor.java | 80 +++++++++++++++++++
.../chrome/browser/ChromeTabbedActivity.java | 6 +-
.../chrome/browser/app/ChromeActivity.java | 4 +
.../AppMenuPropertiesDelegateImpl.java | 6 ++
.../ChromeContextMenuPopulator.java | 8 +-
.../CustomTabActivityLifecycleUmaTracker.java | 25 ------
.../AlwaysIncognitoLinkInterceptor.java | 52 +++++++++++++++++++
.../chrome/browser/ChromeTabbedActivity.java | 6 ++-
.../chrome/browser/app/ChromeActivity.java | 4 ++
.../AppMenuPropertiesDelegateImpl.java | 8 +++
.../ChromeContextMenuPopulator.java | 7 ++-
.../CustomTabActivityLifecycleUmaTracker.java | 25 ---------
.../CustomTabIntentDataProvider.java | 5 +-
.../browser/init/StartupTabPreloader.java | 14 +++-
.../privacy/settings/PrivacySettings.java | 37 ++++++++-
.../browser/settings/SettingsActivity.java | 4 +
.../tabbed_mode/TabbedRootUiCoordinator.java | 6 +-
.../browser/tabmodel/ChromeTabCreator.java | 16 +++-
.../browser/tabmodel/TabPersistentStore.java | 10 +++
.../webapps/WebappIntentDataProvider.java | 14 ++++
.../browser/init/StartupTabPreloader.java | 14 +++--
.../privacy/settings/PrivacySettings.java | 39 +++++++++++++-
.../browser/settings/SettingsActivity.java | 4 ++
.../tabbed_mode/TabbedRootUiCoordinator.java | 5 +-
.../browser/tabmodel/ChromeTabCreator.java | 5 +-
.../tabmodel/TabModelSelectorImpl.java | 3 ++
.../browser/tabmodel/TabPersistentStore.java | 10 ++++
.../webapps/WebappIntentDataProvider.java | 14 +++++
.../chrome_autocomplete_provider_client.cc | 3 ++
.../host_content_settings_map_factory.cc | 16 +++++-
.../flags/android/chrome_feature_list.cc | 2 +-
.../strings/android_chrome_strings.grd | 13 +++
chrome/browser/prefs/browser_prefs.cc | 3 ++
.../strings/android_chrome_strings.grd | 13 +++++
chrome/browser/ui/messages/android/BUILD.gn | 1 +
.../snackbar/INeedSnackbarManager.java | 27 +++++++
20 files changed, 248 insertions(+), 36 deletions(-)
.../snackbar/INeedSnackbarManager.java | 27 ++++++++++
chrome/common/pref_names.cc | 4 ++
chrome/common/pref_names.h | 5 ++
26 files changed, 244 insertions(+), 37 deletions(-)
create mode 100644 chrome/android/java/src/org/chromium/chrome/browser/AlwaysIncognitoLinkInterceptor.java
create mode 100644 chrome/browser/ui/messages/android/java/src/org/chromium/chrome/browser/ui/messages/snackbar/INeedSnackbarManager.java
@ -61,7 +68,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/AlwaysIncognito
new file mode 100644
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/AlwaysIncognitoLinkInterceptor.java
@@ -0,0 +1,80 @@
@@ -0,0 +1,52 @@
+/* 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 http://mozilla.org/MPL/2.0/. */
@ -69,76 +76,48 @@ new file mode 100644
+package org.chromium.chrome.browser;
+
+import android.content.SharedPreferences;
+import org.chromium.base.ContextUtils;
+
+import org.chromium.chrome.browser.tab.EmptyTabObserver;
+import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.chrome.browser.tab.TabImpl;
+import org.chromium.chrome.browser.tabmodel.TabCreatorManager;
+import org.chromium.chrome.browser.tab.TabLaunchType;
+import org.chromium.chrome.browser.tabmodel.TabModel;
+import org.chromium.content_public.browser.LoadUrlParams;
+import org.chromium.url.GURL;
+import org.chromium.components.user_prefs.UserPrefs;
+import org.chromium.components.prefs.PrefService;
+import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.chrome.browser.preferences.Pref;
+import org.chromium.base.Log;
+
+import androidx.annotation.Nullable;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+/**
+ * A {@link TabObserver} that implements the always-incognito preference behavior for links. When the preference is set
+ * to true, it intercepts links opened within observed {@link Tab}s and opens them in new incognito <code>Tab</code>s instead.
+ * A {@link TabObserver} that implements the always-incognito preference behavior for links.
+ */
+public class AlwaysIncognitoLinkInterceptor extends EmptyTabObserver {
+public class AlwaysIncognitoLinkInterceptor {
+
+ public static final String PREF_ALWAYS_INCOGNITO = "always_incognito";
+
+ private final SharedPreferences alwaysIncognitoContainer;
+ private final Map<Tab, String> lastUrls;
+ private final Set<Tab> revertingTabs;
+ private static @Nullable Boolean cachedIsAlwaysIncognito = null;
+
+ public AlwaysIncognitoLinkInterceptor(final SharedPreferences alwaysIncognitoContainer) {
+
+ assert alwaysIncognitoContainer != null;
+
+ this.alwaysIncognitoContainer = alwaysIncognitoContainer;
+ lastUrls = new HashMap<Tab, String>();
+ revertingTabs = new HashSet<Tab>();
+ public static boolean isAlwaysIncognito() {
+ if (cachedIsAlwaysIncognito != null) return cachedIsAlwaysIncognito;
+ cachedIsAlwaysIncognito = ContextUtils.getAppSharedPreferences()
+ .getBoolean(PREF_ALWAYS_INCOGNITO, false);
+ return cachedIsAlwaysIncognito;
+ }
+
+ @Override
+ public void onDestroyed(final Tab tab)
+ {
+ lastUrls.remove(tab);
+ revertingTabs.remove(tab);
+ public static void setAlwaysIncognito(boolean enabled) {
+ UserPrefs.get(Profile.getLastUsedRegularProfile())
+ .setBoolean(Pref.ALWAYS_INCOGNITO_ENABLED, enabled);
+
+ SharedPreferences.Editor sharedPreferenceEditor = ContextUtils.getAppSharedPreferences().edit();
+ sharedPreferenceEditor.putBoolean("always_incognito", enabled);
+ sharedPreferenceEditor.apply();
+ }
+
+ @Override
+ public void onUpdateUrl(Tab tab, GURL gurl) {
+
+ if (tab == null) return;
+ if (gurl == null) return;
+ if (tab.isIncognito()) return;
+ if (alwaysIncognitoContainer == null) return;
+
+ String spec = gurl.getValidSpecOrEmpty();
+ if (spec == null) return;
+
+ final String lastUrl = lastUrls.put(tab, spec);
+
+ if (!alwaysIncognitoContainer.getBoolean(PREF_ALWAYS_INCOGNITO, false)) return;
+ if (revertingTabs.contains(tab)) {
+ revertingTabs.remove(tab);
+ return;
+ }
+
+ ((ChromeTabbedActivity)tab.getWindowAndroid().getActivity().get())
+ .getTabCreator(true)
+ .createNewTab(new LoadUrlParams(spec), TabLaunchType.FROM_LINK, tab);
+
+ if ((spec.equals(lastUrl)) || (!tab.canGoBack())) {
+ // this call was triggered by a reload
+ } else {
+ revertingTabs.add(tab);
+ tab.goBack();
+ public static void migrateSettingToNative() {
+ if (isAlwaysIncognito()) {
+ PrefService prefService = UserPrefs.get(Profile.getLastUsedRegularProfile());
+ if(!prefService.getBoolean(Pref.ALWAYS_INCOGNITO_ENABLED)) {
+ Log.i("BROMITE", "Migration: always incognito pref from java to native");
+ prefService.setBoolean(Pref.ALWAYS_INCOGNITO_ENABLED, true);
+ }
+ }
+ }
+}
@ -153,13 +132,13 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedAct
import org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate;
import org.chromium.chrome.browser.IntentHandler.TabOpenType;
import org.chromium.chrome.browser.accessibility_tab_switcher.OverviewListLayout;
@@ -1760,8 +1761,9 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
@@ -1780,8 +1781,9 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
Bundle savedInstanceState = getSavedInstanceState();
// We determine the model as soon as possible so every systems get initialized coherently.
- boolean startIncognito = savedInstanceState != null
- && savedInstanceState.getBoolean(IS_INCOGNITO_SELECTED, false);
+ boolean startIncognito = ContextUtils.getAppSharedPreferences().getBoolean(AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false)
+ boolean startIncognito = AlwaysIncognitoLinkInterceptor.isAlwaysIncognito()
+ || (savedInstanceState != null
+ && savedInstanceState.getBoolean(IS_INCOGNITO_SELECTED, false));
@ -168,7 +147,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedAct
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java
@@ -101,6 +101,7 @@ import org.chromium.chrome.browser.contextualsearch.ContextualSearchFieldTrial;
@@ -102,6 +102,7 @@ import org.chromium.chrome.browser.contextualsearch.ContextualSearchFieldTrial;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager.ContextualSearchTabPromotionDelegate;
import org.chromium.chrome.browser.dependency_injection.ChromeActivityCommonsModule;
@ -176,11 +155,11 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActiv
import org.chromium.chrome.browser.dependency_injection.ChromeActivityComponent;
import org.chromium.chrome.browser.dependency_injection.ModuleFactoryOverrides;
import org.chromium.chrome.browser.device.DeviceClassManager;
@@ -1910,6 +1911,9 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
@@ -1952,6 +1953,9 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
throw new IllegalStateException(
"Attempting to access TabCreator before initialization");
}
+ if (ContextUtils.getAppSharedPreferences().getBoolean(AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false)) {
+ if (AlwaysIncognitoLinkInterceptor.isAlwaysIncognito()) {
+ incognito = true;
+ }
return mTabCreatorManagerSupplier.get().getTabCreator(incognito);
@ -189,11 +168,20 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActiv
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java
@@ -515,6 +515,12 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
@@ -34,6 +34,7 @@ import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.OneshotSupplier;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
import org.chromium.chrome.browser.banners.AppMenuVerbiage;
import org.chromium.chrome.browser.bookmarks.BookmarkBridge;
import org.chromium.chrome.browser.bookmarks.BookmarkFeatures;
@@ -524,6 +525,13 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
}
private void prepareCommonMenuItems(Menu menu, @MenuGroup int menuGroup, boolean isIncognito) {
+ if (ContextUtils.getAppSharedPreferences().getBoolean("always_incognito", false)) {
+ boolean always_incognito = AlwaysIncognitoLinkInterceptor.isAlwaysIncognito();
+ if (always_incognito) {
+ final MenuItem newTabOption = menu.findItem(R.id.new_tab_menu_id);
+ if (newTabOption != null)
+ newTabOption.setVisible(false);
@ -213,18 +201,17 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/Chr
import org.chromium.chrome.browser.compositor.bottombar.ephemeraltab.EphemeralTabCoordinator;
import org.chromium.chrome.browser.contextmenu.ChromeContextMenuItem.Item;
import org.chromium.chrome.browser.contextmenu.ContextMenuCoordinator.ListItemType;
@@ -408,6 +409,10 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
@@ -408,6 +409,9 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
boolean hasSaveImage = false;
mShowEphemeralTabNewLabel = null;
+ boolean always_incognito =
+ ContextUtils.getAppSharedPreferences().getBoolean(
+ AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false);
+ AlwaysIncognitoLinkInterceptor.isAlwaysIncognito();
+
List<Pair<Integer, ModelList>> groupedItems = new ArrayList<>();
if (mParams.isAnchor()) {
@@ -426,6 +431,7 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
@@ -426,6 +430,7 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
linkGroup.add(createListItem(Item.OPEN_IN_NEW_TAB_IN_GROUP));
}
}
@ -232,7 +219,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/Chr
if (!mItemDelegate.isIncognito() && mItemDelegate.isIncognitoSupported()) {
linkGroup.add(createListItem(Item.OPEN_IN_INCOGNITO_TAB));
}
@@ -450,7 +456,7 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
@@ -450,7 +455,7 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
}
}
if (FirstRunStatus.getFirstRunFlowComplete()) {
@ -294,16 +281,16 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/Cust
@Override
public boolean isIncognito() {
- return false;
+ return ContextUtils.getAppSharedPreferences().getBoolean(AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false);
+ return AlwaysIncognitoLinkInterceptor.isAlwaysIncognito();
}
@Nullable
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/StartupTabPreloader.java b/chrome/android/java/src/org/chromium/chrome/browser/init/StartupTabPreloader.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/init/StartupTabPreloader.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/init/StartupTabPreloader.java
@@ -38,6 +38,9 @@ import org.chromium.network.mojom.ReferrerPolicy;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.url.GURL;
@@ -42,6 +42,9 @@ import org.chromium.url.GURL;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import org.chromium.base.ContextUtils;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
@ -311,11 +298,11 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/StartupTab
/**
* This class attempts to preload the tab if the url is known from the intent when the profile
* is created. This is done to improve startup latency.
@@ -349,17 +352,22 @@ public class StartupTabPreloader implements ProfileManager.Observer, DestroyObse
@@ -446,17 +449,22 @@ public class StartupTabPreloader implements ProfileManager.Observer, DestroyObse
Intent intent = mIntentSupplier.get();
GURL url = UrlFormatter.fixupUrl(getUrlFromIntent(intent));
+ boolean isIncognito = ContextUtils.getAppSharedPreferences().getBoolean(AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false);
+ boolean isIncognito = AlwaysIncognitoLinkInterceptor.isAlwaysIncognito();
+
+ Profile profile = Profile.getLastUsedRegularProfile();
ChromeTabCreator chromeTabCreator =
@ -340,18 +327,19 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/StartupTab
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java b/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
@@ -27,6 +27,10 @@ import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsFragmen
import org.chromium.chrome.browser.profiles.Profile;
@@ -29,6 +29,11 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate;
import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
import org.chromium.chrome.browser.signin.services.IdentityServicesProvider;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
+import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
+import org.chromium.chrome.browser.ui.messages.snackbar.INeedSnackbarManager;
+import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar;
+import org.chromium.chrome.browser.ApplicationLifetime;
import org.chromium.chrome.browser.signin.services.IdentityServicesProvider;
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
import org.chromium.components.browser_ui.settings.ManagedPreferenceDelegate;
@@ -42,7 +46,12 @@ import org.chromium.ui.text.SpanApplier;
import org.chromium.components.browser_ui.settings.SettingsLauncher;
@@ -43,7 +48,12 @@ import org.chromium.ui.text.SpanApplier;
* Fragment to keep track of the all the privacy related preferences.
*/
public class PrivacySettings
@ -363,9 +351,9 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/setting
+
+ private static final String PREF_ALWAYS_INCOGNITO = "always_incognito";
private static final String PREF_CAN_MAKE_PAYMENT = "can_make_payment";
private static final String PREF_NETWORK_PREDICTIONS = "preload_pages";
private static final String PREF_PRELOAD_PAGES = "preload_pages";
private static final String PREF_HTTPS_FIRST_MODE = "https_first_mode";
@@ -99,6 +108,25 @@ public class PrivacySettings
@@ -100,6 +110,25 @@ public class PrivacySettings
(ChromeSwitchPreference) findPreference(PREF_CAN_MAKE_PAYMENT);
canMakePaymentPref.setOnPreferenceChangeListener(this);
@ -388,20 +376,21 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/setting
+ /*actionData*/null)
+ .setDuration(/*durationMs*/70000);
+
ChromeSwitchPreference networkPredictionPref =
(ChromeSwitchPreference) findPreference(PREF_NETWORK_PREDICTIONS);
networkPredictionPref.setChecked(
@@ -130,6 +158,9 @@ public class PrivacySettings
} else if (PREF_NETWORK_PREDICTIONS.equals(key)) {
PrivacyPreferencesManagerImpl.getInstance().setNetworkPredictionEnabled(
(boolean) newValue);
Preference preloadPagesPreference = findPreference(PREF_PRELOAD_PAGES);
preloadPagesPreference.setSummary(
PreloadPagesSettingsFragment.getPreloadPagesSummaryString(getContext()));
@@ -125,6 +154,10 @@ public class PrivacySettings
if (PREF_CAN_MAKE_PAYMENT.equals(key)) {
UserPrefs.get(Profile.getLastUsedRegularProfile())
.setBoolean(Pref.CAN_MAKE_PAYMENT_ENABLED, (boolean) newValue);
+ } else if (PREF_ALWAYS_INCOGNITO.equals(key)) {
+ AlwaysIncognitoLinkInterceptor.setAlwaysIncognito((boolean) newValue);
+ if (!mSnackbarManager.isShowing())
+ mSnackbarManager.showSnackbar(mSnackbar);
} else if (PREF_HTTPS_FIRST_MODE.equals(key)) {
UserPrefs.get(Profile.getLastUsedRegularProfile())
.setBoolean(Pref.HTTPS_ONLY_MODE_ENABLED, (boolean) newValue);
@@ -208,4 +239,8 @@ public class PrivacySettings
@@ -201,4 +234,8 @@ public class PrivacySettings
}
return false;
}
@ -420,8 +409,8 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/Settin
+import org.chromium.chrome.browser.ui.messages.snackbar.INeedSnackbarManager;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager.SnackbarManageable;
import org.chromium.components.browser_ui.settings.FragmentSettingsLauncher;
@@ -171,6 +172,9 @@ public class SettingsActivity extends ChromeBaseAppCompatActivity
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
@@ -206,6 +207,9 @@ public class SettingsActivity extends ChromeBaseAppCompatActivity
.getSiteSettingsDelegate());
delegate.setSnackbarManager(mSnackbarManager);
}
@ -434,7 +423,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/Settin
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java
@@ -120,6 +120,8 @@ import org.chromium.ui.base.DeviceFormFactor;
@@ -119,6 +119,8 @@ import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.base.IntentRequestTracker;
import org.chromium.ui.modaldialog.ModalDialogManager;
import org.chromium.ui.util.TokenHolder;
@ -443,12 +432,11 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/Tab
/**
* A {@link RootUiCoordinator} variant that controls tabbed-mode specific UI.
@@ -494,11 +496,13 @@ public class TabbedRootUiCoordinator extends RootUiCoordinator {
@@ -489,11 +491,12 @@ public class TabbedRootUiCoordinator extends RootUiCoordinator {
// TODO(twellington): Supply TabModelSelector as well and move initialization earlier.
if (DeviceFormFactor.isNonMultiDisplayContextOnTablet(mActivity)) {
+ boolean tabModel = ContextUtils.getAppSharedPreferences().getBoolean(
+ AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false);
+ boolean tabModel = AlwaysIncognitoLinkInterceptor.isAlwaysIncognito();
AppMenuHandler appMenuHandler =
mAppMenuCoordinator == null ? null : mAppMenuCoordinator.getAppMenuHandler();
mEmptyBackgroundViewWrapper = new EmptyBackgroundViewWrapper(
@ -472,44 +460,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/Chrome
/**
* This class creates various kinds of new tabs and adds them to the right {@link TabModel}.
*/
@@ -74,6 +78,7 @@ public class ChromeTabCreator extends TabCreator {
private final Activity mActivity;
private final StartupTabPreloader mStartupTabPreloader;
private final boolean mIncognito;
+ private final TabObserver mExtraLogic;
private WindowAndroid mNativeWindow;
private TabModel mTabModel;
@@ -96,6 +101,10 @@ public class ChromeTabCreator extends TabCreator {
mNativeWindow = nativeWindow;
mTabDelegateFactorySupplier = tabDelegateFactory;
mIncognito = incognito;
+ if (!mIncognito)
+ mExtraLogic = new AlwaysIncognitoLinkInterceptor(ContextUtils.getAppSharedPreferences());
+ else
+ mExtraLogic = null;
mOverviewNTPCreator = overviewNTPCreator;
mAsyncTabParamsManager = asyncTabParamsManager;
mTabModelSelectorSupplier = tabModelSelectorSupplier;
@@ -259,6 +268,8 @@ public class ChromeTabCreator extends TabCreator {
if (creationState == TabCreationState.LIVE_IN_FOREGROUND && !openInForeground) {
creationState = TabCreationState.LIVE_IN_BACKGROUND;
}
+ if (mExtraLogic != null)
+ tab.addObserver(mExtraLogic);
mTabModel.addTab(tab, position, type, creationState);
return tab;
} finally {
@@ -293,6 +304,8 @@ public class ChromeTabCreator extends TabCreator {
@TabCreationState
int creationState = openInForeground ? TabCreationState.LIVE_IN_FOREGROUND
: TabCreationState.LIVE_IN_BACKGROUND;
+ if (mExtraLogic != null)
+ tab.addObserver(mExtraLogic);
mTabModel.addTab(tab, position, type, creationState);
return true;
}
@@ -333,7 +346,6 @@ public class ChromeTabCreator extends TabCreator {
@@ -333,7 +337,6 @@ public class ChromeTabCreator extends TabCreator {
// TODO(crbug.com/1081924): Clean up the launches from SearchActivity/Chrome.
public Tab launchUrlFromExternalApp(
LoadUrlParams loadUrlParams, String appId, boolean forceNewTab, Intent intent) {
@ -517,15 +468,26 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/Chrome
// Don't re-use tabs for intents from Chrome. Note that this can be spoofed so shouldn't be
// relied on for anything security sensitive.
boolean isLaunchedFromChrome = TextUtils.equals(appId, mActivity.getPackageName());
@@ -428,6 +440,8 @@ public class ChromeTabCreator extends TabCreator {
.setSerializedCriticalPersistedTabData(serializedCriticalPersistedTabData)
.build();
}
+ if (mExtraLogic != null)
+ tab.addObserver(mExtraLogic);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorImpl.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelSelectorImpl.java
@@ -10,6 +10,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
if (isIncognito != mIncognito) {
throw new IllegalStateException("Incognito state mismatch. TabState: "
import org.chromium.base.supplier.Supplier;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.flags.ActivityType;
import org.chromium.chrome.browser.profiles.Profile;
@@ -107,6 +108,8 @@ public class TabModelSelectorImpl extends TabModelSelectorBase implements TabMod
public void onNativeLibraryReady(TabContentManager tabContentProvider) {
assert mTabContentManager == null : "onNativeLibraryReady called twice!";
+ AlwaysIncognitoLinkInterceptor.migrateSettingToNative();
+
ChromeTabCreator regularTabCreator =
(ChromeTabCreator) getTabCreatorManager().getTabCreator(false);
ChromeTabCreator incognitoTabCreator =
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
@ -537,7 +499,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPer
import org.chromium.base.Log;
import org.chromium.base.ObserverList;
import org.chromium.base.StreamUtil;
@@ -55,6 +56,8 @@ import org.chromium.content_public.browser.LoadUrlParams;
@@ -57,6 +58,8 @@ import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.url.GURL;
@ -546,11 +508,11 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPer
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -643,6 +646,13 @@ public class TabPersistentStore {
@@ -651,6 +654,13 @@ public class TabPersistentStore {
}
}
}
+ if (ContextUtils.getAppSharedPreferences().getBoolean(AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false)) {
+ if (AlwaysIncognitoLinkInterceptor.isAlwaysIncognito()) {
+ if (!isIncognito) {
+ Log.w(TAG, "Failed to restore tab: not in incognito mode.");
+ return;
@ -563,7 +525,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPer
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappIntentDataProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappIntentDataProvider.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappIntentDataProvider.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappIntentDataProvider.java
@@ -29,6 +29,9 @@ import org.chromium.chrome.browser.flags.ActivityType;
@@ -32,6 +32,9 @@ import org.chromium.chrome.browser.flags.ActivityType;
import org.chromium.components.browser_ui.widget.TintedDrawable;
import org.chromium.device.mojom.ScreenOrientationLockType;
@ -573,7 +535,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappI
/**
* Stores info about a web app.
*/
@@ -42,6 +45,8 @@ public class WebappIntentDataProvider extends BrowserServicesIntentDataProvider
@@ -45,6 +48,8 @@ public class WebappIntentDataProvider extends BrowserServicesIntentDataProvider
private final Intent mIntent;
private final ColorProviderImpl mColorProvider;
@ -582,18 +544,18 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappI
/**
* Returns the toolbar color to use if a custom color is not specified by the webapp.
*/
@@ -63,6 +68,10 @@ public class WebappIntentDataProvider extends BrowserServicesIntentDataProvider
@@ -67,6 +72,10 @@ public class WebappIntentDataProvider extends BrowserServicesIntentDataProvider
mWebappExtras = webappExtras;
mWebApkExtras = webApkExtras;
mActivityType = (webApkExtras != null) ? ActivityType.WEB_APK : ActivityType.WEBAPP;
+
+ if (ContextUtils.getAppSharedPreferences().getBoolean(AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false)) {
+ if (AlwaysIncognitoLinkInterceptor.isAlwaysIncognito()) {
+ mIsIncognito = true;
+ }
}
@Override
@@ -151,6 +160,11 @@ public class WebappIntentDataProvider extends BrowserServicesIntentDataProvider
@@ -155,6 +164,11 @@ public class WebappIntentDataProvider extends BrowserServicesIntentDataProvider
return mWebApkExtras;
}
@ -605,10 +567,65 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappI
@Override
public @ScreenOrientationLockType.EnumType int getDefaultOrientation() {
return mWebappExtras.orientation;
diff --git a/chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc b/chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc
--- a/chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc
+++ b/chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc
@@ -305,6 +305,9 @@ signin::IdentityManager* ChromeAutocompleteProviderClient::GetIdentityManager()
}
bool ChromeAutocompleteProviderClient::IsOffTheRecord() const {
+ if (profile_->GetPrefs()->GetBoolean(prefs::kAlwaysIncognitoEnabled)) {
+ return false;
+ }
return profile_->IsOffTheRecord();
}
diff --git a/chrome/browser/content_settings/host_content_settings_map_factory.cc b/chrome/browser/content_settings/host_content_settings_map_factory.cc
--- a/chrome/browser/content_settings/host_content_settings_map_factory.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_factory.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/buildflags.h"
+#include "chrome/common/pref_names.h"
#include "components/content_settings/core/browser/content_settings_pref_provider.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
@@ -96,9 +97,19 @@ scoped_refptr<RefcountedKeyedService>
if (profile->IsOffTheRecord() && !profile->IsGuestSession())
GetForProfile(original_profile);
+ bool always_incognito_enabled = false;
+
+#if defined(ALWAYS_INCOGNITO_ENABLED)
+ PrefService* prefService = original_profile->GetPrefs();
+ if (prefService->GetBoolean(prefs::kAlwaysIncognitoEnabled)) {
+ profile = original_profile;
+ always_incognito_enabled = true;
+ }
+#endif
+
scoped_refptr<HostContentSettingsMap> settings_map(new HostContentSettingsMap(
profile->GetPrefs(),
- profile->IsOffTheRecord() || profile->IsGuestSession(),
+ !always_incognito_enabled && (profile->IsOffTheRecord() || profile->IsGuestSession()),
/*store_last_modified=*/true,
profile->ShouldRestoreOldSessionCookies()));
@@ -108,6 +119,9 @@ scoped_refptr<RefcountedKeyedService>
HostContentSettingsMap::WEBUI_ALLOWLIST_PROVIDER,
std::move(allowlist_provider));
+ if (always_incognito_enabled)
+ return settings_map;
+
if (base::FeatureList::IsEnabled(
permissions::features::kOneTimeGeolocationPermission)) {
auto one_time_geolocation_provider =
diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc
--- a/chrome/browser/flags/android/chrome_feature_list.cc
+++ b/chrome/browser/flags/android/chrome_feature_list.cc
@@ -460,7 +460,7 @@ const base::Feature kCCTIncognito{"CCTIncognito",
@@ -456,7 +456,7 @@ const base::Feature kCCTIncognito{"CCTIncognito",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kCCTIncognitoAvailableToThirdParty{
@ -617,10 +634,23 @@ diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browse
const base::Feature kCCTPostMessageAPI{"CCTPostMessageAPI",
base::FEATURE_ENABLED_BY_DEFAULT};
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -1261,6 +1261,9 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
variations::VariationsService::RegisterProfilePrefs(registry);
video_tutorials::RegisterPrefs(registry);
feed::prefs::RegisterFeedSharedProfilePrefs(registry);
+ // register incognito pref
+ registry->RegisterBooleanPref(prefs::kAlwaysIncognitoEnabled,
+ /*default_value=*/false);
feed::RegisterProfilePrefs(registry);
#else // defined(OS_ANDROID)
AppShortcutManager::RegisterProfilePrefs(registry);
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -930,6 +930,19 @@ Your Google account may have other forms of browsing history like searches and a
@@ -981,6 +981,19 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_CLEAR_BROWSING_HISTORY_SUMMARY_SYNCED_NO_LINK" desc="A text for the basic tab explaining browsing history for users with history sync. This version is shown when the link to MyActivity is displayed separately.">
Clears history from all synced devices.
</message>
@ -683,5 +713,34 @@ new file mode 100644
+public interface INeedSnackbarManager {
+ void setSnackbarManager(SnackbarManager manager);
+}
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -3284,6 +3284,10 @@ const char kShowCaretBrowsingDialog[] =
const char kLacrosLaunchSwitch[] = "lacros_launch_switch";
#endif
+#if defined(OS_ANDROID)
+const char kAlwaysIncognitoEnabled[] = "always_incognito_enabled";
+#endif
+
#if BUILDFLAG(IS_CHROMEOS_ASH)
// String enum pref determining what should happen when a user who authenticates
// via a security token is removing this token. "IGNORE" - nothing happens
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
@@ -1198,6 +1198,11 @@ extern const char kLastWhatsNewVersion[];
extern const char kLensRegionSearchEnabled[];
#endif
+#if defined(OS_ANDROID)
+#define ALWAYS_INCOGNITO_ENABLED
+extern const char kAlwaysIncognitoEnabled[];
+#endif
+
extern const char kPrivacyReviewShowWelcomeCard[];
extern const char kPrivacyGuideViewed[];
--
2.25.1

View file

@ -13,13 +13,14 @@ See also: https://github.com/bromite/bromite/pull/1427
.../chrome_junit_test_java_sources.gni | 4 +
chrome/android/chrome_test_java_sources.gni | 6 +
.../java/res/xml/privacy_preferences.xml | 5 +
.../AppMenuPropertiesDelegateImpl.java | 29 +-
.../CustomTabAppMenuPropertiesDelegate.java | 3 +
.../AppMenuPropertiesDelegateImpl.java | 25 +-
.../CustomTabAppMenuPropertiesDelegate.java | 4 +
.../browser/download/DownloadUtils.java | 16 +-
.../browser/history/HistoryManager.java | 17 +-
.../chrome/browser/history/HistoryPage.java | 15 +
.../browser/history/HistoryManager.java | 18 +-
.../chrome/browser/history/HistoryPage.java | 16 +
.../native_page/NativePageFactory.java | 4 +-
.../chrome/browser/ntp/RecentTabsManager.java | 8 +-
.../privacy/settings/PrivacySettings.java | 17 +
.../privacy/settings/PrivacySettings.java | 18 +
.../browser/tab/HistoricalTabSaver.java | 12 +-
.../browser/tabmodel/TabPersistentStore.java | 5 +-
.../history/Bromite_HistoryManagerTest.java | 112 ++++++
@ -40,13 +41,13 @@ See also: https://github.com/bromite/bromite/pull/1427
.../request_coordinator_factory.h | 2 +
chrome/browser/prefs/browser_prefs.cc | 3 +
.../browser/ui/android/native_page/BUILD.gn | 2 +
.../browser/ui/native_page/NativePage.java | 6 +-
.../browser/ui/native_page/NativePage.java | 12 +-
.../ui/native_page/NativePageTest.java | 26 ++
.../strings/android_chrome_strings.grd | 6 +
chrome/common/pref_names.cc | 5 +
chrome/common/pref_names.cc | 2 +
chrome/common/pref_names.h | 4 +
chrome/test/BUILD.gn | 5 +
36 files changed, 1044 insertions(+), 38 deletions(-)
37 files changed, 1048 insertions(+), 41 deletions(-)
create mode 100644 chrome/android/javatests/src/org/chromium/chrome/browser/history/Bromite_HistoryManagerTest.java
create mode 100644 chrome/android/javatests/src/org/chromium/chrome/browser/privacy/settings/Bromite_PrivacySettingsFragmentTest_HistoryInAlwaysIncognito.java
create mode 100644 chrome/android/junit/src/org/chromium/chrome/browser/app/appmenu/Bromite_AppMenuPropertiesDelegateUnitTest.java
@ -56,7 +57,7 @@ See also: https://github.com/bromite/bromite/pull/1427
diff --git a/chrome/android/chrome_junit_test_java_sources.gni b/chrome/android/chrome_junit_test_java_sources.gni
--- a/chrome/android/chrome_junit_test_java_sources.gni
+++ b/chrome/android/chrome_junit_test_java_sources.gni
@@ -228,3 +228,7 @@ chrome_junit_test_java_sources = [
@@ -231,3 +231,7 @@ chrome_junit_test_java_sources = [
"junit/src/org/chromium/chrome/browser/webapps/WebappLauncherActivityTest.java",
"junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java",
]
@ -68,7 +69,7 @@ diff --git a/chrome/android/chrome_junit_test_java_sources.gni b/chrome/android/
diff --git a/chrome/android/chrome_test_java_sources.gni b/chrome/android/chrome_test_java_sources.gni
--- a/chrome/android/chrome_test_java_sources.gni
+++ b/chrome/android/chrome_test_java_sources.gni
@@ -660,3 +660,9 @@ chrome_test_java_sources = [
@@ -661,3 +661,9 @@ chrome_test_java_sources = [
if (enable_feed_v2) {
chrome_test_java_sources += [ "javatests/src/org/chromium/chrome/browser/ntp/NewTabPageColorWithFeedV2Test.java" ]
}
@ -96,7 +97,7 @@ diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/androi
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java
@@ -94,6 +94,10 @@ import java.util.ArrayList;
@@ -97,6 +97,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -107,7 +108,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/App
/**
* Base implementation of {@link AppMenuPropertiesDelegate} that handles hiding and showing menu
* items based on activity state.
@@ -153,6 +157,13 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
@@ -157,6 +161,13 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
private @StartSurfaceState int mStartSurfaceState;
protected Runnable mAppMenuInvalidator;
@ -121,17 +122,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/App
/**
* Construct a new {@link AppMenuPropertiesDelegateImpl}.
* @param context The activity context.
@@ -516,7 +527,8 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
}
private void prepareCommonMenuItems(Menu menu, @MenuGroup int menuGroup, boolean isIncognito) {
- if (ContextUtils.getAppSharedPreferences().getBoolean("always_incognito", false)) {
+ boolean always_incognito = ContextUtils.getAppSharedPreferences().getBoolean("always_incognito", false);
+ if (always_incognito) {
final MenuItem newTabOption = menu.findItem(R.id.new_tab_menu_id);
if (newTabOption != null)
newTabOption.setVisible(false);
@@ -578,7 +590,15 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
@@ -589,7 +600,15 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
}
if (item.getItemId() == R.id.recent_tabs_menu_id) {
@ -148,26 +139,33 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/App
}
if (item.getItemId() == R.id.menu_group_tabs) {
item.setVisible(isMenuGroupTabsVisible);
@@ -804,7 +824,10 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
@@ -826,7 +845,9 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
// is not persisted when adding to the homescreen.
// * If creating shortcuts it not supported by the current home screen.
return WebappsUtils.isAddToHomeIntentSupported() && !isChromeScheme && !isFileScheme
- && !isContentScheme && !isIncognito && !url.isEmpty();
+ && !isContentScheme && !url.isEmpty()
+ && (!isIncognito ||
+ ContextUtils.getAppSharedPreferences().getBoolean(
+ "always_incognito", false));
+ AlwaysIncognitoLinkInterceptor.isAlwaysIncognito());
}
/**
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
@@ -168,6 +168,9 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
@@ -20,6 +20,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
import org.chromium.chrome.browser.DefaultBrowserInfo;
import org.chromium.chrome.browser.app.appmenu.AppMenuPropertiesDelegateImpl;
import org.chromium.chrome.browser.bookmarks.BookmarkBridge;
@@ -168,6 +169,9 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
downloadItemVisible = false;
openInChromeItemVisible = false;
}
+ if (ContextUtils.getAppSharedPreferences().getBoolean("always_incognito", false)) {
+ if (AlwaysIncognitoLinkInterceptor.isAlwaysIncognito()) {
+ downloadItemVisible = true;
+ }
@ -176,7 +174,15 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/Cust
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
@@ -71,6 +71,10 @@ import org.chromium.ui.widget.Toast;
@@ -34,6 +34,7 @@ import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.download.items.OfflineContentAggregatorFactory;
@@ -71,6 +72,10 @@ import org.chromium.ui.widget.Toast;
import java.io.File;
@ -187,13 +193,12 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/Downlo
/**
* A class containing some utility static methods.
*/
@@ -311,7 +315,17 @@ public class DownloadUtils {
@@ -311,7 +316,16 @@ public class DownloadUtils {
// Offline pages isn't supported in Incognito. This should be checked before calling
// OfflinePageBridge.getForProfile because OfflinePageBridge instance will not be found
// for incognito profile.
- if (tab.isIncognito()) return false;
+ boolean always_incognito =
+ ContextUtils.getAppSharedPreferences().getBoolean("always_incognito", false);
+ boolean always_incognito = AlwaysIncognitoLinkInterceptor.isAlwaysIncognito();
+ if (always_incognito) {
+ PrefService prefService = UserPrefs.get(Profile.getLastUsedRegularProfile());
+ boolean historyEnabledInIncognito =
@ -209,7 +214,15 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/Downlo
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java
@@ -41,6 +41,12 @@ import org.chromium.ui.base.Clipboard;
@@ -22,6 +22,7 @@ import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
import org.chromium.chrome.browser.browsing_data.ClearBrowsingDataTabsFragment;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
@@ -41,6 +42,12 @@ import org.chromium.ui.base.Clipboard;
import java.util.List;
@ -222,7 +235,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/History
/**
* Combines and manages the different UI components of browsing history.
*/
@@ -213,7 +219,16 @@ public class HistoryManager implements OnMenuItemClickListener, SelectionObserve
@@ -213,7 +220,16 @@ public class HistoryManager implements OnMenuItemClickListener, SelectionObserve
: mSelectableListLayout;
}
@ -231,7 +244,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/History
+
+ public boolean shouldShowIncognitoPlaceholder() {
+ if (mIsIncognito &&
+ ContextUtils.getAppSharedPreferences().getBoolean("always_incognito", false)) {
+ AlwaysIncognitoLinkInterceptor.isAlwaysIncognito()) {
+ PrefService prefService = UserPrefs.get(Profile.getLastUsedRegularProfile());
+ boolean historyEnabledInIncognito =
+ prefService.getBoolean(Pref.INCOGNITO_TAB_HISTORY_ENABLED);
@ -243,7 +256,14 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/History
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryPage.java b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryPage.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryPage.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryPage.java
@@ -16,6 +16,12 @@ import org.chromium.chrome.browser.ui.native_page.BasicNativePage;
@@ -10,12 +10,19 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.chrome.browser.ui.native_page.BasicNativePage;
import org.chromium.chrome.browser.ui.native_page.NativePageHost;
import org.chromium.components.embedder_support.util.UrlConstants;
@ -256,12 +276,12 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/History
/**
* Native page for managing browsing history.
*/
@@ -37,8 +43,17 @@ public class HistoryPage extends BasicNativePage {
@@ -37,8 +44,17 @@ public class HistoryPage extends BasicNativePage {
boolean isIncognito, Supplier<Tab> tabSupplier) {
super(host);
+ if (isIncognito &&
+ ContextUtils.getAppSharedPreferences().getBoolean("always_incognito", false)) {
+ AlwaysIncognitoLinkInterceptor.isAlwaysIncognito()) {
+ PrefService prefService = UserPrefs.get(Profile.getLastUsedRegularProfile());
+ boolean historyEnabledInIncognito =
+ prefService.getBoolean(Pref.INCOGNITO_TAB_HISTORY_ENABLED);
@ -274,6 +294,27 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/History
mTitle = host.getContext().getResources().getString(R.string.menu_history);
initWithView(mHistoryManager.getView());
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/native_page/NativePageFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/native_page/NativePageFactory.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/native_page/NativePageFactory.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/native_page/NativePageFactory.java
@@ -15,6 +15,7 @@ import org.chromium.base.jank_tracker.JankTracker;
import org.chromium.base.supplier.BooleanSupplier;
import org.chromium.base.supplier.DestroyableObservableSupplier;
import org.chromium.base.supplier.Supplier;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.bookmarks.BookmarkPage;
import org.chromium.chrome.browser.browser_controls.BrowserControlsMarginSupplier;
@@ -243,7 +244,8 @@ public class NativePageFactory {
String url, NativePage candidatePage, Tab tab, boolean isIncognito) {
NativePage page;
- switch (NativePage.nativePageType(url, candidatePage, isIncognito)) {
+ boolean isAlwaysIncognito = AlwaysIncognitoLinkInterceptor.isAlwaysIncognito();
+ switch (NativePage.nativePageType(url, candidatePage, isIncognito, isAlwaysIncognito)) {
case NativePageType.NONE:
return null;
case NativePageType.CANDIDATE:
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/RecentTabsManager.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/RecentTabsManager.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/RecentTabsManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/RecentTabsManager.java
@ -308,7 +349,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/setting
import org.chromium.chrome.R;
import org.chromium.chrome.browser.feedback.HelpAndFeedbackLauncherImpl;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
@@ -152,6 +153,11 @@ public class PrivacySettings
@@ -151,6 +152,11 @@ public class PrivacySettings
Preference secureDnsPref = findPreference(PREF_SECURE_DNS);
secureDnsPref.setVisible(SecureDnsSettings.isUiEnabled());
@ -320,27 +361,25 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/setting
updatePreferences();
}
@@ -171,6 +177,9 @@ public class PrivacySettings
} else if (PREF_ALWAYS_INCOGNITO.equals(key)) {
if (!mSnackbarManager.isShowing())
mSnackbarManager.showSnackbar(mSnackbar);
+ } else if (PREF_INCOGNITO_TAB_HISTORY_ENABLED.equals(key)) {
+ UserPrefs.get(Profile.getLastUsedRegularProfile())
+ .setBoolean(Pref.INCOGNITO_TAB_HISTORY_ENABLED, (boolean) newValue);
@@ -171,10 +177,15 @@ public class PrivacySettings
} else if (PREF_HTTPS_FIRST_MODE.equals(key)) {
UserPrefs.get(Profile.getLastUsedRegularProfile())
.setBoolean(Pref.HTTPS_ONLY_MODE_ENABLED, (boolean) newValue);
@@ -178,6 +187,7 @@ public class PrivacySettings
+ } else if (PREF_INCOGNITO_TAB_HISTORY_ENABLED.equals(key)) {
+ UserPrefs.get(Profile.getLastUsedRegularProfile())
+ .setBoolean(Pref.INCOGNITO_TAB_HISTORY_ENABLED, (boolean) newValue);
}
return true;
}
+ public static final String PREF_INCOGNITO_TAB_HISTORY_ENABLED = "incognito_history_enabled";
+
@Override
public void onResume() {
super.onResume();
@@ -219,6 +229,13 @@ public class PrivacySettings
PrivacySandboxSettingsFragment.getStatusString(getContext()));
}
@@ -205,6 +216,13 @@ public class PrivacySettings
closeTabsOnExitPref.setOnPreferenceChangeListener(this);
closeTabsOnExitPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
+ ChromeSwitchPreference historyInIncognitoPref =
+ (ChromeSwitchPreference) findPreference(PREF_INCOGNITO_TAB_HISTORY_ENABLED);
@ -349,9 +388,9 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/setting
+ prefService.getBoolean(Pref.INCOGNITO_TAB_HISTORY_ENABLED));
+ }
+
mIncognitoLockSettings.updateIncognitoReauthPreferenceIfNeeded(getActivity());
}
Preference secureDnsPref = findPreference(PREF_SECURE_DNS);
if (secureDnsPref != null && secureDnsPref.isVisible()) {
secureDnsPref.setSummary(SecureDnsSettings.getSummary(getContext()));
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/HistoricalTabSaver.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/HistoricalTabSaver.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/HistoricalTabSaver.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/HistoricalTabSaver.java
@ -393,13 +432,13 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/HistoricalT
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
@@ -150,7 +150,10 @@ public class TabPersistentStore {
@@ -152,7 +152,10 @@ public class TabPersistentStore {
@Override
public void didCloseTab(Tab tab) {
PersistedTabData.onTabClose(tab);
- if (!tab.isIncognito()) HistoricalTabSaver.createHistoricalTab(tab);
+ boolean is_always_incognito =
+ ContextUtils.getAppSharedPreferences().getBoolean(AlwaysIncognitoLinkInterceptor.PREF_ALWAYS_INCOGNITO, false);
+ AlwaysIncognitoLinkInterceptor.isAlwaysIncognito();
+ if (!tab.isIncognito() || is_always_incognito)
+ HistoricalTabSaver.createHistoricalTab(tab, is_always_incognito);
removeTabFromQueues(tab);
@ -1278,7 +1317,7 @@ diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/histo
#else
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -357,6 +360,13 @@ void HistoryTabHelper::TitleWasSet(NavigationEntry* entry) {
@@ -358,6 +361,13 @@ void HistoryTabHelper::TitleWasSet(NavigationEntry* entry) {
history::HistoryService* HistoryTabHelper::GetHistoryService() {
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
@ -1292,7 +1331,7 @@ diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/histo
if (profile->IsOffTheRecord())
return NULL;
@@ -364,6 +374,12 @@ history::HistoryService* HistoryTabHelper::GetHistoryService() {
@@ -365,6 +375,12 @@ history::HistoryService* HistoryTabHelper::GetHistoryService() {
profile, ServiceAccessType::IMPLICIT_ACCESS);
}
@ -1308,7 +1347,7 @@ diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/histo
diff --git a/chrome/browser/history/history_tab_helper.h b/chrome/browser/history/history_tab_helper.h
--- a/chrome/browser/history/history_tab_helper.h
+++ b/chrome/browser/history/history_tab_helper.h
@@ -10,6 +10,8 @@
@@ -9,6 +9,8 @@
#include "build/build_config.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
@ -1317,7 +1356,7 @@ diff --git a/chrome/browser/history/history_tab_helper.h b/chrome/browser/histor
namespace history {
struct HistoryAddPageArgs;
@@ -42,6 +44,11 @@ class HistoryTabHelper : public content::WebContentsObserver,
@@ -41,6 +43,11 @@ class HistoryTabHelper : public content::WebContentsObserver,
force_eligible_tab_for_testing_ = force;
}
@ -1329,7 +1368,7 @@ diff --git a/chrome/browser/history/history_tab_helper.h b/chrome/browser/histor
private:
explicit HistoryTabHelper(content::WebContents* web_contents);
friend class content::WebContentsUserData<HistoryTabHelper>;
@@ -70,9 +77,6 @@ class HistoryTabHelper : public content::WebContentsObserver,
@@ -69,9 +76,6 @@ class HistoryTabHelper : public content::WebContentsObserver,
bool started_from_context_menu,
bool renderer_initiated) override;
@ -1342,7 +1381,7 @@ diff --git a/chrome/browser/history/history_tab_helper.h b/chrome/browser/histor
diff --git a/chrome/browser/history/history_tab_helper_unittest.cc b/chrome/browser/history/history_tab_helper_unittest.cc
--- a/chrome/browser/history/history_tab_helper_unittest.cc
+++ b/chrome/browser/history/history_tab_helper_unittest.cc
@@ -39,6 +39,9 @@
@@ -40,6 +40,9 @@
using testing::NiceMock;
@ -1352,7 +1391,7 @@ diff --git a/chrome/browser/history/history_tab_helper_unittest.cc b/chrome/brow
namespace {
#if defined(OS_ANDROID)
@@ -48,6 +51,25 @@ class TestFeedApi : public feed::StubFeedApi {
@@ -49,6 +52,25 @@ class TestFeedApi : public feed::StubFeedApi {
};
#endif
@ -1488,7 +1527,7 @@ diff --git a/chrome/browser/offline_pages/android/offline_page_model_factory.cc
diff --git a/chrome/browser/offline_pages/android/request_coordinator_factory.cc b/chrome/browser/offline_pages/android/request_coordinator_factory.cc
--- a/chrome/browser/offline_pages/android/request_coordinator_factory.cc
+++ b/chrome/browser/offline_pages/android/request_coordinator_factory.cc
@@ -29,6 +29,11 @@
@@ -30,6 +30,11 @@
#include "components/offline_pages/core/offline_page_feature.h"
#include "content/public/browser/web_contents.h"
@ -1500,7 +1539,7 @@ diff --git a/chrome/browser/offline_pages/android/request_coordinator_factory.cc
namespace network {
class NetworkQualityTracker;
}
@@ -114,4 +119,16 @@ KeyedService* RequestCoordinatorFactory::BuildServiceInstanceFor(
@@ -115,4 +120,16 @@ KeyedService* RequestCoordinatorFactory::BuildServiceInstanceFor(
return request_coordinator;
}
@ -1520,7 +1559,7 @@ diff --git a/chrome/browser/offline_pages/android/request_coordinator_factory.cc
diff --git a/chrome/browser/offline_pages/offline_page_model_factory.h b/chrome/browser/offline_pages/offline_page_model_factory.h
--- a/chrome/browser/offline_pages/offline_page_model_factory.h
+++ b/chrome/browser/offline_pages/offline_page_model_factory.h
@@ -49,6 +49,7 @@ class OfflinePageModelFactory : public SimpleKeyedServiceFactory {
@@ -48,6 +48,7 @@ class OfflinePageModelFactory : public SimpleKeyedServiceFactory {
std::unique_ptr<KeyedService> BuildServiceInstanceFor(
SimpleFactoryKey* key) const override;
@ -1531,7 +1570,7 @@ diff --git a/chrome/browser/offline_pages/offline_page_model_factory.h b/chrome/
diff --git a/chrome/browser/offline_pages/recent_tab_helper.cc b/chrome/browser/offline_pages/recent_tab_helper.cc
--- a/chrome/browser/offline_pages/recent_tab_helper.cc
+++ b/chrome/browser/offline_pages/recent_tab_helper.cc
@@ -30,6 +30,11 @@
@@ -29,6 +29,11 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
@ -1560,7 +1599,7 @@ diff --git a/chrome/browser/offline_pages/recent_tab_helper.cc b/chrome/browser/
diff --git a/chrome/browser/offline_pages/request_coordinator_factory.h b/chrome/browser/offline_pages/request_coordinator_factory.h
--- a/chrome/browser/offline_pages/request_coordinator_factory.h
+++ b/chrome/browser/offline_pages/request_coordinator_factory.h
@@ -37,6 +37,8 @@ class RequestCoordinatorFactory : public BrowserContextKeyedServiceFactory {
@@ -36,6 +36,8 @@ class RequestCoordinatorFactory : public BrowserContextKeyedServiceFactory {
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
@ -1581,10 +1620,10 @@ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browse
#include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h"
#include "chrome/browser/android/explore_sites/history_statistics_reporter.h"
#include "chrome/browser/android/ntp/recent_tabs_page_prefs.h"
@@ -1276,6 +1278,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
variations::VariationsService::RegisterProfilePrefs(registry);
video_tutorials::RegisterPrefs(registry);
feed::prefs::RegisterFeedSharedProfilePrefs(registry);
@@ -1268,6 +1270,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
// register incognito pref
registry->RegisterBooleanPref(prefs::kAlwaysIncognitoEnabled,
/*default_value=*/false);
+ HistoryTabHelper::RegisterProfilePrefs(registry);
feed::RegisterProfilePrefs(registry);
#else // defined(OS_ANDROID)
@ -1615,14 +1654,38 @@ diff --git a/chrome/browser/ui/android/native_page/java/src/org/chromium/chrome/
/**
* An interface for pages that will be using Android views instead of html/rendered Web content.
*/
@@ -158,7 +160,9 @@ public interface NativePage {
@@ -120,12 +122,12 @@ public interface NativePage {
*/
@Deprecated // Use GURL-variant instead.
public static boolean isNativePageUrl(String url, boolean isIncognito) {
- return nativePageType(url, null, isIncognito) != NativePageType.NONE;
+ return nativePageType(url, null, isIncognito, false) != NativePageType.NONE;
}
public static boolean isNativePageUrl(GURL url, boolean isIncognito) {
return url != null
- && nativePageType(url.getSpec(), null, isIncognito) != NativePageType.NONE;
+ && nativePageType(url.getSpec(), null, isIncognito, false) != NativePageType.NONE;
}
/**
@@ -136,7 +138,8 @@ public interface NativePage {
*/
// TODO(crbug/783819) - Convert to using GURL.
public static @NativePageType int nativePageType(
- String url, NativePage candidatePage, boolean isIncognito) {
+ String url, NativePage candidatePage, boolean isIncognito,
+ boolean isAlwaysIncognito) {
if (url == null) return NativePageType.NONE;
Uri uri = Uri.parse(url);
@@ -158,7 +161,8 @@ public interface NativePage {
return NativePageType.DOWNLOADS;
} else if (UrlConstants.HISTORY_HOST.equals(host)) {
return NativePageType.HISTORY;
- } else if (UrlConstants.RECENT_TABS_HOST.equals(host) && !isIncognito) {
+ } else if (UrlConstants.RECENT_TABS_HOST.equals(host) &&
+ (!isIncognito ||
+ ContextUtils.getAppSharedPreferences().getBoolean("always_incognito", false))) {
+ (!isIncognito || isAlwaysIncognito)) {
return NativePageType.RECENT_TABS;
} else if (UrlConstants.EXPLORE_HOST.equals(host)) {
return NativePageType.EXPLORE;
@ -1670,7 +1733,7 @@ diff --git a/chrome/browser/ui/android/native_page/java/src/org/chromium/chrome/
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -961,6 +961,12 @@ Your Google account may have other forms of browsing history like searches and a
@@ -1012,6 +1012,12 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_UI_RELAUNCH_NOTICE" desc="Summary for always incognito mode">
Your changes will take effect the next time you relaunch Bromite.
</message>
@ -1686,22 +1749,19 @@ diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chro
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -3298,6 +3298,11 @@ const char kShowCaretBrowsingDialog[] =
const char kLacrosLaunchSwitch[] = "lacros_launch_switch";
#endif
@@ -3289,6 +3289,8 @@ const char kLacrosLaunchSwitch[] = "lacros_launch_switch";
+#if defined(OS_ANDROID)
#if defined(OS_ANDROID)
const char kAlwaysIncognitoEnabled[] = "always_incognito_enabled";
+const char kIncognitoTabHistoryEnabled[] =
+ "incognito_tab_history_enabled";
+#endif
+
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
// String enum pref determining what should happen when a user who authenticates
// via a security token is removing this token. "IGNORE" - nothing happens
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
@@ -1206,6 +1206,10 @@ extern const char kPrivacyReviewShowWelcomeCard[];
@@ -1209,6 +1209,10 @@ extern const char kPrivacyGuideViewed[];
extern const char kCorsNonWildcardRequestHeadersSupport[];
@ -1715,7 +1775,7 @@ diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -4872,6 +4872,11 @@ test("unit_tests") {
@@ -4880,6 +4880,11 @@ test("unit_tests") {
]
}

View file

@ -10,9 +10,9 @@ See also: https://github.com/bromite/bromite/issues/1062
chrome/android/chrome_java_resources.gni | 1 +
chrome/android/chrome_java_sources.gni | 1 +
chrome/android/java/AndroidManifest.xml | 18 +++
.../res/layout/sharing_intent_content.xml | 83 +++++++++++++
.../res/layout/sharing_intent_content.xml | 83 ++++++++++++
.../init/ProcessInitializationHandler.java | 3 +
.../SharedIntentShareActivity.java | 114 ++++++++++++++++++
.../SharedIntentShareActivity.java | 118 ++++++++++++++++++
chrome/browser/about_flags.cc | 4 +
chrome/browser/flag_descriptions.cc | 5 +
chrome/browser/flag_descriptions.h | 3 +
@ -20,7 +20,7 @@ See also: https://github.com/bromite/bromite/issues/1062
.../flags/android/chrome_feature_list.h | 1 +
.../browser/flags/ChromeFeatureList.java | 1 +
.../strings/android_chrome_strings.grd | 13 ++
13 files changed, 251 insertions(+)
13 files changed, 255 insertions(+)
create mode 100644 chrome/android/java/res/layout/sharing_intent_content.xml
create mode 100644 chrome/android/java/src/org/chromium/chrome/browser/sharing/shared_intent/SharedIntentShareActivity.java
@ -186,7 +186,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sharing/shared_
new file mode 100644
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/sharing/shared_intent/SharedIntentShareActivity.java
@@ -0,0 +1,114 @@
@@ -0,0 +1,118 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
@ -210,6 +210,7 @@ new file mode 100644
+import org.chromium.base.task.PostTask;
+import org.chromium.base.task.TaskTraits;
+import org.chromium.chrome.R;
+import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor;
+import org.chromium.chrome.browser.flags.ChromeFeatureList;
+import org.chromium.chrome.browser.init.AsyncInitializationActivity;
+import org.chromium.chrome.browser.LaunchIntentDispatcher;
@ -293,6 +294,9 @@ new file mode 100644
+ finish();
+ });
+
+ if (AlwaysIncognitoLinkInterceptor.isAlwaysIncognito())
+ open_url_incognito_button.setVisibility(View.GONE);
+
+ onInitialLayoutInflationComplete();
+ }
+