#include "chrome/browser/browsing_data/chrome_browsing_data_lifetime_manager.h"
#include <algorithm>
#include <limits>
#include <string>
#include <utility>
#include "base/command_line.h"
#include "base/containers/flat_set.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/scoped_observation.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_constants.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/browsing_data/core/browsing_data_policies_utils.h"
#include "components/browsing_data/core/pref_names.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/sync_user_settings.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browsing_data_filter_builder.h"
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/web_contents.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "url/gurl.h"
#include "url/origin.h"
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#else
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/ui/android/tab_model/tab_model.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#endif
namespace {
constexpr int kInitialCleanupDelayInSeconds = …;
constexpr int kTestCleanupPeriodInMinutes = …;
constexpr int kDefaultCleanupPeriodInMinutes = …;
ScheduledRemovalSettings;
class BrowsingDataRemoverObserver
: public content::BrowsingDataRemover::Observer { … };
uint64_t GetOriginTypeMask(const base::Value::List& data_types) { … }
uint64_t GetRemoveMask(const base::Value::List& data_types) { … }
std::vector<ScheduledRemovalSettings> ConvertToScheduledRemovalSettings(
const base::Value::List& browsing_data_settings) { … }
base::flat_set<GURL> GetOpenedUrls(Profile* profile) { … }
syncer::UserSelectableTypeSet GetSyncTypesForPolicyPref(
Profile* profile,
const std::string& pref_name) { … }
}
namespace browsing_data {
namespace policy_fields {
const char kTimeToLiveInHours[] = …;
const char kDataTypes[] = …;
}
}
ChromeBrowsingDataLifetimeManager::ChromeBrowsingDataLifetimeManager(
content::BrowserContext* browser_context)
: … { … }
ChromeBrowsingDataLifetimeManager::~ChromeBrowsingDataLifetimeManager() =
default;
void ChromeBrowsingDataLifetimeManager::Shutdown() { … }
void ChromeBrowsingDataLifetimeManager::ClearBrowsingDataForOnExitPolicy(
bool keep_browser_alive) { … }
void ChromeBrowsingDataLifetimeManager::UpdateScheduledRemovalSettings() { … }
void ChromeBrowsingDataLifetimeManager::StartScheduledBrowsingDataRemoval() { … }
bool ChromeBrowsingDataLifetimeManager::
IsConditionSatisfiedForBrowsingDataRemoval(
const syncer::UserSelectableTypeSet sync_types) { … }