#include "chrome/browser/extensions/external_provider_impl.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_path_override.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/browser/extensions/external_testing_loader.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/web_applications/preinstalled_app_install_features.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_test_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/pref_names.h"
#include "extensions/browser/updater/extension_cache_fake.h"
#include "extensions/browser/updater/extension_downloader_test_helper.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "testing/gmock/include/gmock/gmock.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/customization/customization_document.h"
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
#include "chromeos/ash/components/system/fake_statistics_provider.h"
#include "chromeos/ash/components/system/statistics_provider.h"
#include "components/user_manager/scoped_user_manager.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "base/test/test_reg_util_win.h"
#include "base/win/registry.h"
#endif
namespace extensions {
namespace {
struct TestServerExtension { … };
constexpr const TestServerExtension kInAppPaymentsApp{ … };
constexpr const TestServerExtension kGoodApp{ … };
constexpr const TestServerExtension kTestServerExtensions[] = …;
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
const char kExternalAppId[] = "kekdneafjmhmndejhmbcadfiiofngffo";
#endif
#if BUILDFLAG(IS_WIN)
const char kExternalAppCrxPath[] =
"external\\kekdneafjmhmndejhmbcadfiiofngffo.crx";
const wchar_t kExternalAppRegistryKey[] =
L"Software\\Google\\Chrome\\Extensions\\kekdneafjmhmndejhmbcadfiiofngffo";
#endif
class ExternalProviderImplTest : public ExtensionServiceTestBase { … };
}
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
TEST_F(ExternalProviderImplTest, InAppPayments) {
InitServiceWithExternalProviders();
AwaitCheckForExternalUpdates();
EXPECT_TRUE(registry()->GetInstalledExtension(kInAppPaymentsApp.app_id));
EXPECT_TRUE(service_->IsExtensionEnabled(kInAppPaymentsApp.app_id));
}
TEST_F(ExternalProviderImplTest, BlockedExternalUserProviders) {
OverrideExternalExtensionsPath();
InitServiceWithExternalProviders(true);
AwaitCheckForExternalUpdates();
EXPECT_FALSE(registry()->GetInstalledExtension(kExternalAppId));
}
TEST_F(ExternalProviderImplTest, NotBlockedExternalUserProviders) {
OverrideExternalExtensionsPath();
InitServiceWithExternalProviders(false);
AwaitCheckForExternalUpdates();
EXPECT_TRUE(registry()->GetInstalledExtension(kExternalAppId));
}
#endif
TEST_F(ExternalProviderImplTest, WebAppMigrationFlag) { … }
}