diff --git a/components/web_discovery/browser/BUILD.gn b/components/web_discovery/browser/BUILD.gn index 2edd60e651bf..24bca33cba88 100644 --- a/components/web_discovery/browser/BUILD.gn +++ b/components/web_discovery/browser/BUILD.gn @@ -15,6 +15,7 @@ static_library("browser") { deps = [ ":internal", "//base", + "//brave/components/web_discovery/common:mojom", "//components/keyed_service/core", "//components/prefs", "//services/network/public/cpp", @@ -53,9 +54,9 @@ source_set("internal") { ] visibility = [ + "//brave/browser/web_discovery:browser_tests", "//brave/components/web_discovery/browser", "//brave/components/web_discovery/browser:unit_tests", - "//brave/browser/web_discovery:browser_tests", ] deps = [ diff --git a/components/web_discovery/browser/content_scraper.h b/components/web_discovery/browser/content_scraper.h index a4454d6e1d04..779f2587ec6f 100644 --- a/components/web_discovery/browser/content_scraper.h +++ b/components/web_discovery/browser/content_scraper.h @@ -13,7 +13,7 @@ #include "base/containers/flat_map.h" #include "base/functional/callback.h" #include "base/values.h" -#include "brave/components/web_discovery/browser/document_extractor/src/lib.rs.h" +#include "brave/components/web_discovery/browser/document_extractor/lib.rs.h" #include "brave/components/web_discovery/browser/patterns.h" #include "brave/components/web_discovery/browser/server_config_loader.h" #include "brave/components/web_discovery/common/web_discovery.mojom.h" diff --git a/components/web_discovery/browser/hash_detection.cc b/components/web_discovery/browser/hash_detection.cc index e28762b9b869..4442860016b0 100644 --- a/components/web_discovery/browser/hash_detection.cc +++ b/components/web_discovery/browser/hash_detection.cc @@ -35,6 +35,10 @@ constexpr double kClassifierThreshold = 0.015; bool IsHashLikely(std::string value, double threshold_multiplier) { TransformToAlphanumeric(value); + if (value.empty()) { + return false; + } + double log_prob_sum = 0.0; size_t add_count = 0; for (size_t i = 0; i < value.length() - 1; i++) { diff --git a/components/web_discovery/browser/hash_detection_unittest.cc b/components/web_discovery/browser/hash_detection_unittest.cc index 44e2104e91bb..c629a064cc9d 100644 --- a/components/web_discovery/browser/hash_detection_unittest.cc +++ b/components/web_discovery/browser/hash_detection_unittest.cc @@ -1,4 +1,3 @@ - /* Copyright (c) 2024 The Brave Authors. All rights reserved. * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, diff --git a/components/web_discovery/renderer/blink_document_extractor.cc b/components/web_discovery/renderer/blink_document_extractor.cc index b7fb01114b50..7a7ab2865778 100644 --- a/components/web_discovery/renderer/blink_document_extractor.cc +++ b/components/web_discovery/renderer/blink_document_extractor.cc @@ -60,6 +60,9 @@ BlinkDocumentExtractor::BlinkDocumentExtractor( content::RenderFrame* render_frame, service_manager::BinderRegistry* registry) : content::RenderFrameObserver(render_frame), render_frame_(render_frame) { + if (!render_frame->IsMainFrame()) { + return; + } registry->AddInterface(base::BindRepeating( &BlinkDocumentExtractor::BindReceiver, base::Unretained(this))); } diff --git a/renderer/brave_content_renderer_client.cc b/renderer/brave_content_renderer_client.cc index e45ded956b47..fc164cd98db9 100644 --- a/renderer/brave_content_renderer_client.cc +++ b/renderer/brave_content_renderer_client.cc @@ -220,7 +220,8 @@ void BraveContentRendererClient::RenderFrameCreated( #if BUILDFLAG(ENABLE_WEB_DISCOVERY_NATIVE) if (base::FeatureList::IsEnabled( - web_discovery::features::kBraveWebDiscoveryNative)) { + web_discovery::features::kBraveWebDiscoveryNative) && + !IsIncognitoProcess()) { new web_discovery::BlinkDocumentExtractor(render_frame, registry); } #endif