Commit 3a29113f authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

Move visual_utils to common/ to fix dependency check.

Move visual_utils code and tests from components/safe_browsing/
content/password_protection to compontents/safe_browsing/core/
common/. The code for visual_utils currently lives in
components/safe_browsing/content/password_protection/, but is now
used by both password_protection and phishing_classifier code,
therefore this CL moves the files and tests to the common/ directory.

This solves the assert_no_deps issue and allows to remove the
"nogncheck" in scorer.h when depending on the
"c/s_b/c/password_protection" target from the phishing_classifier
(which is in deps for chrome/renderer/BUILD.gn), see crbug.com/1138547
for details.

BUG=1138547,1136950

Change-Id: Ic3796eec31c32ff6aee9e9267fbbebb0be090ef7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495066Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822278}
parent 7b1acf8e
......@@ -14,8 +14,6 @@ source_set("password_protection") {
"password_protection_request.h",
"password_protection_service.cc",
"password_protection_service.h",
"visual_utils.cc",
"visual_utils.h",
]
public_deps = [ "//google_apis:google_apis" ]
......@@ -75,9 +73,7 @@ source_set("password_protection_unittest") {
"password_protection_navigation_throttle_unittest.cc",
"password_protection_service_unittest.cc",
]
if (safe_browsing_mode == 1) {
sources += [ "visual_utils_unittest.cc" ]
}
deps = [
":mock_password_protection",
":password_protection",
......
......@@ -18,8 +18,8 @@
#include "components/safe_browsing/content/common/safe_browsing.mojom.h"
#include "components/safe_browsing/content/password_protection/metrics_util.h"
#include "components/safe_browsing/content/password_protection/password_protection_navigation_throttle.h"
#include "components/safe_browsing/content/password_protection/visual_utils.h"
#include "components/safe_browsing/content/web_ui/safe_browsing_ui.h"
#include "components/safe_browsing/core/common/visual_utils.h"
#include "components/safe_browsing/core/db/allowlist_checker_client.h"
#include "components/safe_browsing/core/features.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
......
include_rules = [
"+components/paint_preview/common",
"+components/safe_browsing/content/renderer",
"+components/safe_browsing/content/password_protection/visual_utils.h",
"+components/safe_browsing/core/common",
"+components/safe_browsing/core/proto/csd.pb.h",
"+components/safe_browsing/core/proto/client_model.pb.h",
......
......@@ -15,8 +15,8 @@
#include "base/strings/string_piece.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "components/safe_browsing/content/password_protection/visual_utils.h" // nogncheck crbug.com/1138547
#include "components/safe_browsing/content/renderer/phishing_classifier/features.h"
#include "components/safe_browsing/core/common/visual_utils.h"
#include "components/safe_browsing/core/proto/client_model.pb.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
#include "content/public/renderer/render_thread.h"
......
......@@ -45,6 +45,7 @@ source_set("unit_tests") {
"safe_browsing_policy_handler_unittest.cc",
"safe_browsing_prefs_unittest.cc",
]
deps = [
":safe_browsing_policy_handler",
":safe_browsing_prefs",
......@@ -58,6 +59,14 @@ source_set("unit_tests") {
"//testing/gtest",
"//url:url",
]
if (safe_browsing_mode == 1) {
sources += [ "visual_utils_unittest.cc" ]
deps += [
":common",
"//ui/gfx:color_utils",
]
}
}
source_set("common") {
......@@ -82,6 +91,18 @@ source_set("common") {
"//url/ipc:url_ipc",
]
if (safe_browsing_mode == 1 || safe_browsing_mode == 2) {
sources += [
"visual_utils.cc",
"visual_utils.h",
]
deps += [
"//components/safe_browsing/core:client_model_proto",
"//third_party/opencv:emd",
"//ui/gfx:color_utils",
]
}
public_deps = [ ":interfaces" ]
if (!is_ios) {
......
......@@ -8,5 +8,8 @@ include_rules = [
"+content/public/test",
"+crypto/sha2.h",
"+ipc",
"+third_party/opencv",
"+third_party/skia/include",
"+ui/gfx",
"+url"
]
......@@ -5,7 +5,7 @@
#include <unordered_map>
#include <vector>
#include "components/safe_browsing/content/password_protection/visual_utils.h"
#include "components/safe_browsing/core/common/visual_utils.h"
#include "base/check_op.h"
#include "base/numerics/checked_math.h"
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SAFE_BROWSING_CONTENT_PASSWORD_PROTECTION_VISUAL_UTILS_H_
#define COMPONENTS_SAFE_BROWSING_CONTENT_PASSWORD_PROTECTION_VISUAL_UTILS_H_
#ifndef COMPONENTS_SAFE_BROWSING_CORE_COMMON_VISUAL_UTILS_H_
#define COMPONENTS_SAFE_BROWSING_CORE_COMMON_VISUAL_UTILS_H_
#include <string>
......@@ -52,4 +52,4 @@ base::Optional<VisionMatchResult> IsVisualMatch(const SkBitmap& image,
} // namespace visual_utils
} // namespace safe_browsing
#endif // COMPONENTS_SAFE_BROWSING_CONTENT_PASSWORD_PROTECTION_VISUAL_UTILS_H_
#endif // COMPONENTS_SAFE_BROWSING_CORE_COMMON_VISUAL_UTILS_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/safe_browsing/content/password_protection/visual_utils.h"
#include "components/safe_browsing/core/common/visual_utils.h"
#include "base/test/test_discardable_memory_allocator.h"
#include "testing/gmock/include/gmock/gmock.h"
......
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