chromium/chrome/browser/ui/views/extensions/extensions_menu_view_controller.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/extensions/extensions_menu_view_controller.h"

#include <algorithm>

#include "base/functional/bind.h"
#include "base/i18n/case_conversion.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/notreached.h"
#include "chrome/browser/extensions/extension_action_runner.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/permissions/site_permissions_helper.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/extensions/extension_action_view_controller.h"
#include "chrome/browser/ui/extensions/extensions_container.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/extensions/extensions_dialogs_utils.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_item_view.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_main_page_view.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_site_permissions_page_view.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/permissions_manager.h"
#include "extensions/common/extension_id.h"
#include "ui/base/metadata/metadata_types.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/view_utils.h"
#include "ui/views/widget/widget.h"

namespace {

PermissionsManager;
SitePermissionsHelper;

// Returns the extension for `extension_id`.
const extensions::Extension* GetExtension(
    Browser* browser,
    extensions::ExtensionId extension_id) {}

// Returns sorted extension ids based on their extensions name.
std::vector<std::string> SortExtensionsByName(
    ToolbarActionsModel& toolbar_model) {}

// Returns the index of `action_id` in the toolbar model actions based on the
// extensions name alphabetical order.
size_t FindIndex(ToolbarActionsModel& toolbar_model,
                 const ToolbarActionsModel::ActionId& action_id) {}

// Returns the main page, if it is the correct type.
ExtensionsMenuMainPageView* GetMainPage(views::View* page) {}

// Returns the site permissions page, if it is the correct type.
ExtensionsMenuSitePermissionsPageView* GetSitePermissionsPage(
    views::View* page) {}

// Returns whether `extension` cannot have its site access modified by the user
// because of policy.
bool HasEnterpriseForcedAccess(const extensions::Extension& extension,
                               Profile& profile) {}

// Returns whether the site setting toggle for `web_contents` should be visible.
bool IsSiteSettingsToggleVisible(const ToolbarActionsModel& toolbar_model,
                                 content::WebContents* web_contents) {}

// Returns whether the site settings toggle for `web_contents` should be on.
bool IsSiteSettingsToggleOn(Browser* browser,
                            content::WebContents* web_contents) {}

// Returns whether the site permissions button should be visible.
bool IsSitePermissionsButtonVisible(const extensions::Extension& extension,
                                    Profile& profile,
                                    const ToolbarActionsModel& toolbar_model,
                                    content::WebContents& web_contents) {}

// Returns whether user can select the site access for `extension` on
// `web_contents`.
bool CanUserCustomizeExtensionSiteAccess(
    const extensions::Extension& extension,
    Profile& profile,
    const ToolbarActionsModel& toolbar_model,
    content::WebContents& web_contents) {}

// Returns the state for the `extension`'s site permissions button.
ExtensionMenuItemView::SitePermissionsButtonState GetSitePermissionsButtonState(
    const extensions::Extension& extension,
    Profile& profile,
    const ToolbarActionsModel& toolbar_model,
    content::WebContents& web_contents) {}

// Returns the sites access displayed by the `extension`'s site permissions
// button.
ExtensionMenuItemView::SitePermissionsButtonAccess
GetSitePermissionsButtonAccess(const extensions::Extension& extension,
                               Profile& profile,
                               const ToolbarActionsModel& toolbar_model,
                               content::WebContents& web_contents) {}

// Returns the state for the `extension`'s site access toggle button.
ExtensionMenuItemView::SiteAccessToggleState GetSiteAccessToggleState(
    const extensions::Extension& extension,
    Profile& profile,
    const ToolbarActionsModel& toolbar_model,
    content::WebContents& web_contents) {}

// Returns the state for the message section in the menu.
ExtensionsMenuMainPageView::MessageSectionState GetMessageSectionState(
    Profile& profile,
    const ToolbarActionsModel& toolbar_model,
    content::WebContents& web_contents) {}

void LogSiteAccessUpdate(PermissionsManager::UserSiteAccess site_access) {}

}  // namespace

ExtensionsMenuViewController::ExtensionsMenuViewController(
    Browser* browser,
    ExtensionsContainer* extensions_container,
    views::View* bubble_contents,
    views::BubbleDialogDelegate* bubble_delegate)
    :{}

ExtensionsMenuViewController::~ExtensionsMenuViewController() {}

void ExtensionsMenuViewController::OpenMainPage() {}

