Commit 9a12143e authored by Bettina Dea's avatar Bettina Dea Committed by Commit Bot

Disable visual detection if on Android.

Client side detection is currently enabled
on Android but there was no check to prevent
visual detection from being done and is
causing crashes in PaintPreviewTracker on beta.

Bug: 1146121
Change-Id: If37cd5abe52ebb25fa7fb7ae126cd934c6a74cf6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521353
Commit-Queue: Bettina Dea <bdea@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824679}
parent ef1f238e
......@@ -12,6 +12,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/core/proto/client_model.pb.h"
#include "content/public/test/browser_test.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -82,6 +83,7 @@ class ClientSideDetectionHostBrowserTest : public InProcessBrowserTest {
~ClientSideDetectionHostBrowserTest() override = default;
};
#if BUILDFLAG(FULL_SAFE_BROWSING)
IN_PROC_BROWSER_TEST_F(ClientSideDetectionHostBrowserTest,
VerifyVisualFeatureCollection) {
FakeClientSideDetectionService fake_csd_service;
......@@ -139,5 +141,6 @@ IN_PROC_BROWSER_TEST_F(ClientSideDetectionHostBrowserTest,
EXPECT_CALL(*mock_ui_manager, DisplayBlockingPage(_));
std::move(fake_csd_service.saved_callback()).Run(page_url, true);
}
#endif
} // namespace safe_browsing
......@@ -15,6 +15,7 @@
#include "base/test/test_discardable_memory_allocator.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
#include "chrome/test/base/chrome_render_view_test.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/content/renderer/phishing_classifier/features.h"
#include "components/safe_browsing/content/renderer/phishing_classifier/murmurhash3_util.h"
#include "components/safe_browsing/content/renderer/phishing_classifier/scorer.h"
......@@ -272,6 +273,7 @@ TEST_F(PhishingClassifierTest, DisableDetection) {
EXPECT_FALSE(classifier_->is_ready());
}
#if BUILDFLAG(FULL_SAFE_BROWSING)
TEST_F(PhishingClassifierTest, TestSendsVisualHash) {
LoadHtml(GURL("https://host.net"),
"<html><body><a href=\"http://safe.com/\">login</a></body></html>");
......@@ -288,6 +290,7 @@ TEST_F(PhishingClassifierTest, TestSendsVisualDigest) {
EXPECT_FALSE(screenshot_digest_.empty());
}
#endif
// TODO(jialiul): Add test to verify that classification only starts on GET
// method. It seems there is no easy way to simulate a HTTP POST in
......
......@@ -28,6 +28,7 @@ source_set("phishing_classifier") {
deps = [
"//cc/paint",
"//components/paint_preview/common",
"//components/safe_browsing:buildflags",
"//components/safe_browsing/content/common:interfaces",
"//components/safe_browsing/content/renderer",
"//components/safe_browsing/core:client_model_proto",
......
......@@ -21,6 +21,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "cc/paint/skia_paint_canvas.h"
#include "components/paint_preview/common/paint_preview_tracker.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/content/renderer/phishing_classifier/features.h"
#include "components/safe_browsing/content/renderer/phishing_classifier/phishing_dom_feature_extractor.h"
#include "components/safe_browsing/content/renderer/phishing_classifier/phishing_term_feature_extractor.h"
......@@ -162,7 +163,11 @@ void PhishingClassifier::DOMExtractionFinished(bool success) {
void PhishingClassifier::TermExtractionFinished(bool success) {
if (success) {
#if BUILDFLAG(FULL_SAFE_BROWSING)
ExtractVisualFeatures();
#else
VisualExtractionFinished(true);
#endif
} else {
RunFailureCallback();
}
......@@ -228,12 +233,15 @@ void PhishingClassifier::VisualExtractionFinished(bool success) {
verdict->set_client_score(score);
verdict->set_is_phishing(score >= scorer_->threshold_probability());
#if BUILDFLAG(FULL_SAFE_BROWSING)
visual_matching_start_ = base::TimeTicks::Now();
scorer_->GetMatchingVisualTargets(
*bitmap_, std::move(verdict),
base::BindOnce(&PhishingClassifier::OnVisualTargetsMatched,
weak_factory_.GetWeakPtr()));
#else
RunCallback(*verdict);
#endif
}
void PhishingClassifier::OnVisualTargetsMatched(
......
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