From 17d0ff2967d633dc3cddbe409670d4927622fdf0 Mon Sep 17 00:00:00 2001 From: Cris Barreiro Date: Tue, 10 Dec 2024 18:23:39 +0100 Subject: [PATCH] Do not make MaliciousSiteBlockerWebViewIntegration public --- .../app/browser/BrowserWebViewClientTest.kt | 2 +- .../browser/WebViewRequestInterceptorTest.kt | 1 - .../UrlExtractingWebViewClientTest.kt | 2 +- .../referencetests/DomainsReferenceTest.kt | 2 +- .../referencetests/SurrogatesReferenceTest.kt | 2 +- .../app/browser/BrowserWebViewClient.kt | 2 +- .../app/browser/WebViewRequestInterceptor.kt | 2 +- .../app/browser/di/BrowserModule.kt | 2 +- .../UrlExtractingWebViewClient.kt | 2 +- ...MaliciousSiteBlockerWebViewIntegration.kt} | 19 ++++++++- .../MaliciousSiteBlockerWebViewIntegration.kt | 39 ------------------- 11 files changed, 26 insertions(+), 49 deletions(-) rename app/src/main/java/com/duckduckgo/app/browser/webview/{RealMaliciousSiteBlockerWebViewIntegration.kt => MaliciousSiteBlockerWebViewIntegration.kt} (92%) delete mode 100644 browser-api/src/main/java/com/duckduckgo/browser/api/MaliciousSiteBlockerWebViewIntegration.kt diff --git a/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt b/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt index ac56d97e6e1a..edafca37b598 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt @@ -59,6 +59,7 @@ import com.duckduckgo.app.browser.pageloadpixel.firstpaint.PagePaintedHandler import com.duckduckgo.app.browser.print.PrintInjector import com.duckduckgo.app.browser.trafficquality.AndroidFeaturesHeaderPlugin import com.duckduckgo.app.browser.uriloaded.UriLoadedManager +import com.duckduckgo.app.browser.webview.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.app.global.model.Site import com.duckduckgo.app.pixels.remoteconfig.AndroidBrowserConfigFeature import com.duckduckgo.app.statistics.pixels.Pixel @@ -66,7 +67,6 @@ import com.duckduckgo.autoconsent.api.Autoconsent import com.duckduckgo.autofill.api.BrowserAutofill import com.duckduckgo.autofill.api.InternalTestUserChecker import com.duckduckgo.browser.api.JsInjectorPlugin -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.browser.api.WebViewVersionProvider import com.duckduckgo.common.test.CoroutineTestRule import com.duckduckgo.common.utils.CurrentTimeProvider diff --git a/app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt b/app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt index ad115fcf07c6..3ffb8f747d0e 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt @@ -42,7 +42,6 @@ import com.duckduckgo.app.trackerdetection.TrackerDetector import com.duckduckgo.app.trackerdetection.model.TrackerStatus import com.duckduckgo.app.trackerdetection.model.TrackerType import com.duckduckgo.app.trackerdetection.model.TrackingEvent -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.test.CoroutineTestRule import com.duckduckgo.duckplayer.api.DuckPlayer import com.duckduckgo.feature.toggles.api.FeatureToggle diff --git a/app/src/androidTest/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClientTest.kt b/app/src/androidTest/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClientTest.kt index fd521dfdf4af..c8092cab9873 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClientTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClientTest.kt @@ -24,7 +24,7 @@ import com.duckduckgo.app.browser.* import com.duckduckgo.app.browser.certificates.rootstore.TrustedCertificateStore import com.duckduckgo.app.browser.cookies.ThirdPartyCookieManager import com.duckduckgo.app.browser.httpauth.WebViewHttpAuthStore -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration +import com.duckduckgo.app.browser.webview.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.test.CoroutineTestRule import com.duckduckgo.cookies.api.CookieManagerProvider import kotlinx.coroutines.test.TestScope diff --git a/app/src/androidTest/java/com/duckduckgo/app/referencetests/DomainsReferenceTest.kt b/app/src/androidTest/java/com/duckduckgo/app/referencetests/DomainsReferenceTest.kt index 50f945aa1b23..baf7d6ce4b7f 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/referencetests/DomainsReferenceTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/referencetests/DomainsReferenceTest.kt @@ -28,6 +28,7 @@ import androidx.test.platform.app.InstrumentationRegistry import com.duckduckgo.adclick.api.AdClickManager import com.duckduckgo.app.browser.WebViewRequestInterceptor import com.duckduckgo.app.browser.useragent.provideUserAgentOverridePluginPoint +import com.duckduckgo.app.browser.webview.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.app.fakes.FeatureToggleFake import com.duckduckgo.app.fakes.UserAgentFake import com.duckduckgo.app.fakes.UserAllowListRepositoryFake @@ -52,7 +53,6 @@ import com.duckduckgo.app.trackerdetection.db.TdsCnameEntityDao import com.duckduckgo.app.trackerdetection.db.TdsDomainEntityDao import com.duckduckgo.app.trackerdetection.db.TdsEntityDao import com.duckduckgo.app.trackerdetection.db.WebTrackersBlockedDao -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.test.CoroutineTestRule import com.duckduckgo.common.test.FileUtilities import com.duckduckgo.duckplayer.api.DuckPlayer diff --git a/app/src/androidTest/java/com/duckduckgo/app/referencetests/SurrogatesReferenceTest.kt b/app/src/androidTest/java/com/duckduckgo/app/referencetests/SurrogatesReferenceTest.kt index 8d6e3015751f..92114b7d3152 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/referencetests/SurrogatesReferenceTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/referencetests/SurrogatesReferenceTest.kt @@ -27,6 +27,7 @@ import androidx.test.platform.app.InstrumentationRegistry import com.duckduckgo.adclick.api.AdClickManager import com.duckduckgo.app.browser.WebViewRequestInterceptor import com.duckduckgo.app.browser.useragent.provideUserAgentOverridePluginPoint +import com.duckduckgo.app.browser.webview.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.app.fakes.FeatureToggleFake import com.duckduckgo.app.fakes.UserAgentFake import com.duckduckgo.app.fakes.UserAllowListRepositoryFake @@ -50,7 +51,6 @@ import com.duckduckgo.app.trackerdetection.db.TdsCnameEntityDao import com.duckduckgo.app.trackerdetection.db.TdsDomainEntityDao import com.duckduckgo.app.trackerdetection.db.TdsEntityDao import com.duckduckgo.app.trackerdetection.db.WebTrackersBlockedDao -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.test.CoroutineTestRule import com.duckduckgo.common.test.FileUtilities import com.duckduckgo.duckplayer.api.DuckPlayer diff --git a/app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt b/app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt index e97175e533b1..8a83de393f1d 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt @@ -60,13 +60,13 @@ import com.duckduckgo.app.browser.pageloadpixel.firstpaint.PagePaintedHandler import com.duckduckgo.app.browser.print.PrintInjector import com.duckduckgo.app.browser.trafficquality.AndroidFeaturesHeaderPlugin import com.duckduckgo.app.browser.uriloaded.UriLoadedManager +import com.duckduckgo.app.browser.webview.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.app.di.AppCoroutineScope import com.duckduckgo.app.statistics.pixels.Pixel import com.duckduckgo.autoconsent.api.Autoconsent import com.duckduckgo.autofill.api.BrowserAutofill import com.duckduckgo.autofill.api.InternalTestUserChecker import com.duckduckgo.browser.api.JsInjectorPlugin -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.utils.CurrentTimeProvider import com.duckduckgo.common.utils.DispatcherProvider import com.duckduckgo.common.utils.plugins.PluginPoint diff --git a/app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt b/app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt index 0adaad641815..7838e6ddaa15 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt @@ -22,6 +22,7 @@ import android.webkit.WebResourceResponse import android.webkit.WebView import androidx.annotation.WorkerThread import com.duckduckgo.adclick.api.AdClickManager +import com.duckduckgo.app.browser.webview.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.app.privacy.db.PrivacyProtectionCountDao import com.duckduckgo.app.privacy.model.TrustedSites import com.duckduckgo.app.surrogates.ResourceSurrogates @@ -29,7 +30,6 @@ import com.duckduckgo.app.trackerdetection.CloakedCnameDetector import com.duckduckgo.app.trackerdetection.TrackerDetector import com.duckduckgo.app.trackerdetection.model.TrackerStatus import com.duckduckgo.app.trackerdetection.model.TrackingEvent -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.utils.AppUrl import com.duckduckgo.common.utils.DefaultDispatcherProvider import com.duckduckgo.common.utils.DispatcherProvider diff --git a/app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt b/app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt index 0c910af68c97..088ad74173b9 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt @@ -55,6 +55,7 @@ import com.duckduckgo.app.browser.tabpreview.WebViewPreviewPersister import com.duckduckgo.app.browser.urlextraction.DOMUrlExtractor import com.duckduckgo.app.browser.urlextraction.JsUrlExtractor import com.duckduckgo.app.browser.urlextraction.UrlExtractingWebViewClient +import com.duckduckgo.app.browser.webview.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.app.di.AppCoroutineScope import com.duckduckgo.app.fire.* import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteRepository @@ -72,7 +73,6 @@ import com.duckduckgo.app.surrogates.ResourceSurrogates import com.duckduckgo.app.tabs.ui.GridViewColumnCalculator import com.duckduckgo.app.trackerdetection.CloakedCnameDetector import com.duckduckgo.app.trackerdetection.TrackerDetector -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.utils.DispatcherProvider import com.duckduckgo.cookies.api.CookieManagerProvider import com.duckduckgo.cookies.api.DuckDuckGoCookieManager diff --git a/app/src/main/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClient.kt b/app/src/main/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClient.kt index 63516ae4e464..5a774ea93970 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClient.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClient.kt @@ -28,7 +28,7 @@ import com.duckduckgo.app.browser.certificates.rootstore.CertificateValidationSt import com.duckduckgo.app.browser.certificates.rootstore.TrustedCertificateStore import com.duckduckgo.app.browser.cookies.ThirdPartyCookieManager import com.duckduckgo.app.browser.httpauth.WebViewHttpAuthStore -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration +import com.duckduckgo.app.browser.webview.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.utils.DispatcherProvider import com.duckduckgo.cookies.api.CookieManagerProvider import kotlinx.coroutines.* diff --git a/app/src/main/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegration.kt b/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt similarity index 92% rename from app/src/main/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegration.kt rename to app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt index b621492409ab..782905743d66 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegration.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt @@ -24,7 +24,6 @@ import androidx.core.net.toUri import com.duckduckgo.app.di.AppCoroutineScope import com.duckduckgo.app.di.IsMainProcess import com.duckduckgo.app.pixels.remoteconfig.AndroidBrowserConfigFeature -import com.duckduckgo.browser.api.MaliciousSiteBlockerWebViewIntegration import com.duckduckgo.common.utils.DispatcherProvider import com.duckduckgo.di.scopes.AppScope import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection @@ -37,6 +36,24 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import timber.log.Timber +interface MaliciousSiteBlockerWebViewIntegration { + + suspend fun shouldIntercept( + request: WebResourceRequest, + documentUri: Uri?, + onSiteBlockedAsync: () -> Unit, + ): WebResourceResponse? + + suspend fun shouldOverrideUrlLoading( + url: Uri, + webViewUrl: Uri?, + isForMainFrame: Boolean, + onSiteBlockedAsync: () -> Unit, + ): Boolean + + fun onPageLoadStarted() +} + @ContributesMultibinding(AppScope::class, PrivacyConfigCallbackPlugin::class) @ContributesBinding(AppScope::class, MaliciousSiteBlockerWebViewIntegration::class) class RealMaliciousSiteBlockerWebViewIntegration @Inject constructor( diff --git a/browser-api/src/main/java/com/duckduckgo/browser/api/MaliciousSiteBlockerWebViewIntegration.kt b/browser-api/src/main/java/com/duckduckgo/browser/api/MaliciousSiteBlockerWebViewIntegration.kt deleted file mode 100644 index 4b9a2e8c0b75..000000000000 --- a/browser-api/src/main/java/com/duckduckgo/browser/api/MaliciousSiteBlockerWebViewIntegration.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2024 DuckDuckGo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.duckduckgo.browser.api - -import android.net.Uri -import android.webkit.WebResourceRequest -import android.webkit.WebResourceResponse - -interface MaliciousSiteBlockerWebViewIntegration { - - suspend fun shouldIntercept( - request: WebResourceRequest, - documentUri: Uri?, - onSiteBlockedAsync: () -> Unit, - ): WebResourceResponse? - - suspend fun shouldOverrideUrlLoading( - url: Uri, - webViewUrl: Uri?, - isForMainFrame: Boolean, - onSiteBlockedAsync: () -> Unit, - ): Boolean - - fun onPageLoadStarted() -}