chromium/chrome/browser/extensions/extension_safety_check_utils.cc

// Copyright 2024 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/extension_safety_check_utils.h"

#include "chrome/browser/extensions/api/developer_private/developer_private_api.h"
#include "chrome/browser/extensions/cws_info_service.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "extensions/browser/blocklist_extension_prefs.h"
#include "extensions/browser/blocklist_state.h"
#include "extensions/browser/extension_prefs.h"
#include "ui/base/l10n/l10n_util.h"

namespace extensions {

developer;

namespace {

// Update the old kPrefAcknowledgeSafetyCheckWarning pref to the new
// kPrefAcknowledgeSafetyCheckWarningReason pref. If only the boolean
// acknowledged pref is present, it's replaced with the new acknowledge
// reason pref set to the current top warning reason. If both the
// boolean and reason acknowledged pref are present, the bool pref is
// removed.
void MigrateSafetyCheckAcknowledgePref(
    const Extension& extension,
    developer::SafetyCheckWarningReason acknowledged_reason,
    developer::SafetyCheckWarningReason top_warning_reason,
    ExtensionPrefs* extension_prefs) {}

// Returns true if the Safety Check should display a malware warning.
bool SafetyCheckShouldShowMalware(
    BitMapBlocklistState blocklist_state,
    const std::optional<CWSInfoService::CWSInfo>& cws_info) {}

// Returns true if the Safety Check should display a policy violation warning.
bool SafetyCheckShouldShowPolicyViolation(
    BitMapBlocklistState blocklist_state,
    const std::optional<CWSInfoService::CWSInfo>& cws_info) {}

// Returns true if the Safety Check should display an unwanted software warning.
bool SafetyCheckShouldShowPotentiallyUnwanted(
    BitMapBlocklistState blocklist_state) {}

// Returns true if the Safety Check should display a no privacy practice
// warning.
bool SafetyCheckShouldShowNoPrivacyPractice(
    const std::optional<CWSInfoService::CWSInfo>& cws_info) {}

// Returns true if the Safety Check should display a no off-store extension
// warning.
bool SafetyCheckShouldShowOffstoreExtension(
    const Extension& extension,
    Profile* profile,
    const std::optional<CWSInfoService::CWSInfo>& cws_info) {}

// Return the `PrefAcknowledgeSafetyCheckWarningReason` pref as an enum.
developer::SafetyCheckWarningReason GetPrefAcknowledgeSafetyCheckWarningReason(
    const Extension& extension,
    ExtensionPrefs* extension_prefs) {}

// Converts the `SafetyCheckWarningReason` enum into its corresponding
// warning level. The greater the return value the more severe the
// trigger.
int GetSafetyCheckWarningLevel(
    developer::SafetyCheckWarningReason safety_check_warning) {}

// Checks if the user has already acknowledged a safety check warning that
// is of the same or greater level than the current warning reason.
//    * current_warning - Current Safety Check warning reason
//    * acknowledged_warning - Previously acknowledged warning reason
bool SafetyCheckHasUserAcknowledgedWarningLevel(
    developer::SafetyCheckWarningReason acknowledged_reason,
    developer::SafetyCheckWarningReason warning_reason) {}

}  // namespace

namespace ExtensionSafetyCheckUtils {

developer::SafetyCheckWarningReason GetSafetyCheckWarningReason(
    const Extension& extension,
    Profile* profile,
    bool unpublished_only) {}

developer::SafetyCheckWarningReason GetSafetyCheckWarningReasonHelper(
    CWSInfoServiceInterface* cws_info_service,
    BitMapBlocklistState blocklist_state,
    Profile* profile,
    const Extension& extension,
    bool unpublished_only) {}

api::developer_private::SafetyCheckStrings GetSafetyCheckWarningStrings(
    developer::SafetyCheckWarningReason warning_reason,
    developer::ExtensionState state) {}
}  // namespace ExtensionSafetyCheckUtils
}  // namespace extensions