#include "chrome/browser/ui/views/extensions/extensions_menu_main_page_view.h"
#include <memory>
#include <string>
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/user_metrics.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/extensions/extension_action_view_controller.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/controls/hover_button.h"
#include "chrome/browser/ui/views/extensions/extensions_dialogs_utils.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_handler.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_item_view.h"
#include "chrome/grit/generated_resources.h"
#include "components/vector_icons/vector_icons.h"
#include "extensions/common/extension_id.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/text_constants.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/bubble/tooltip_icon.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/separator.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/flex_layout_view.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/style/typography.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
#include "extensions/common/extension_urls.h"
#endif
namespace {
std::u16string GetSiteSettingToggleText(bool is_on) { … }
ExtensionMenuItemView* GetAsMenuItem(views::View* view) { … }
ExtensionMenuItemView* GetMenuItem(
views::View* parent_view,
const ToolbarActionsModel::ActionId& action_id) { … }
}
class MessageSection : public views::BoxLayoutView { … };
BEGIN_VIEW_BUILDER(, MessageSection, views::BoxLayoutView)
END_VIEW_BUILDER
DEFINE_VIEW_BUILDER(…)
MessageSection::MessageSection(
base::RepeatingCallback<void()> reload_callback,
base::RepeatingCallback<void(const extensions::ExtensionId&)>
allow_callback,
base::RepeatingCallback<void(const extensions::ExtensionId&)>
dismiss_callback)
: … { … }
void MessageSection::Update(
ExtensionsMenuMainPageView::MessageSectionState state,
bool has_enterprise_extensions) { … }
void MessageSection::UpdateContainer(ContainerType container_type,
int label_id,
bool show_label_tooltip) { … }
void MessageSection::AddOrUpdateExtension(const extensions::ExtensionId& id,
const std::u16string& name,
const ui::ImageModel& icon,
int index) { … }
void MessageSection::RemoveExtension(const extensions::ExtensionId& id) { … }
void MessageSection::ClearExtensions() { … }
void MessageSection::UpdateVisibility() { … }
std::vector<extensions::ExtensionId> MessageSection::GetExtensionsForTesting() { … }
views::View* MessageSection::GetExtensionEntryForTesting(
const extensions::ExtensionId& extension_id) { … }
ExtensionsMenuMainPageView::ExtensionsMenuMainPageView(
Browser* browser,
ExtensionsMenuHandler* menu_handler)
: … { … }
void ExtensionsMenuMainPageView::CreateAndInsertMenuItem(
std::unique_ptr<ExtensionActionViewController> action_controller,
extensions::ExtensionId extension_id,
bool is_enterprise,
ExtensionMenuItemView::SiteAccessToggleState site_access_toggle_state,
ExtensionMenuItemView::SitePermissionsButtonState
site_permissions_button_state,
ExtensionMenuItemView::SitePermissionsButtonAccess
site_permissions_button_access,
int index) { … }
void ExtensionsMenuMainPageView::RemoveMenuItem(
const ToolbarActionsModel::ActionId& action_id) { … }
void ExtensionsMenuMainPageView::UpdateSiteSettings(
const std::u16string& current_site,
bool is_site_settings_toggle_visible,
bool is_site_settings_toggle_on) { … }
void ExtensionsMenuMainPageView::UpdateMessageSection(
MessageSectionState state,
bool has_enterprise_extensions) { … }
ExtensionsMenuMainPageView::MessageSectionState
ExtensionsMenuMainPageView::GetMessageSectionState() { … }
void ExtensionsMenuMainPageView::AddOrUpdateExtensionRequestingAccess(
const extensions::ExtensionId& id,
const std::u16string& name,
const ui::ImageModel& icon,
int index) { … }
void ExtensionsMenuMainPageView::RemoveExtensionRequestingAccess(
const extensions::ExtensionId& id) { … }
void ExtensionsMenuMainPageView::ClearExtensionsRequestingAccess() { … }
std::vector<ExtensionMenuItemView*> ExtensionsMenuMainPageView::GetMenuItems()
const { … }
const std::u16string&
ExtensionsMenuMainPageView::GetSiteSettingLabelForTesting() const { … }
views::View* ExtensionsMenuMainPageView::GetTextContainerForTesting() { … }
views::View* ExtensionsMenuMainPageView::GetReloadContainerForTesting() { … }
views::View*
ExtensionsMenuMainPageView::GetRequestsAccessContainerForTesting() { … }
std::vector<extensions::ExtensionId>
ExtensionsMenuMainPageView::GetExtensionsRequestingAccessForTesting() { … }
views::View*
ExtensionsMenuMainPageView::GetExtensionRequestingAccessEntryForTesting(
const extensions::ExtensionId& extension_id) { … }
content::WebContents* ExtensionsMenuMainPageView::GetActiveWebContents() const { … }
BEGIN_METADATA(…)