void ExtensionsMenuViewController::OpenSitePermissionsPage(
    const extensions::ExtensionId& extension_id) {}

void ExtensionsMenuViewController::CloseBubble() {}

void ExtensionsMenuViewController::OnSiteAccessSelected(
    const extensions::ExtensionId& extension_id,
    PermissionsManager::UserSiteAccess site_access) {}

void ExtensionsMenuViewController::OnSiteSettingsToggleButtonPressed(
    bool is_on) {}

void ExtensionsMenuViewController::OnExtensionToggleSelected(
    const extensions::ExtensionId& extension_id,
    bool is_on) {}

void ExtensionsMenuViewController::OnReloadPageButtonClicked() {}

void ExtensionsMenuViewController::OnAllowExtensionClicked(
    const extensions::ExtensionId& extension_id) {}

void ExtensionsMenuViewController::OnDismissExtensionClicked(
    const extensions::ExtensionId& extension_id) {}

void ExtensionsMenuViewController::OnShowRequestsTogglePressed(
    const extensions::ExtensionId& extension_id,
    bool is_on) {}

void ExtensionsMenuViewController::TabChangedAt(content::WebContents* contents,
                                                int index,
                                                TabChangeType change_type) {}

void ExtensionsMenuViewController::OnTabStripModelChanged(
    TabStripModel* tab_strip_model,
    const TabStripModelChange& change,
    const TabStripSelectionChange& selection) {}

void ExtensionsMenuViewController::UpdatePage(
    content::WebContents* web_contents) {}

void ExtensionsMenuViewController::UpdateMainPage(
    ExtensionsMenuMainPageView* main_page,
    content::WebContents* web_contents) {}

void ExtensionsMenuViewController::UpdateSitePermissionsPage(
    ExtensionsMenuSitePermissionsPageView* site_permissions_page,
    content::WebContents* web_contents) {}

void ExtensionsMenuViewController::OnToolbarActionAdded(
    const ToolbarActionsModel::ActionId& action_id) {}

void ExtensionsMenuViewController::OnToolbarActionRemoved(
    const ToolbarActionsModel::ActionId& action_id) {}

void ExtensionsMenuViewController::OnToolbarActionUpdated(
    const ToolbarActionsModel::ActionId& action_id) {}

void ExtensionsMenuViewController::OnToolbarModelInitialized() {}

void ExtensionsMenuViewController::OnToolbarPinnedActionsChanged() {}

void ExtensionsMenuViewController::OnUserPermissionsSettingsChanged(
    const PermissionsManager::UserPermissionsSettings& settings) {}

void ExtensionsMenuViewController::OnShowAccessRequestsInToolbarChanged(
    const extensions::ExtensionId& extension_id,
    bool can_show_requests) {}

void ExtensionsMenuViewController::OnSiteAccessRequestDismissedByUser(
    const extensions::ExtensionId& extension_id,
    const url::Origin& origin) {}

void ExtensionsMenuViewController::OnSiteAccessRequestAdded(
    const extensions::ExtensionId& extension_id,
    int tab_id) {}

void ExtensionsMenuViewController::OnSiteAccessRequestUpdated(
    const extensions::ExtensionId& extension_id,
    int tab_id) {}

void ExtensionsMenuViewController::OnSiteAccessRequestRemoved(
    const extensions::ExtensionId& extension_id,
    int tab_id) {}

void ExtensionsMenuViewController::OnSiteAccessRequestsCleared(int tab_id) {}

ExtensionsMenuMainPageView*
ExtensionsMenuViewController::GetMainPageViewForTesting() {}

ExtensionsMenuSitePermissionsPageView*
ExtensionsMenuViewController::GetSitePermissionsPageForTesting() {}

void ExtensionsMenuViewController::SwitchToPage(
    std::unique_ptr<views::View> page) {}

void ExtensionsMenuViewController::PopulateMainPage(
    ExtensionsMenuMainPageView* main_page) {}

void ExtensionsMenuViewController::InsertMenuItemMainPage(
    ExtensionsMenuMainPageView* main_page,
    const extensions::ExtensionId& extension_id,
    int index) {}

void ExtensionsMenuViewController::AddOrUpdateExtensionRequestingAccess(
    ExtensionsMenuMainPageView* main_page,
    const extensions::ExtensionId& extension_id,
    int index,
    content::WebContents* web_contents) {}

content::WebContents* ExtensionsMenuViewController::GetActiveWebContents()
    const {}