chromium/chrome/browser/browsing_data/browsing_data_history_observer_service.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// This method takes in parameter |urls|, which is a map,
// {Origin -> {Count, LastVisitTime}}, keyed by origin to the
// count of its URLs in the history and its last visit time.
// Here, we iterate over the map to return the set of origins
// which doesn't have any of its urls present in the history.
// A flat_set is returned for efficient lookups
// in the Contains method below. The insertion
// time is O(n.logn) as we invoke the move
// constructor with std::vector.
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

}  // namespace

BrowsingDataHistoryObserverService::BrowsingDataHistoryObserverService(
    Profile* profile)
    :{}

BrowsingDataHistoryObserverService::~BrowsingDataHistoryObserverService() {}

void BrowsingDataHistoryObserverService::OnHistoryDeletions(
    history::HistoryService* history_service,
    const history::DeletionInfo& deletion_info) {}

// static
BrowsingDataHistoryObserverService::Factory*
BrowsingDataHistoryObserverService::Factory::GetInstance() {}

BrowsingDataHistoryObserverService::Factory::Factory()
    :{}

std::unique_ptr<KeyedService> BrowsingDataHistoryObserverService::Factory::
    BuildServiceInstanceForBrowserContext(
        content::BrowserContext* context) const {}

bool BrowsingDataHistoryObserverService::Factory::
    ServiceIsCreatedWithBrowserContext() const {}