Commit 4cc7cc84 authored by Bettina's avatar Bettina Committed by Commit Bot

Only load the Client Side Detection Service sometimes on Android.

On Android, the ClientSideDetectionOnAndroid
experiment needs to be turned on in order
for the CSDService and CSDHost to be created.
Also updated the CSDModel experiment to
the experiment used on Android.


Bug: 1108080
Change-Id: Ia53cb59331582877b6e0ebf4f08f2c921a732ba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2411426
Commit-Queue: Bettina Dea <bdea@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808045}
parent 84647252
......@@ -389,7 +389,7 @@ void ClientSideDetectionHost::DidFinishNavigation(
void ClientSideDetectionHost::SendModelToRenderFrame() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!web_contents() || web_contents() != tab_)
if (!web_contents() || web_contents() != tab_ || !csd_service_)
return;
for (content::RenderFrameHost* frame : web_contents()->GetAllFrames()) {
......@@ -435,8 +435,8 @@ void ClientSideDetectionHost::WebContentsDestroyed() {
}
// Cancel all pending feature extractions.
feature_extractor_.reset();
csd_service_->RemoveClientSideDetectionHost(this);
if (csd_service_)
csd_service_->RemoveClientSideDetectionHost(this);
}
void ClientSideDetectionHost::RenderFrameCreated(
......
......@@ -10,6 +10,8 @@
#include "chrome/browser/safe_browsing/client_side_detection_service.h"
#include "chrome/common/chrome_switches.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/core/features.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace safe_browsing {
......@@ -40,6 +42,16 @@ ClientSideDetectionServiceFactory::ClientSideDetectionServiceFactory()
KeyedService* ClientSideDetectionServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
bool client_side_detection_enabled =
#if BUILDFLAG(FULL_SAFE_BROWSING)
true;
#else
base::FeatureList::IsEnabled(
safe_browsing::kClientSideDetectionForAndroid);
#endif
if (!client_side_detection_enabled)
return nullptr;
Profile* profile = Profile::FromBrowserContext(context);
return new ClientSideDetectionService(profile);
}
......
......@@ -20,6 +20,7 @@
#include "base/task/thread_pool.h"
#include "base/threading/sequenced_task_runner_handle.h"
#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/proto/client_model.pb.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
......@@ -62,7 +63,11 @@ const char ModelLoader::kClientModelUrlPrefix[] =
const char ModelLoader::kClientModelNamePattern[] =
"client_model_v5%s_variation_%d.pb";
const char ModelLoader::kClientModelFinchExperiment[] =
#if BUILDFLAG(FULL_SAFE_BROWSING)
"ClientSideDetectionModel";
#else
"ClientSideDetectionModelOnAndroid";
#endif
const char ModelLoader::kClientModelFinchParam[] =
"ModelNum";
const char kUmaModelDownloadResponseMetricName[] =
......
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