#include "chrome/browser/ui/bookmarks/bookmark_context_menu_controller.h"
#include <stddef.h>
#include <string>
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/feature_list.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/user_metrics.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/bookmarks/bookmark_editor.h"
#include "chrome/browser/ui/bookmarks/bookmark_utils.h"
#include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/undo/bookmark_undo_service_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
#include "components/bookmarks/browser/bookmark_client.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/browser/scoped_group_bookmark_actions.h"
#include "components/bookmarks/common/bookmark_metrics.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/bookmarks/managed/managed_bookmark_service.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/saved_tab_groups/features.h"
#include "components/strings/grit/components_strings.h"
#include "components/tab_groups/tab_group_visual_data.h"
#include "components/undo/bookmark_undo_service.h"
#include "content/public/browser/page_navigator.h"
#include "ui/base/l10n/l10n_util.h"
UserMetricsAction;
BookmarkNode;
namespace {
constexpr UserMetricsAction kBookmarkBarNewBackgroundTab(
"BookmarkBar_ContextMenu_OpenAll");
constexpr UserMetricsAction kBookmarkBarNewWindow(
"BookmarkBar_ContextMenu_OpenAllInNewWindow");
constexpr UserMetricsAction kBookmarkBarIncognito(
"BookmarkBar_ContextMenu_OpenAllIncognito");
constexpr UserMetricsAction kAppMenuBookmarksNewBackgroundTab(
"WrenchMenu_Bookmarks_ContextMenu_OpenAll");
constexpr UserMetricsAction kAppMenuBookmarksNewWindow(
"WrenchMenu_Bookmarks_ContextMenu_OpenAllInNewWindow");
constexpr UserMetricsAction kAppMenuBookmarksIncognito(
"WrenchMenu_Bookmarks_ContextMenu_OpenAllIncognito");
constexpr UserMetricsAction kSidePanelBookmarksNewBackgroundTab(
"SidePanel_Bookmarks_ContextMenu_OpenAll");
constexpr UserMetricsAction kSidePanelBookmarksNewWindow(
"SidePanel_Bookmarks_ContextMenu_OpenAllInNewWindow");
constexpr UserMetricsAction kSidePanelBookmarksIncognito(
"SidePanel_Bookmarks_ContextMenu_OpenAllIncognito");
const UserMetricsAction* GetActionForLocationAndDisposition(
BookmarkLaunchLocation location,
WindowOpenDisposition disposition) { … }
}
BookmarkContextMenuController::BookmarkContextMenuController(
gfx::NativeWindow parent_window,
BookmarkContextMenuControllerDelegate* delegate,
Browser* browser,
Profile* profile,
BookmarkLaunchLocation opened_from,
const BookmarkNode* parent,
const std::vector<raw_ptr<const BookmarkNode, VectorExperimental>>&
selection)
: … { … }
BookmarkContextMenuController::~BookmarkContextMenuController() { … }
void BookmarkContextMenuController::BuildMenu() { … }
void BookmarkContextMenuController::AddItem(int id, const std::u16string str) { … }
void BookmarkContextMenuController::AddItem(int id, int localization_id) { … }
void BookmarkContextMenuController::AddSeparator() { … }
void BookmarkContextMenuController::AddCheckboxItem(int id,
int localization_id) { … }
void BookmarkContextMenuController::ExecuteCommand(int id, int event_flags) { … }
bool BookmarkContextMenuController::IsItemForCommandIdDynamic(int command_id)
const { … }
std::u16string BookmarkContextMenuController::GetLabelForCommandId(
int command_id) const { … }
bool BookmarkContextMenuController::IsCommandIdChecked(int command_id) const { … }
bool BookmarkContextMenuController::IsCommandIdEnabled(int command_id) const { … }
bool BookmarkContextMenuController::IsCommandIdVisible(int command_id) const { … }
void BookmarkContextMenuController::BookmarkModelChanged() { … }