#include "extensions/browser/api/management/management_api.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/types/expected_macros.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/supervised_user/core/common/buildflags.h"
#include "components/supervised_user/core/common/features.h"
#include "content/public/browser/browser_context.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/management/management_api_constants.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/management_policy.h"
#include "extensions/browser/requirements_checker.h"
#include "extensions/browser/supervised_user_extensions_delegate.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/api/management.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/icons/extension_icon_set.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "extensions/common/manifest_handlers/offline_enabled_info.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/manifest_handlers/replacement_apps.h"
#include "extensions/common/manifest_url_handlers.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "extensions/common/permissions/permission_message.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/url_pattern.h"
#include "services/data_decoder/public/cpp/data_decoder.h"
#include "url/gurl.h"
#include "url/url_constants.h"
BrowserThread;
ManifestLocation;
keys;
namespace extensions {
management;
namespace {
ExtensionInfoList;
IconInfoList;
enum AutoConfirmForTest { … };
AutoConfirmForTest auto_confirm_for_test = …;
bool ShouldExposeViaManagementAPI(const Extension& extension) { … }
std::vector<std::string> CreateWarningsList(const Extension* extension) { … }
std::vector<management::LaunchType> GetAvailableLaunchTypes(
const Extension& extension,
const ManagementAPIDelegate* delegate) { … }
management::ExtensionInfo CreateExtensionInfo(
const Extension* source_extension,
const Extension& extension,
content::BrowserContext* context) { … }
void AddExtensionInfo(const Extension* source_extension,
const ExtensionSet& extensions,
ExtensionInfoList* extension_list,
content::BrowserContext* context) { … }
bool PlatformSupportsApprovalFlowForExtensions() { … }
}
ExtensionFunction::ResponseAction ManagementGetAllFunction::Run() { … }
ExtensionFunction::ResponseAction ManagementGetFunction::Run() { … }
ExtensionFunction::ResponseAction ManagementGetSelfFunction::Run() { … }
ExtensionFunction::ResponseAction
ManagementGetPermissionWarningsByIdFunction::Run() { … }
ExtensionFunction::ResponseAction
ManagementGetPermissionWarningsByManifestFunction::Run() { … }
void ManagementGetPermissionWarningsByManifestFunction::OnParse(
data_decoder::DataDecoder::ValueOrError result) { … }
ExtensionFunction::ResponseAction ManagementLaunchAppFunction::Run() { … }
ManagementSetEnabledFunction::ManagementSetEnabledFunction() = default;
ManagementSetEnabledFunction::~ManagementSetEnabledFunction() = default;
ExtensionFunction::ResponseAction ManagementSetEnabledFunction::Run() { … }
void ManagementSetEnabledFunction::CheckRequirements(
const Extension& extension) { … }
void ManagementSetEnabledFunction::OnRequirementsChecked(
const PreloadCheck::Errors& errors) { … }
void ManagementSetEnabledFunction::CheckPermissionsIncrease() { … }
void ManagementSetEnabledFunction::OnPermissionsIncreaseChecked(
bool permissions_allowed) { … }
void ManagementSetEnabledFunction::CheckManifestV2Deprecation() { … }
void ManagementSetEnabledFunction::OnManifestV2DeprecationChecked(
bool enable_allowed) { … }
void ManagementSetEnabledFunction::FinishEnable(ResponseValue response_value) { … }
bool ManagementSetEnabledFunction::HasUnsupportedRequirements(
const ExtensionId& extension_id) const { … }
bool ManagementSetEnabledFunction::IsSupervisedExtensionApprovalFlowRequired(
const Extension* target_extension) const { … }
void ManagementSetEnabledFunction::OnSupervisedExtensionApprovalDone(
SupervisedUserExtensionsDelegate::ExtensionApprovalResult result) { … }
const Extension* ManagementSetEnabledFunction::GetExtension() { … }
ManagementUninstallFunctionBase::ManagementUninstallFunctionBase() = default;
ManagementUninstallFunctionBase::~ManagementUninstallFunctionBase() = default;
bool ManagementUninstallFunctionBase::ShouldKeepWorkerAliveIndefinitely() { … }
ExtensionFunction::ResponseAction ManagementUninstallFunctionBase::Uninstall(
const std::string& target_extension_id,
bool show_confirm_dialog) { … }
void ManagementUninstallFunctionBase::Finish(bool did_start_uninstall,
const std::string& error) { … }
void ManagementUninstallFunctionBase::OnExtensionUninstallDialogClosed(
bool did_start_uninstall,
const std::u16string& error) { … }
void ManagementUninstallFunctionBase::UninstallExtension() { … }
ManagementUninstallFunction::ManagementUninstallFunction() { … }
ManagementUninstallFunction::~ManagementUninstallFunction() { … }
ExtensionFunction::ResponseAction ManagementUninstallFunction::Run() { … }
ManagementUninstallSelfFunction::ManagementUninstallSelfFunction() { … }
ManagementUninstallSelfFunction::~ManagementUninstallSelfFunction() { … }
ExtensionFunction::ResponseAction ManagementUninstallSelfFunction::Run() { … }
ManagementCreateAppShortcutFunction::ManagementCreateAppShortcutFunction() { … }
ManagementCreateAppShortcutFunction::~ManagementCreateAppShortcutFunction() { … }
void ManagementCreateAppShortcutFunction::SetAutoConfirmForTest(
bool should_proceed) { … }
void ManagementCreateAppShortcutFunction::OnCloseShortcutPrompt(bool created) { … }
ExtensionFunction::ResponseAction ManagementCreateAppShortcutFunction::Run() { … }
ExtensionFunction::ResponseAction ManagementSetLaunchTypeFunction::Run() { … }
ManagementGenerateAppForLinkFunction::ManagementGenerateAppForLinkFunction() =
default;
ManagementGenerateAppForLinkFunction::~ManagementGenerateAppForLinkFunction() =
default;
void ManagementGenerateAppForLinkFunction::FinishCreateWebApp(
const std::string& web_app_id,
bool install_success) { … }
ExtensionFunction::ResponseAction ManagementGenerateAppForLinkFunction::Run() { … }
ManagementInstallReplacementWebAppFunction::
ManagementInstallReplacementWebAppFunction() { … }
ManagementInstallReplacementWebAppFunction::
~ManagementInstallReplacementWebAppFunction() { … }
ExtensionFunction::ResponseAction
ManagementInstallReplacementWebAppFunction::Run() { … }
void ManagementInstallReplacementWebAppFunction::FinishResponse(
ManagementAPIDelegate::InstallOrLaunchWebAppResult result) { … }
ManagementEventRouter::ManagementEventRouter(content::BrowserContext* context)
: … { … }
ManagementEventRouter::~ManagementEventRouter() = default;
void ManagementEventRouter::OnExtensionLoaded(
content::BrowserContext* browser_context,
const Extension* extension) { … }
void ManagementEventRouter::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionReason reason) { … }
void ManagementEventRouter::OnExtensionInstalled(
content::BrowserContext* browser_context,
const Extension* extension,
bool is_update) { … }
void ManagementEventRouter::OnExtensionUninstalled(
content::BrowserContext* browser_context,
const Extension* extension,
extensions::UninstallReason reason) { … }
void ManagementEventRouter::BroadcastEvent(
const Extension* extension,
events::HistogramValue histogram_value,
const char* event_name) { … }
ManagementAPI::ManagementAPI(content::BrowserContext* context)
: … { … }
ManagementAPI::~ManagementAPI() { … }
void ManagementAPI::Shutdown() { … }
static base::LazyInstance<
BrowserContextKeyedAPIFactory<ManagementAPI>>::DestructorAtExit g_factory = …;
BrowserContextKeyedAPIFactory<ManagementAPI>*
ManagementAPI::GetFactoryInstance() { … }
void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { … }
}