From: uazo Date: Thu, 16 Feb 2023 15:28:16 +0000 Subject: Add setting to clear data on exit License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html --- chrome/android/chrome_java_sources.gni | 1 + .../java/res/xml/privacy_preferences.xml | 5 ++ .../chrome/browser/ChromeTabbedActivity.java | 7 +- .../browsing_data/BrowsingDataBridge.java | 12 +-- .../ClearBrowsingDataFragment.java | 37 +++++++-- .../ClearBrowsingDataFragmentAtStart.java | 79 +++++++++++++++++++ chrome/app/settings_strings.grdp | 8 ++ chrome/browser/about_flags.cc | 1 + .../browsing_data/browsing_data_bridge.cc | 17 +++- .../chrome_browsing_data_lifetime_manager.cc | 22 +++++- .../chrome_browsing_data_remover_delegate.cc | 15 ++++ .../api/settings_private/prefs_util.cc | 17 ++++ .../browser/profiles/ProfileManagerUtils.java | 5 ++ .../profiles/android/profile_manager_utils.cc | 5 ++ chrome/browser/profiles/profile_manager.cc | 17 +++- chrome/browser/profiles/profile_manager.h | 2 + .../clear_browsing_data_browser_proxy.ts | 1 + .../clear_browsing_data_dialog_v2.html | 20 ++++- .../clear_browsing_data_dialog_v2.ts | 62 ++++++++++++++- .../clear_browsing_data_time_picker.ts | 6 +- .../settings/privacy_page/privacy_page.html | 12 +++ .../settings/privacy_page/privacy_page.ts | 10 +++ .../privacy_page/privacy_page_index.ts | 2 +- chrome/browser/resources/settings/route.ts | 2 + chrome/browser/resources/settings/router.ts | 1 + .../strings/android_chrome_strings.grd | 3 + .../Add-setting-to-clear-data-on-exit.grdp | 9 +++ .../settings_localized_strings_provider.cc | 4 + .../content/browsing_data_helper.cc | 9 ++- components/browsing_data/core/BUILD.gn | 5 ++ .../core/browsing_data_policies_utils.cc | 20 ++--- .../core/browsing_data_policies_utils.h | 11 +++ .../browsing_data/core/browsing_data_utils.cc | 31 ++++++++ .../core/clear_browsing_data_tab.h | 3 +- components/browsing_data/core/pref_names.cc | 17 ++++ components/browsing_data/core/pref_names.h | 10 +++ components/favicon/core/favicon_database.cc | 9 +++ components/favicon/core/favicon_database.h | 3 + .../search_engines/template_url_service.cc | 1 + content/browser/btm/btm_service_impl.cc | 2 +- content/browser/storage_partition_impl.cc | 2 + .../public/browser/browsing_data_remover.h | 7 +- .../Add-setting-to-clear-data-on-exit.inc | 8 ++ 43 files changed, 473 insertions(+), 47 deletions(-) create mode 100644 chrome/android/java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentAtStart.java create mode 100644 chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-setting-to-clear-data-on-exit.grdp create mode 100644 cromite_flags/chrome/browser/about_flags_cc/Add-setting-to-clear-data-on-exit.inc diff --git a/chrome/android/chrome_java_sources.gni b/chrome/android/chrome_java_sources.gni --- a/chrome/android/chrome_java_sources.gni +++ b/chrome/android/chrome_java_sources.gni @@ -295,6 +295,7 @@ chrome_java_sources = [ "java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataCheckBoxPreference.java", "java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFetcher.java", "java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragment.java", + "java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentAtStart.java", "java/src/org/chromium/chrome/browser/browsing_data/ConfirmImportantSitesDialogFragment.java", "java/src/org/chromium/chrome/browser/browsing_data/OtherFormsOfHistoryDialogFragment.java", "java/src/org/chromium/chrome/browser/browsing_data/UrlFilter.java", diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml --- a/chrome/android/java/res/xml/privacy_preferences.xml +++ b/chrome/android/java/res/xml/privacy_preferences.xml @@ -19,6 +19,11 @@ found in the LICENSE file. android:title="@string/clear_browsing_data_title" android:summary="@string/clear_browsing_data_summary" android:fragment="org.chromium.chrome.browser.browsing_data.ClearBrowsingDataFragment" /> + mPageTitle = + protected final SettableMonotonicObservableSupplier mPageTitle = ObservableSuppliers.createMonotonic(); /** @@ -356,7 +362,7 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment } /** Called when browsing data is about to be cleared. */ - private void onClearBrowsingData() { + protected void onClearBrowsingData() { RecordUserAction.record("ClearBrowsingData_AdvancedTab"); } @@ -442,6 +448,7 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment BrowsingDataBridge.getForProfile(getProfile()) .setBrowsingDataDeletionPreference( ClearBrowsingDataFragment.getDataType(item.getOption()), + getClearBrowsingDataTabType(), item.isSelected()); } @@ -449,8 +456,16 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment .setBrowsingDataDeletionTimePeriod(mLastSelectedTimePeriod); } + protected int getClearBrowsingDataTabType() { + return ClearBrowsingDataTab.ADVANCED; + } + /** Returns the list of supported {@link DialogOption}. */ - private static List getDialogOptions(Bundle fragmentArgs) { + protected List getDialogOptions(Bundle fragmentArgs) { + return getDialogOptionsStatic(fragmentArgs); + } + + private static List getDialogOptionsStatic(Bundle fragmentArgs) { String referrer = fragmentArgs.getString( ClearBrowsingDataFragment.CLEAR_BROWSING_DATA_REFERRER, null); @@ -476,6 +491,10 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment DialogOption.CLEAR_SITE_SETTINGS); } + protected boolean shouldClearBrowsingData() { + return true; + } + /** * Decides whether a given dialog option should be selected when the dialog is initialized. * @@ -484,7 +503,7 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment */ private boolean isOptionSelectedByDefault(@DialogOption int option) { return BrowsingDataBridge.getForProfile(getProfile()) - .getBrowsingDataDeletionPreference(getDataType(option)); + .getBrowsingDataDeletionPreference(getDataType(option), getClearBrowsingDataTabType()); } /** @@ -552,6 +571,7 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment * options. */ private void onClearButtonClicked() { + if (!shouldClearBrowsingData()) return; if (shouldShowImportantSitesDialog()) { showImportantDialogThenClear(); return; @@ -581,6 +601,7 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment Button clearButton = (Button) assumeNonNull(getView()).findViewById(R.id.clear_button); boolean isEnabled = !getSelectedOptions().isEmpty(); clearButton.setEnabled(isEnabled); + clearButton.setVisibility(shouldClearBrowsingData() ? View.VISIBLE : View.INVISIBLE); } private int getSpinnerIndex( @@ -658,7 +679,7 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment .getBoolean(Pref.ALLOW_DELETING_BROWSER_HISTORY)) { enabled = false; browsingDataBridge.setBrowsingDataDeletionPreference( - getDataType(DialogOption.CLEAR_HISTORY), false); + getDataType(DialogOption.CLEAR_HISTORY), getClearBrowsingDataTabType(), false); } // Disable tabs closure if the user is in multi-window mode. @@ -688,8 +709,12 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment mSigninManager.addSignInStateObserver(this); setHasOptionsMenu(true); + + onCustomizePreferences(savedInstanceState, rootKey); } + protected void onCustomizePreferences(Bundle savedInstanceState, String rootKey) {} + @Override public MonotonicObservableSupplier getPageTitle() { return mPageTitle; @@ -990,7 +1015,7 @@ public class ClearBrowsingDataFragment extends ChromeBaseSettingsFragment public void updateDynamicPreferences( Context context, SettingsIndexData indexData, Profile profile) { Bundle args = createFragmentArgs(context.getClass().getName()); - List options = getDialogOptions(args); + List options = getDialogOptionsStatic(args); // Not all checkboxes defined in the layout are necessarily handled by this // class or a particular subclass. Hide those that are not. Set unboundOptions = getAllOptions(); diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentAtStart.java b/chrome/android/java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentAtStart.java new file mode 100644 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragmentAtStart.java @@ -0,0 +1,79 @@ +/* + This file is part of Bromite. + + Bromite is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bromite is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bromite. If not, see . +*/ + +package org.chromium.chrome.browser.browsing_data; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.IntDef; +import androidx.preference.Preference; + +import org.chromium.base.Callback; +import org.chromium.chrome.R; +import org.chromium.chrome.browser.profiles.Profile; +import org.chromium.components.browser_ui.settings.SpinnerPreference; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.util.Arrays; +import java.util.List; + +public class ClearBrowsingDataFragmentAtStart extends ClearBrowsingDataFragment { + static final String PREF_TIME_RANGE = "time_period_spinner"; + + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + super.onCreatePreferences(savedInstanceState, rootKey); + + SpinnerPreference spinner = (SpinnerPreference) findPreference(PREF_TIME_RANGE); + if (spinner != null) { + getPreferenceScreen().removePreference(spinner); + } + } + + private boolean isHistorySyncEnabled() { + return false; + } + + @Override + protected void onCustomizePreferences(Bundle savedInstanceState, String rootKey) { + mPageTitle.set(getString(R.string.clear_browsing_data_at_start_title)); + } + + @Override + protected int getClearBrowsingDataTabType() { + return ClearBrowsingDataTab.AT_START; + } + + @Override + protected List getDialogOptions(Bundle fragmentArgs) { + return Arrays.asList(DialogOption.CLEAR_HISTORY, DialogOption.CLEAR_COOKIES_AND_SITE_DATA, + DialogOption.CLEAR_CACHE, DialogOption.CLEAR_PASSWORDS, + DialogOption.CLEAR_FORM_DATA, DialogOption.CLEAR_SITE_SETTINGS); + } + + @Override + public void onClearBrowsingData() { + } + + @Override + protected boolean shouldClearBrowsingData() { + return false; + } +} diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp @@ -2222,6 +2222,14 @@ Delete browsing data + + + Clear browsing data when closing Cromite + + + Choose what to automatically delete when you close Cromite + + Delete history, cookies, cache, and more diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -113,6 +113,7 @@ #include "components/enterprise/client_certificates/core/features.h" #include "components/enterprise/data_controls/core/browser/features.h" #include "components/error_page/common/error_page_switches.h" +#include "components/favicon/core/favicon_database.h" #include "components/feature_engagement/public/feature_constants.h" #include "components/feature_engagement/public/feature_list.h" #include "components/feed/feed_feature_list.h" diff --git a/chrome/browser/android/browsing_data/browsing_data_bridge.cc b/chrome/browser/android/browsing_data/browsing_data_bridge.cc --- a/chrome/browser/android/browsing_data/browsing_data_bridge.cc +++ b/chrome/browser/android/browsing_data/browsing_data_bridge.cc @@ -65,6 +65,15 @@ PrefService* GetPrefService(Profile* profile) { return profile->GetOriginalProfile()->GetPrefs(); } +browsing_data::ClearBrowsingDataTab ToTabEnum(jint clear_browsing_data_tab) { + DCHECK_GE(clear_browsing_data_tab, 0); + DCHECK_LE(clear_browsing_data_tab, + static_cast(browsing_data::ClearBrowsingDataTab::MAX_VALUE)); + + return static_cast( + clear_browsing_data_tab); +} + void OnBrowsingDataModelBuilt(JNIEnv* env, const ScopedJavaGlobalRef& java_callback, std::unique_ptr model) { @@ -217,7 +226,8 @@ static void JNI_BrowsingDataBridge_MarkOriginAsImportantForTesting( static bool JNI_BrowsingDataBridge_GetBrowsingDataDeletionPreference( JNIEnv* env, Profile* profile, - int32_t data_type) { + int32_t data_type, + jint clear_browsing_data_tab) { DCHECK_GE(data_type, 0); DCHECK_LE(data_type, static_cast(browsing_data::BrowsingDataType::MAX_VALUE)); @@ -229,7 +239,7 @@ static bool JNI_BrowsingDataBridge_GetBrowsingDataDeletionPreference( std::string pref; if (!browsing_data::GetDeletionPreferenceFromDataType( static_cast(data_type), - browsing_data::ClearBrowsingDataTab::ADVANCED, &pref)) { + ToTabEnum(clear_browsing_data_tab), &pref)) { return false; } @@ -240,6 +250,7 @@ static void JNI_BrowsingDataBridge_SetBrowsingDataDeletionPreference( JNIEnv* env, Profile* profile, int32_t data_type, + jint clear_browsing_data_tab, bool value) { DCHECK_GE(data_type, 0); DCHECK_LE(data_type, @@ -248,7 +259,7 @@ static void JNI_BrowsingDataBridge_SetBrowsingDataDeletionPreference( std::string pref; if (!browsing_data::GetDeletionPreferenceFromDataType( static_cast(data_type), - browsing_data::ClearBrowsingDataTab::ADVANCED, &pref)) { + ToTabEnum(clear_browsing_data_tab), &pref)) { return; } diff --git a/chrome/browser/browsing_data/chrome_browsing_data_lifetime_manager.cc b/chrome/browser/browsing_data/chrome_browsing_data_lifetime_manager.cc --- a/chrome/browser/browsing_data/chrome_browsing_data_lifetime_manager.cc +++ b/chrome/browser/browsing_data/chrome_browsing_data_lifetime_manager.cc @@ -325,8 +325,25 @@ void ChromeBrowsingDataLifetimeManager::Shutdown() { void ChromeBrowsingDataLifetimeManager::ClearBrowsingDataForOnExitPolicy( bool keep_browser_alive) { - const base::ListValue& data_types = profile_->GetPrefs()->GetList( - browsing_data::prefs::kClearBrowsingDataOnExitList); + base::ListValue data_types = profile_->GetPrefs()->GetList( + browsing_data::prefs::kClearBrowsingDataOnExitList).Clone(); + + if (profile_->GetPrefs()->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistoryAtStart)) + data_types.Append(browsing_data::policy_data_types::kBrowsingHistoryName); + if (profile_->GetPrefs()->GetBoolean(browsing_data::prefs::kDeletePasswordsAtStart)) + data_types.Append(browsing_data::policy_data_types::kPasswordSigninName); + if (profile_->GetPrefs()->GetBoolean(browsing_data::prefs::kDeleteFormDataAtStart)) + data_types.Append(browsing_data::policy_data_types::kAutofillName); + if (profile_->GetPrefs()->GetBoolean(browsing_data::prefs::kDeleteSiteSettingsAtStart)) + data_types.Append(browsing_data::policy_data_types::kSiteSettingsName); + if (profile_->GetPrefs()->GetBoolean(browsing_data::prefs::kDeleteHostedAppsDataAtStart)) + data_types.Append(browsing_data::policy_data_types::kHostedAppDataName); + if (profile_->GetPrefs()->GetBoolean(browsing_data::prefs::kDeleteDownloadHistoryAtStart)) + data_types.Append(browsing_data::policy_data_types::kDownloadHistoryName); + if (profile_->GetPrefs()->GetBoolean(browsing_data::prefs::kDeleteCookiesAtStart)) + data_types.Append(browsing_data::policy_data_types::kCookiesAndOtherSiteDataName); + if (profile_->GetPrefs()->GetBoolean(browsing_data::prefs::kDeleteCacheAtStart)) + data_types.Append(browsing_data::policy_data_types::kCachedImagesAndFilesName); if (!data_types.empty() && IsConditionSatisfiedForBrowsingDataRemoval(GetSyncTypesForPolicyPref( @@ -435,6 +452,7 @@ void ChromeBrowsingDataLifetimeManager::StartScheduledBrowsingDataRemoval() { bool ChromeBrowsingDataLifetimeManager:: IsConditionSatisfiedForBrowsingDataRemoval( const syncer::UserSelectableTypeSet sync_types) { + if ((true)) return true; bool sync_disabled = !SyncServiceFactory::IsSyncAllowed(profile_); // Condition is satisfied if sync is fully disabled by policy. if (sync_disabled) { diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc --- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc +++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc @@ -317,6 +317,7 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( uint64_t origin_type_mask, base::OnceCallback callback) { CHECK(((remove_mask & + ~content::BrowsingDataRemover::DATA_TYPE_SKIP_SSL_HOST_STATE & ~content::BrowsingDataRemover::DATA_TYPE_AVOID_CLOSING_CONNECTIONS & ~constants::FILTERABLE_DATA_TYPES) == 0) || filter_builder->MatchesAllOriginsAndDomains()); @@ -420,6 +421,9 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( CreateTaskCompletionClosure(TracingDataType::kHistory), &history_task_tracker_); } + } + + if (remove_mask & content::BrowsingDataRemover::DATA_TYPE_CACHE) { if (ClipboardRecentContent::GetInstance()) ClipboardRecentContent::GetInstance()->SuppressClipboardContent(); @@ -527,6 +531,11 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( // and SSL host state are scoped to hosts and represent them as std::string. // Rename the method to indicate its more general usage. if (profile_->GetSSLHostStateDelegate()) { + bool skip = false; + if (remove_mask & content::BrowsingDataRemover::DATA_TYPE_SKIP_SSL_HOST_STATE) { + skip = true; + } + if (!skip) profile_->GetSSLHostStateDelegate()->Clear( filter_builder->MatchesAllOriginsAndDomains() ? base::RepeatingCallback() @@ -555,9 +564,13 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( } device_event_log::Clear(delete_begin_, delete_end_); + } + if ((remove_mask & constants::DATA_TYPE_HISTORY) && may_delete_history) { CreateCrashUploadList()->Clear(delete_begin_, delete_end_); + } + if (remove_mask & content::BrowsingDataRemover::DATA_TYPE_CACHE) { content::BackgroundTracingManager::GetInstance().DeleteTracesInDateRange( delete_begin_, delete_end_); @@ -1276,6 +1289,8 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( if (should_clear_zero_suggest_and_session_token && template_url_service) template_url_service->ClearSessionToken(); + + template_url_service->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); } ////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc --- a/chrome/browser/extensions/api/settings_private/prefs_util.cc +++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc @@ -591,6 +591,23 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetAllowlistedKeys() { (*s_allowlist)[browsing_data::prefs::kLastClearBrowsingDataTab] = settings_api::PrefType::kNumber; + (*s_allowlist)[browsing_data::prefs::kDeleteBrowsingHistoryAtStart] = + settings_api::PrefType::kBoolean; + (*s_allowlist)[browsing_data::prefs::kDeleteDownloadHistoryAtStart] = + settings_api::PrefType::kBoolean; + (*s_allowlist)[browsing_data::prefs::kDeleteCacheAtStart] = + settings_api::PrefType::kBoolean; + (*s_allowlist)[browsing_data::prefs::kDeleteCookiesAtStart] = + settings_api::PrefType::kBoolean; + (*s_allowlist)[browsing_data::prefs::kDeletePasswordsAtStart] = + settings_api::PrefType::kBoolean; + (*s_allowlist)[browsing_data::prefs::kDeleteFormDataAtStart] = + settings_api::PrefType::kBoolean; + (*s_allowlist)[browsing_data::prefs::kDeleteSiteSettingsAtStart] = + settings_api::PrefType::kBoolean; + (*s_allowlist)[browsing_data::prefs::kDeleteHostedAppsDataAtStart] = + settings_api::PrefType::kBoolean; + // Accessibility. (*s_allowlist)[::prefs::kAccessibilityImageLabelsEnabled] = settings_api::PrefType::kBoolean; diff --git a/chrome/browser/profiles/android/java/src/org/chromium/chrome/browser/profiles/ProfileManagerUtils.java b/chrome/browser/profiles/android/java/src/org/chromium/chrome/browser/profiles/ProfileManagerUtils.java --- a/chrome/browser/profiles/android/java/src/org/chromium/chrome/browser/profiles/ProfileManagerUtils.java +++ b/chrome/browser/profiles/android/java/src/org/chromium/chrome/browser/profiles/ProfileManagerUtils.java @@ -69,11 +69,16 @@ public class ProfileManagerUtils { } } + public static void removeBrowsingDataAtStart() { + ProfileManagerUtilsJni.get().removeBrowsingDataAtStart(); + } + @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) @NativeMethods public interface Natives { void flushPersistentDataForAllProfiles(); void removeSessionCookiesForAllProfiles(); + void removeBrowsingDataAtStart(); } } diff --git a/chrome/browser/profiles/android/profile_manager_utils.cc b/chrome/browser/profiles/android/profile_manager_utils.cc --- a/chrome/browser/profiles/android/profile_manager_utils.cc +++ b/chrome/browser/profiles/android/profile_manager_utils.cc @@ -65,4 +65,9 @@ static void JNI_ProfileManagerUtils_RemoveSessionCookiesForAllProfiles( RemoveSessionCookiesForProfile); } +static void JNI_ProfileManagerUtils_RemoveBrowsingDataAtStart( + JNIEnv* env) { + g_browser_process->profile_manager()->RemoveBrowsingDataAtStart(); +} + DEFINE_JNI(ProfileManagerUtils) diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -1566,6 +1566,19 @@ void ProfileManager::DoFinalInit(ProfileInfo* profile_info, } } +void ProfileManager::RemoveBrowsingDataAtStart() { + std::ranges::for_each( + GetLoadedProfiles(), + [](Profile* profile) { + auto* browsing_data_lifetime_manager = + ChromeBrowsingDataLifetimeManagerFactory::GetForProfile(profile); + if (browsing_data_lifetime_manager && !profile->IsOffTheRecord()) { + browsing_data_lifetime_manager->ClearBrowsingDataForOnExitPolicy( + /*keep_browser_alive=*/false); + } + }); +} + void ProfileManager::DoFinalInitForServices(Profile* profile, bool go_off_the_record) { if (!do_final_services_init_ || @@ -2307,9 +2320,9 @@ void ProfileManager::OnBrowserClosed(BrowserWindowInterface* browser) { // Do nothing if the closed window is not the last window of the same profile. bool has_other_window = false; ForEachCurrentBrowserWindowInterfaceOrderedByActivation( - [original_profile, &has_other_window](BrowserWindowInterface* browser) { + [profile, &has_other_window](BrowserWindowInterface* browser) { const Profile* const iter_profile = browser->GetProfile(); - if (iter_profile->GetOriginalProfile() == original_profile) { + if (iter_profile == profile) { has_other_window = true; } return !has_other_window; diff --git a/chrome/browser/profiles/profile_manager.h b/chrome/browser/profiles/profile_manager.h --- a/chrome/browser/profiles/profile_manager.h +++ b/chrome/browser/profiles/profile_manager.h @@ -264,6 +264,8 @@ class ProfileManager : public Profile::Delegate { // profiles. std::vector GetLoadedProfiles() const; + void RemoveBrowsingDataAtStart(); + // If a profile with the given path is currently managed by this object and // fully initialized, return a pointer to the corresponding Profile object; // otherwise return null. diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_browser_proxy.ts b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_browser_proxy.ts --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_browser_proxy.ts +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_browser_proxy.ts @@ -42,6 +42,7 @@ export enum BrowsingDataType { SITE_SETTINGS = 5, DOWNLOADS = 6, HOSTED_APPS_DATA = 7, + PASSWORDS = 8, // TABS = 8, Not used on Desktop. } // LINT.ThenChange(/components/browsing_data/core/browsing_data_utils.h:BrowsingDataType) diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog_v2.html b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog_v2.html --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog_v2.html +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog_v2.html @@ -40,6 +40,8 @@ #deleteBrowsingDataDialog::part(dialog) { max-height: var(--dbd-dialog-max-height); + top: 300px; + width: 590px; } #deletingDataAlert { @@ -99,18 +101,25 @@