#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/ui/webui/history/history_ui.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/commerce/shopping_service_factory.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/history_embeddings/history_embeddings_utils.h"
#include "chrome/browser/page_image_service/image_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/commerce/shopping_ui_handler_delegate.h"
#include "chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.h"
#include "chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/history/browsing_history_handler.h"
#include "chrome/browser/ui/webui/history/foreign_session_handler.h"
#include "chrome/browser/ui/webui/history/history_login_handler.h"
#include "chrome/browser/ui/webui/history/navigation_handler.h"
#include "chrome/browser/ui/webui/history_clusters/history_clusters_handler.h"
#include "chrome/browser/ui/webui/managed_ui_handler.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/history_resources.h"
#include "chrome/grit/history_resources_map.h"
#include "chrome/grit/locale_settings.h"
#include "components/commerce/core/feature_utils.h"
#include "components/commerce/core/shopping_service.h"
#include "components/commerce/core/webui/shopping_service_handler.h"
#include "components/favicon_base/favicon_url_parser.h"
#include "components/grit/components_scaled_resources.h"
#include "components/history/core/common/pref_names.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/page_image_service/image_service.h"
#include "components/page_image_service/image_service_handler.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/webui/resources/cr_components/commerce/shopping_service.mojom.h"
namespace {
constexpr char kIsUserSignedInKey[] = …;
bool IsUserSignedIn(Profile* profile) { … }
content::WebUIDataSource* CreateAndAddHistoryUIHTMLSource(Profile* profile) { … }
}
HistoryUIConfig::HistoryUIConfig()
: … { … }
HistoryUIConfig::~HistoryUIConfig() = default;
std::unique_ptr<content::WebUIController>
HistoryUIConfig::CreateWebUIController(content::WebUI* web_ui,
const GURL& url) { … }
HistoryUI::HistoryUI(content::WebUI* web_ui)
: … { … }
HistoryUI::~HistoryUI() = default;
WEB_UI_CONTROLLER_TYPE_IMPL(HistoryUI)
base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
ui::ResourceScaleFactor scale_factor) { … }
void HistoryUI::BindInterface(
mojo::PendingReceiver<history_embeddings::mojom::PageHandler>
pending_page_handler) { … }
void HistoryUI::BindInterface(
mojo::PendingReceiver<history_clusters::mojom::PageHandler>
pending_page_handler) { … }
void HistoryUI::BindInterface(
mojo::PendingReceiver<page_image_service::mojom::PageImageServiceHandler>
pending_page_handler) { … }
void HistoryUI::BindInterface(
mojo::PendingReceiver<
shopping_service::mojom::ShoppingServiceHandlerFactory> receiver) { … }
void HistoryUI::CreateShoppingServiceHandler(
mojo::PendingRemote<shopping_service::mojom::Page> page,
mojo::PendingReceiver<shopping_service::mojom::ShoppingServiceHandler>
receiver) { … }
void HistoryUI::UpdateDataSource() { … }
void HistoryUI::BindInterface(
mojo::PendingReceiver<help_bubble::mojom::HelpBubbleHandlerFactory>
pending_receiver) { … }
void HistoryUI::CreateHelpBubbleHandler(
mojo::PendingRemote<help_bubble::mojom::HelpBubbleClient> client,
mojo::PendingReceiver<help_bubble::mojom::HelpBubbleHandler> handler) { … }