#include "chrome/browser/extensions/api/developer_private/extension_info_generator.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_file_value_serializer.h"
#include "base/json/json_writer.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/types/optional_util.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/api/developer_private/developer_private_api.h"
#include "chrome/browser/extensions/api/developer_private/inspectable_views_finder.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/error_console/error_console.h"
#include "chrome/browser/extensions/extension_action_test_util.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_with_install.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/manifest_v2_experiment_manager.h"
#include "chrome/browser/extensions/mv2_experiment_stage.h"
#include "chrome/browser/extensions/permissions/permissions_test_util.h"
#include "chrome/browser/extensions/permissions/permissions_updater.h"
#include "chrome/browser/extensions/permissions/scripting_permissions_modifier.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_extensions_delegate_impl.h"
#include "chrome/browser/supervised_user/supervised_user_test_util.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/api/developer_private.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/crx_file/id_util.h"
#include "components/supervised_user/core/common/features.h"
#include "extensions/browser/blocklist_state.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/supervised_user_extensions_delegate.h"
#include "extensions/common/api/extension_action/action_info.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/features/feature_channel.h"
#include "extensions/common/permissions/permission_message.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/url_pattern.h"
#include "extensions/common/url_pattern_set.h"
#include "extensions/test/permissions_manager_waiter.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
namespace extensions {
ManifestLocation;
developer;
namespace {
const char kAllHostsPermission[] = …;
std::optional<base::Value::Dict> DeserializeJSONTestData(
const base::FilePath& path,
std::string* error) { … }
const developer::ExtensionInfo* GetInfoFromList(
const ExtensionInfoGenerator::ExtensionInfoList& list,
const ExtensionId& id) { … }
std::string SiteControlsToString(
const std::vector<developer::SiteControl>& controls) { … }
}
class ExtensionInfoGeneratorUnitTest : public ExtensionServiceTestWithInstall { … };
TEST_F(ExtensionInfoGeneratorUnitTest, BasicInfoTest) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, ExtensionInfoInstalledByDefault) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, ExtensionInfoInstalledByOem) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, ExtensionInfoGenerateSafetyHubData) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, GenerateExtensionsJSONData) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, RuntimeHostPermissions) { … }
TEST_F(ExtensionInfoGeneratorUnitTest,
RuntimeHostPermissionsBeyondRequestedScope) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, RuntimeHostPermissionsSpecificHosts) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, RuntimeHostPermissionsAllURLs) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, WithheldUrlsOverlapping) { … }
TEST_F(ExtensionInfoGeneratorUnitTest,
WithheldUrlsOverlappingWithContentScript) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, ActiveTabFileUrls) { … }
TEST_F(ExtensionInfoGeneratorUnitTest,
CanAccessSiteDataWithoutHostPermissions) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, RevokedOptionalPermissionsInfoTest) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, Blocklisted) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, ExtensionActionCommands) { … }
TEST_F(ExtensionInfoGeneratorUnitTest,
NoParentDisabledPermissionsForRegularUsers) { … }
TEST_F(ExtensionInfoGeneratorUnitTest, IsPinnedToToolbar) { … }
class ExtensionInfoGeneratorWithMV2DeprecationUnitTest
: public ExtensionInfoGeneratorUnitTest,
public testing::WithParamInterface<MV2ExperimentStage> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(ExtensionInfoGeneratorWithMV2DeprecationUnitTest,
DidAcknowledgeMv2DeprecationNotice) { … }
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
enum class ExtensionsParentalControlState : int { … };
enum class ExtensionManagementFamilyLinkSwitch : int { … };
class ExtensionInfoGeneratorUnitTestSupervised
: public ExtensionInfoGeneratorUnitTest,
public testing::WithParamInterface<
std::tuple<ExtensionsParentalControlState,
ExtensionManagementFamilyLinkSwitch>> { … };
TEST_P(ExtensionInfoGeneratorUnitTestSupervised,
ParentDisabledPermissionsForSupervisedUsers) { … }
INSTANTIATE_TEST_SUITE_P(…);
#endif
}