#include "chrome/browser/extensions/installed_loader.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/browser/extensions/extension_service_user_test_base.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/test/base/testing_profile.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_features.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#endif
namespace extensions {
namespace {
constexpr const char kHasWithheldHostsHistogram[] = …;
constexpr const char kGrantedHostCountHistogram[] = …;
constexpr const char kGrantedAccessHistogram[] = …;
constexpr const char kGrantedAccessForBroadRequestsHistogram[] = …;
constexpr const char kGrantedAccessForTargetedRequestsHistogram[] = …;
constexpr mojom::ManifestLocation kManifestInternal = …;
constexpr mojom::ManifestLocation kManifestExternalPolicy = …;
struct HostPermissionsMetricsTestParams { … };
}
class InstalledLoaderUnitTest : public ExtensionServiceUserTestBase { … };
const Extension* InstalledLoaderUnitTest::AddExtension(
const std::vector<std::string>& host_permissions,
mojom::ManifestLocation location,
bool requests_active_tab) { … }
void InstalledLoaderUnitTest::RunHostPermissionsMetricsTest(
HostPermissionsMetricsTestParams params) { … }
void InstalledLoaderUnitTest::RunEmitUserHistogramsTest(
int nonuser_expected_total_count,
int user_expected_total_count) { … }
TEST_F(InstalledLoaderUnitTest,
RuntimeHostPermissions_Metrics_HasWithheldHosts_False) { … }
TEST_F(InstalledLoaderUnitTest,
RuntimeHostPermissions_Metrics_HasWithheldHosts_True) { … }
TEST_F(InstalledLoaderUnitTest,
RuntimeHostPermissions_Metrics_GrantedHostCount) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_CannotAffect) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_CannotAffect_Broad_AllUrls) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_CannotAffect_Broad_Patterns) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_CannotAffect_Targeted) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_NotRequested) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnClick_Broad_AllUrls) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnClick_Broad_Pattern) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnClick_Targeted) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnSpecificSites_Broad_AllUrls) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnSpecificSites_Broad_Pattern) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnSpecificSites_Targeted) { … }
TEST_F(
InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnAllRequestedSites_Broad_AllUrls) { … }
TEST_F(
InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnAllRequestedSites_Broad_Pattern) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnAllRequestedSites_Targeted) { … }
TEST_F(InstalledLoaderUnitTest,
HostPermissions_Metrics_GrantedAccess_OnActiveTabOnly) { … }
TEST_F(InstalledLoaderUnitTest, UserMetrics_UserMetricsEmitForRegularUser) { … }
TEST_F(InstalledLoaderUnitTest, UserMetrics_UserMetricsDoNotEmitForGuestUser) { … }
}