Commit 0043f152 authored by Daniel Rubery's avatar Daniel Rubery Committed by Commit Bot

Replace deprecated use of GetVariationParamValue with GetFieldTrialParamValueByFeature

Since we're wrapping up one experiment for CSD on Desktop (vision-based
CSD) and moving immediately into another (the new DOM-based model),
take this opportunity to remove the legacy usage of
GetVariationParamValue on Desktop.

Change-Id: Idc153248827e48fdd53d6b062fc32285644d3204
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2551458Reviewed-by: default avatarBettina Dea <bdea@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829828}
parent 14358976
......@@ -23,6 +23,7 @@
#include "base/time/time.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/core/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/features.h"
#include "components/safe_browsing/core/proto/client_model.pb.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
#include "components/variations/variations_associated_data.h"
......@@ -63,10 +64,8 @@ const char ModelLoader::kClientModelUrlPrefix[] =
"https://ssl.gstatic.com/safebrowsing/csd/";
const char ModelLoader::kClientModelNamePattern[] =
"client_model_v5%s_variation_%d.pb";
#if !BUILDFLAG(FULL_SAFE_BROWSING)
const char ModelLoader::kClientModelFinchExperiment[] =
#if BUILDFLAG(FULL_SAFE_BROWSING)
"ClientSideDetectionModel";
#else
"ClientSideDetectionModelOnAndroid";
#endif
const char ModelLoader::kClientModelFinchParam[] =
......@@ -80,8 +79,13 @@ const char kOverrideCsdModelFlag[] = "csd-model-override-path";
// static
int ModelLoader::GetModelNumber() {
#if BUILDFLAG(FULL_SAFE_BROWSING)
std::string num_str = base::GetFieldTrialParamValueByFeature(
kClientSideDetectionModelVersion, kClientModelFinchParam);
#else
std::string num_str = variations::GetVariationParamValue(
kClientModelFinchExperiment, kClientModelFinchParam);
#endif
int model_number = 0;
if (!base::StringToInt(num_str, &model_number)) {
model_number = 6; // Default model
......
......@@ -20,6 +20,8 @@
#include "base/strings/string_number_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/core/features.h"
#include "components/safe_browsing/core/proto/client_model.pb.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
#include "components/variations/variations_associated_data.h"
......@@ -76,6 +78,13 @@ class ModelLoaderTest : public testing::Test {
// Set up the finch experiment to control the model number
// used in the model URL. This clears all existing state.
void SetFinchModelNumber(int model_number) {
#if BUILDFLAG(FULL_SAFE_BROWSING)
scoped_feature_list_.Reset();
scoped_feature_list_.InitAndEnableFeatureWithParameters(
kClientSideDetectionModelVersion,
{{ ModelLoader::kClientModelFinchParam,
base::NumberToString(model_number) }});
#else
scoped_feature_list_.Reset();
scoped_feature_list_.Init();
variations::testing::ClearAllVariationIDs();
......@@ -91,6 +100,7 @@ class ModelLoaderTest : public testing::Test {
ASSERT_TRUE(variations::AssociateVariationParams(
ModelLoader::kClientModelFinchExperiment, group_name, params));
#endif
}
// Set the URL for future SetModelFetchResponse() calls.
......
......@@ -36,6 +36,9 @@ const base::Feature kCaptureInlineJavascriptForGoogleAds{
const base::Feature kClientSideDetectionForAndroid{
"ClientSideDetectionModelOnAndroid", base::FEATURE_DISABLED_BY_DEFAULT};
extern const base::Feature kClientSideDetectionModelVersion{
"ClientSideDetectionModel", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kDelayedWarnings{"SafeBrowsingDelayedWarnings",
base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -37,6 +37,10 @@ extern const base::Feature kCaptureInlineJavascriptForGoogleAds;
// Enables client side detection on Android.
extern const base::Feature kClientSideDetectionForAndroid;
// Determines the experimental version of client side detection model, for
// Desktop.
extern const base::Feature kClientSideDetectionModelVersion;
// Enable the addition of access tokens to download pings for enhanced
// protection users.
extern const base::Feature kDownloadRequestWithToken;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment