#include "chrome/browser/ui/webui/history/browsing_history_handler.h"
#include <stddef.h>
#include <optional>
#include <set>
#include "base/check_deref.h"
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/i18n/rtl.h"
#include "base/i18n/time_formatting.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/favicon/large_icon_service_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history/history_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/sync/device_info_sync_service_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/url_identity.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/pref_names.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/favicon/core/fallback_url_util.h"
#include "components/favicon/core/large_icon_service.h"
#include "components/favicon_base/favicon_url_parser.h"
#include "components/history_clusters/core/config.h"
#include "components/history_clusters/core/features.h"
#include "components/history_clusters/core/history_clusters_prefs.h"
#include "components/history_embeddings/history_embeddings_features.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/prefs/pref_service.h"
#include "components/query_parser/snippet.h"
#include "components/strings/grit/components_strings.h"
#include "components/supervised_user/core/browser/supervised_user_preferences.h"
#include "components/supervised_user/core/browser/supervised_user_service.h"
#include "components/supervised_user/core/browser/supervised_user_url_filter.h"
#include "components/sync/protocol/sync_enums.pb.h"
#include "components/sync/service/sync_service.h"
#include "components/sync_device_info/device_info.h"
#include "components/sync_device_info/device_info_sync_service.h"
#include "components/sync_device_info/device_info_tracker.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/time_format.h"
BookmarkModel;
BrowsingHistoryService;
HistoryService;
WebHistoryService;
namespace {
static const char kDeviceTypeLaptop[] = …;
static const char kDeviceTypePhone[] = …;
static const char kDeviceTypeTablet[] = …;
void GetDeviceNameAndType(const syncer::DeviceInfoTracker* tracker,
const std::string& client_id, std::string* name,
std::string* type) { … }
void SetHistoryEntryUrlAndTitle(
const BrowsingHistoryService::HistoryEntry& entry,
base::Value::Dict* result) { … }
bool IsUrlInLocalDatabase(const BrowsingHistoryService::HistoryEntry& entry) { … }
bool IsEntryInRemoteUserData(
const BrowsingHistoryService::HistoryEntry& entry) { … }
constexpr UrlIdentity::TypeSet allowed_types = …;
constexpr UrlIdentity::FormatOptions url_identity_options{ … };
base::Value::Dict HistoryEntryToValue(
const BrowsingHistoryService::HistoryEntry& entry,
BookmarkModel* bookmark_model, Profile& profile,
const syncer::DeviceInfoTracker* tracker, base::Clock* clock) { … }
}
BrowsingHistoryHandler::BrowsingHistoryHandler()
: … { … }
BrowsingHistoryHandler::~BrowsingHistoryHandler() = default;
void BrowsingHistoryHandler::OnJavascriptAllowed() { … }
void BrowsingHistoryHandler::OnJavascriptDisallowed() { … }
void BrowsingHistoryHandler::RegisterMessages() { … }
void BrowsingHistoryHandler::StartQueryHistory() { … }
void BrowsingHistoryHandler::HandleQueryHistory(const base::Value::List& args) { … }
void BrowsingHistoryHandler::SendHistoryQuery(
int max_count, const std::u16string& query,
std::optional<double> begin_timestamp) { … }
void BrowsingHistoryHandler::HandleQueryHistoryContinuation(
const base::Value::List& args) { … }
void BrowsingHistoryHandler::HandleRemoveVisits(const base::Value::List& args) { … }
void BrowsingHistoryHandler::HandleClearBrowsingData(
const base::Value::List& args) { … }
void BrowsingHistoryHandler::HandleRemoveBookmark(
const base::Value::List& args) { … }
void BrowsingHistoryHandler::HandleSetLastSelectedTab(
const base::Value::List& args) { … }
void BrowsingHistoryHandler::OnQueryComplete(
const std::vector<BrowsingHistoryService::HistoryEntry>& results,
const BrowsingHistoryService::QueryResultsInfo& query_results_info,
base::OnceClosure continuation_closure) { … }
void BrowsingHistoryHandler::OnRemoveVisitsComplete() { … }
void BrowsingHistoryHandler::OnRemoveVisitsFailed() { … }
void BrowsingHistoryHandler::HistoryDeleted() { … }
void BrowsingHistoryHandler::HasOtherFormsOfBrowsingHistory(
bool has_other_forms, bool has_synced_results) { … }
Profile* BrowsingHistoryHandler::GetProfile() { … }