#include "chrome/browser/browsing_data/browsing_data_history_observer_service.h"
#include <tuple>
#include "base/functional/callback_helpers.h"
#include "base/memory/singleton.h"
#include "build/build_config.h"
#include "chrome/browser/browsing_data/navigation_entry_remover.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/common/buildflags.h"
#include "components/search_engines/template_url_service.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/commerce/merchant_viewer/merchant_viewer_data_manager.h"
#include "chrome/browser/commerce/merchant_viewer/merchant_viewer_data_manager_factory.h"
#include "chrome/browser/commerce/shopping_service_factory.h"
#include "components/commerce/core/shopping_service.h"
#endif
#if BUILDFLAG(ENABLE_SESSION_SERVICE)
#include "chrome/browser/sessions/session_service_factory.h"
#endif
namespace {
base::flat_set<GURL> GetDeletedOrigins(
const history::OriginCountAndLastVisitMap& urls) { … }
bool Contains(const base::flat_set<GURL>& deleted_origins,
const GURL& template_gurl) { … }
void DeleteTemplateUrlsForTimeRange(TemplateURLService* keywords_model,
base::Time delete_begin,
base::Time delete_end) { … }
void DeleteTemplateUrlsForDeletedOrigins(TemplateURLService* keywords_model,
base::flat_set<GURL> deleted_origins) { … }
#if BUILDFLAG(IS_ANDROID)
void ClearCommerceData(Profile* profile,
const history::DeletionInfo& deletion_info) {
MerchantViewerDataManager* merchant_viewer_data_manager =
MerchantViewerDataManagerFactory::GetForProfile(profile);
if (!merchant_viewer_data_manager)
return;
if (deletion_info.time_range().IsValid()) {
merchant_viewer_data_manager->DeleteMerchantViewerDataForTimeRange(
deletion_info.time_range().begin(), deletion_info.time_range().end());
} else {
auto deleted_origins =
GetDeletedOrigins(deletion_info.deleted_urls_origin_map());
merchant_viewer_data_manager->DeleteMerchantViewerDataForOrigins(
std::move(deleted_origins));
}
}
#endif
}
BrowsingDataHistoryObserverService::BrowsingDataHistoryObserverService(
Profile* profile)
: … { … }
BrowsingDataHistoryObserverService::~BrowsingDataHistoryObserverService() { … }
void BrowsingDataHistoryObserverService::OnHistoryDeletions(
history::HistoryService* history_service,
const history::DeletionInfo& deletion_info) { … }
BrowsingDataHistoryObserverService::Factory*
BrowsingDataHistoryObserverService::Factory::GetInstance() { … }
BrowsingDataHistoryObserverService::Factory::Factory()
: … { … }
std::unique_ptr<KeyedService> BrowsingDataHistoryObserverService::Factory::
BuildServiceInstanceForBrowserContext(
content::BrowserContext* context) const { … }
bool BrowsingDataHistoryObserverService::Factory::
ServiceIsCreatedWithBrowserContext() const { … }