#include "chrome/browser/extensions/extension_management.h"
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "chrome/browser/extensions/cws_info_service.h"
#include "chrome/browser/extensions/extension_management_internal.h"
#include "chrome/browser/extensions/extension_management_test_util.h"
#include "chrome/browser/extensions/external_policy_loader.h"
#include "chrome/browser/extensions/standard_management_policy_provider.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "extensions/common/url_pattern.h"
#include "extensions/common/url_pattern_set.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
APIPermissionID;
ManifestLocation;
namespace extensions {
namespace {
const char kTargetExtension[] = …;
const char kTargetExtension2[] = …;
const char kTargetExtension3[] = …;
const char kTargetExtension4[] = …;
const char kTargetExtension5[] = …;
const char kTargetExtension6[] = …;
const char kTargetExtension7[] = …;
const char kTargetExtension8[] = …;
const char kTargetExtension9[] = …;
const char kExampleUpdateUrl[] = …;
const char kNonExistingExtension[] = …;
const char kNonExistingUpdateUrl[] = …;
const char kExampleForceInstalledDictPreference[] = …;
const char kExampleDictPreferenceWithoutInstallationMode[] = …;
const char kExampleDictPreferenceWithMultipleEntries[] = …;
const char kExampleDictPreference[] = …;
const char kExampleDictNoCustomError[] = …;
}
class ExtensionManagementServiceTest : public testing::Test { … };
class MockCWSInfoService : public CWSInfoServiceInterface { … };
class ExtensionAdminPolicyTest : public ExtensionManagementServiceTest { … };
bool ExtensionAdminPolicyTest::BlocklistedByDefault(
const base::Value::List* blocklist) { … }
bool ExtensionAdminPolicyTest::UserMayLoad(
const base::Value::List* blocklist,
const base::Value::List* allowlist,
const base::Value::List* allowed_types,
const Extension* extension,
std::u16string* error) { … }
bool ExtensionAdminPolicyTest::UserMayModifySettings(const Extension* extension,
std::u16string* error) { … }
bool ExtensionAdminPolicyTest::ExtensionMayModifySettings(
const Extension* source_extension,
const Extension* extension,
std::u16string* error) { … }
bool ExtensionAdminPolicyTest::MustRemainEnabled(const Extension* extension,
std::u16string* error) { … }
TEST_F(ExtensionManagementServiceTest, LegacyInstallSources) { … }
TEST_F(ExtensionManagementServiceTest, LegacyAllowedTypes) { … }
TEST_F(ExtensionManagementServiceTest, LegacyInstallBlocklist) { … }
TEST_F(ExtensionManagementServiceTest, LegacyAllowlist) { … }
TEST_F(ExtensionManagementServiceTest, LegacyInstallForcelist) { … }
TEST_F(ExtensionManagementServiceTest,
InstallUpdateUrlEnforcedForceInstalledPref) { … }
TEST_F(ExtensionManagementServiceTest,
InstallUpdateUrlEnforcedForceInstalledPrefMissing) { … }
TEST_F(ExtensionManagementServiceTest,
InstallUpdateUrlEnforcedExtensionSettings) { … }
TEST_F(ExtensionManagementServiceTest,
InstallUpdateUrlEnforcedWebstoreUpdateUrl) { … }
TEST_F(ExtensionManagementServiceTest, HostsMaximumExceeded) { … }
TEST_F(ExtensionManagementServiceTest, MultipleEntries) { … }
TEST_F(ExtensionManagementServiceTest, PreferenceParsing) { … }
TEST_F(ExtensionManagementServiceTest, InstallationModeConflictHandling) { … }
TEST_F(ExtensionManagementServiceTest, BlockedPermissionsConflictHandling) { … }
TEST_F(ExtensionManagementServiceTest, DefaultHostExtensionsOverride) { … }
TEST_F(ExtensionManagementServiceTest, kMinimumVersionRequired) { … }
TEST_F(ExtensionManagementServiceTest, NewInstallSources) { … }
TEST_F(ExtensionManagementServiceTest, NewAllowedTypes) { … }
TEST_F(ExtensionManagementServiceTest, NewInstallBlocklist) { … }
TEST_F(ExtensionManagementServiceTest, NewAllowlist) { … }
TEST_F(ExtensionManagementServiceTest, NewInstallForcelist) { … }
TEST_F(ExtensionManagementServiceTest, IsInstallationExplicitlyAllowed) { … }
TEST_F(ExtensionManagementServiceTest, IsInstallationExplicitlyBlocked) { … }
TEST_F(ExtensionManagementServiceTest,
ExtensionsAreBlockedByDefaultForExtensionRequest) { … }
TEST_F(ExtensionManagementServiceTest, ManifestV2Default) { … }
TEST_F(ExtensionManagementServiceTest, ManifestV2Disabled) { … }
TEST_F(ExtensionManagementServiceTest, ManifestV2Enabled) { … }
TEST_F(ExtensionManagementServiceTest, ManifestV2EnabledForForceInstalled) { … }
TEST_F(ExtensionManagementServiceTest, ManifestV2EnabledForExtensionOnly) { … }
TEST_F(ExtensionManagementServiceTest,
UnpublishedCheckForNonCWSUpdateExtensions) { … }
TEST_F(ExtensionManagementServiceTest,
UnpublishedCheckWithPolicySettingAllowUnpublished) { … }
TEST_F(ExtensionManagementServiceTest,
UnpublishedCheckWithPolicySettingDisableUnpublished) { … }
TEST_F(ExtensionManagementServiceTest, IsFileUrlNavigationAllowed) { … }
TEST_F(ExtensionAdminPolicyTest, BlocklistedByDefault) { … }
TEST_F(ExtensionAdminPolicyTest, UserMayLoadRequired) { … }
TEST_F(ExtensionAdminPolicyTest, UserMayLoadNoBlocklist) { … }
TEST_F(ExtensionAdminPolicyTest, UserMayLoadAllowlisted) { … }
TEST_F(ExtensionAdminPolicyTest, UserMayLoadBlocklisted) { … }
TEST_F(ExtensionAdminPolicyTest, UserMayLoadAllowedTypes) { … }
TEST_F(ExtensionAdminPolicyTest, UserMayModifySettings) { … }
TEST_F(ExtensionAdminPolicyTest, ExtensionMayModifySettings) { … }
TEST_F(ExtensionAdminPolicyTest, MustRemainEnabled) { … }
}