chromium/chrome/browser/extensions/installed_loader_unittest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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  // BUILDFLAG(IS_CHROMEOS_ASH)

namespace extensions {

namespace {

constexpr const char kHasWithheldHostsHistogram[] =;
constexpr const char kGrantedHostCountHistogram[] =;
constexpr const char kGrantedAccessHistogram[] =;
constexpr const char kGrantedAccessForBroadRequestsHistogram[] =;
constexpr const char kGrantedAccessForTargetedRequestsHistogram[] =;
// Use an internal location for extensions since metrics aren't recorded for
// unpacked extensions.
constexpr mojom::ManifestLocation kManifestInternal =;
constexpr mojom::ManifestLocation kManifestExternalPolicy =;

struct HostPermissionsMetricsTestParams {};

}  // namespace

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) {}

// Test that certain histograms are emitted for user and non-user profiles
// (users for ChromeOS Ash).
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) {}

// TODO(crbug.com/40878021): After deleting the deprecated unincremented
// histograms, consider modifying these to becomes less of change detectors in
// metrics being modified.
// Tests that some histograms that only emit for profiles that can use
// non-component extensions emit as expected.
TEST_F(InstalledLoaderUnitTest, UserMetrics_UserMetricsEmitForRegularUser) {}

// Tests that some histograms that only emit for profiles that can use
// non-component extensions do not emit as expected.
TEST_F(InstalledLoaderUnitTest, UserMetrics_UserMetricsDoNotEmitForGuestUser) {}

}  // namespace extensions