#include "chrome/browser/ui/toolbar/back_forward_menu_model.h"
#include <stddef.h>
#include <algorithm>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "components/favicon_base/favicon_types.h"
#include "components/feature_engagement/public/feature_constants.h"
#include "components/grit/components_scaled_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "ui/base/accelerators/menu_label_accelerator_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/window_open_disposition.h"
#include "ui/base/window_open_disposition_utils.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/text_elider.h"
UserMetricsAction;
NavigationController;
NavigationEntry;
WebContents;
const size_t BackForwardMenuModel::kMaxHistoryItems = …;
const size_t BackForwardMenuModel::kMaxChapterStops = …;
static const int kMaxBackForwardMenuWidth = …;
const char kBackNavigationMenuIsOpenedEvent[] = …;
BackForwardMenuModel::BackForwardMenuModel(Browser* browser,
ModelType model_type)
: … { … }
BackForwardMenuModel::~BackForwardMenuModel() = default;
base::WeakPtr<ui::MenuModel> BackForwardMenuModel::AsWeakPtr() { … }
size_t BackForwardMenuModel::GetItemCount() const { … }
ui::MenuModel::ItemType BackForwardMenuModel::GetTypeAt(size_t index) const { … }
ui::MenuSeparatorType BackForwardMenuModel::GetSeparatorTypeAt(
size_t index) const { … }
int BackForwardMenuModel::GetCommandIdAt(size_t index) const { … }
std::u16string BackForwardMenuModel::GetLabelAt(size_t index) const { … }
bool BackForwardMenuModel::IsItemDynamicAt(size_t index) const { … }
bool BackForwardMenuModel::GetAcceleratorAt(
size_t index,
ui::Accelerator* accelerator) const { … }
bool BackForwardMenuModel::IsItemCheckedAt(size_t index) const { … }
int BackForwardMenuModel::GetGroupIdAt(size_t index) const { … }
ui::ImageModel BackForwardMenuModel::GetIconAt(size_t index) const { … }
ui::ButtonMenuItemModel* BackForwardMenuModel::GetButtonMenuItemAt(
size_t index) const { … }
bool BackForwardMenuModel::IsEnabledAt(size_t index) const { … }
ui::MenuModel* BackForwardMenuModel::GetSubmenuModelAt(size_t index) const { … }
void BackForwardMenuModel::ActivatedAt(size_t index) { … }
void BackForwardMenuModel::ActivatedAt(size_t index, int event_flags) { … }
void BackForwardMenuModel::MenuWillShow() { … }
void BackForwardMenuModel::MenuWillClose() { … }
void BackForwardMenuModel::NavigationEntryCommitted(
const content::LoadCommittedDetails& load_details) { … }
void BackForwardMenuModel::NavigationEntriesDeleted() { … }
bool BackForwardMenuModel::IsSeparator(size_t index) const { … }
void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) { … }
void BackForwardMenuModel::OnFavIconDataAvailable(
int navigation_entry_unique_id,
const favicon_base::FaviconImageResult& image_result) { … }
size_t BackForwardMenuModel::GetHistoryItemCount() const { … }
size_t BackForwardMenuModel::GetChapterStopCount(size_t history_items) const { … }
std::optional<size_t> BackForwardMenuModel::GetIndexOfNextChapterStop(
size_t start_from,
bool forward) const { … }
std::optional<size_t> BackForwardMenuModel::FindChapterStop(size_t offset,
bool forward,
size_t skip) const { … }
bool BackForwardMenuModel::ItemHasCommand(size_t index) const { … }
bool BackForwardMenuModel::ItemHasIcon(size_t index) const { … }
std::u16string BackForwardMenuModel::GetShowFullHistoryLabel() const { … }
WebContents* BackForwardMenuModel::GetWebContents() const { … }
std::optional<size_t> BackForwardMenuModel::MenuIndexToNavEntryIndex(
size_t index) const { … }
NavigationEntry* BackForwardMenuModel::GetNavigationEntry(size_t index) const { … }
std::string BackForwardMenuModel::BuildActionName(
const std::string& action,
std::optional<size_t> index) const { … }
bool BackForwardMenuModel::ShouldShowFullHistoryBeVisible() const { … }