Skip to content

Commit

Permalink
Address Web Discovery feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
DJAndries committed Jan 7, 2025
1 parent 0d1cfec commit c9d4f04
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/web_discovery/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion components/web_discovery/browser/content_scraper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions components/web_discovery/browser/hash_detection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 3 additions & 0 deletions components/web_discovery/renderer/blink_document_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<mojom::DocumentExtractor>(base::BindRepeating(
&BlinkDocumentExtractor::BindReceiver, base::Unretained(this)));
}
Expand Down
3 changes: 2 additions & 1 deletion renderer/brave_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c9d4f04

Please sign in to comment.