
The logic that generates Extensions Safety Hub data, i.e., warning reason strings, has been consolidated into a common ExtensionsSafetyCheckUtils class in a previous CL https://chromium-review.googlesource.com/c/chromium/src/+/5545709. This CL refactors the ExtensionInfoGenerator class to use the ExtensionsSafetyCheckUtils methods instead of its own. This CL also deprecates the use of the boolean kPrefAcknowledgeSafetyCheckWarning. This pref is no longer used for keeping track of user acknowledgement of warnings. Instead, we just rely on kPrefAcknowledgeSafetyCheckWarningReason, an integer pref which tracks the warning type acknowledged and allows for more granular metrics collection. The migration of this pref change has been implemented in CL https://chromium-review.googlesource.com/c/chromium/src/+/5639261. Bug: 335639105 Change-Id: I828b7fa890bf1dd91e42dd2bc9345913b51b11aa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5663416 Reviewed-by: Richard Chen <richche@google.com> Commit-Queue: Adam Psarouthakis <psarouthakis@google.com> Reviewed-by: Anunoy Ghosh <anunoy@chromium.org> Reviewed-by: John Lee <johntlee@chromium.org> Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org> Reviewed-by: Kelvin Jiang <kelvinjiang@chromium.org> Cr-Commit-Position: refs/heads/main@{#1326720}
49 lines
1.9 KiB
C++
49 lines
1.9 KiB
C++
// 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.
|
|
|
|
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SAFETY_CHECK_UTILS_H_
|
|
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SAFETY_CHECK_UTILS_H_
|
|
|
|
#include "base/gtest_prod_util.h"
|
|
#include "chrome/common/extensions/api/developer_private.h"
|
|
#include "extensions/browser/blocklist_state.h"
|
|
#include "extensions/browser/extension_prefs.h"
|
|
|
|
class Profile;
|
|
|
|
namespace extensions {
|
|
|
|
class CWSInfoServiceInterface;
|
|
class Extension;
|
|
|
|
inline constexpr PrefMap kPrefAcknowledgeSafetyCheckWarning = {
|
|
"ack_safety_check_warning", PrefType::kBool, PrefScope::kExtensionSpecific};
|
|
|
|
// These functions are used as a utility functions for the Extension
|
|
// Safety Check.
|
|
namespace ExtensionSafetyCheckUtils {
|
|
// Returns the Safety Hub warning reason for an extension.
|
|
api::developer_private::SafetyCheckWarningReason GetSafetyCheckWarningReason(
|
|
const Extension& extension,
|
|
Profile* profile,
|
|
bool unpublished_only = false);
|
|
|
|
// A helper function to `GetSafetyCheckWarningReason` to simplify testing.
|
|
api::developer_private::SafetyCheckWarningReason
|
|
GetSafetyCheckWarningReasonHelper(CWSInfoServiceInterface* cws_info_service,
|
|
BitMapBlocklistState blocklist_state,
|
|
Profile* profile,
|
|
const Extension& extension,
|
|
bool unpublished_only = false);
|
|
|
|
// Returns the display strings related to a Safety Hub Warning reason.
|
|
api::developer_private::SafetyCheckStrings GetSafetyCheckWarningStrings(
|
|
api::developer_private::SafetyCheckWarningReason warning_reason,
|
|
api::developer_private::ExtensionState state);
|
|
|
|
} // namespace ExtensionSafetyCheckUtils
|
|
} // namespace extensions
|
|
|
|
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SAFETY_CHECK_UTILS_H_
|