Commit 9d4434df authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[Subresource Filter] Componentize ads blocked infobar

This infobar will be reused by WebLayer. The componentization is
straightforward as all //chrome dependencies have been removed in prior
CLs.

Bug: 1116095
Change-Id: I9315ac43591e516dbef59b61aeaadf18505f14b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2470657Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817063}
parent 183ecee2
...@@ -3190,7 +3190,6 @@ generate_jni("chrome_jni_headers") { ...@@ -3190,7 +3190,6 @@ generate_jni("chrome_jni_headers") {
"java/src/org/chromium/chrome/browser/history/HistoryDeletionInfo.java", "java/src/org/chromium/chrome/browser/history/HistoryDeletionInfo.java",
"java/src/org/chromium/chrome/browser/historyreport/HistoryReportJniBridge.java", "java/src/org/chromium/chrome/browser/historyreport/HistoryReportJniBridge.java",
"java/src/org/chromium/chrome/browser/incognito/IncognitoUtils.java", "java/src/org/chromium/chrome/browser/incognito/IncognitoUtils.java",
"java/src/org/chromium/chrome/browser/infobar/AdsBlockedInfoBar.java",
"java/src/org/chromium/chrome/browser/infobar/AutofillCreditCardFillingInfoBar.java", "java/src/org/chromium/chrome/browser/infobar/AutofillCreditCardFillingInfoBar.java",
"java/src/org/chromium/chrome/browser/infobar/AutofillSaveCardInfoBar.java", "java/src/org/chromium/chrome/browser/infobar/AutofillSaveCardInfoBar.java",
"java/src/org/chromium/chrome/browser/infobar/DataReductionPromoInfoBarDelegate.java", "java/src/org/chromium/chrome/browser/infobar/DataReductionPromoInfoBarDelegate.java",
......
...@@ -812,7 +812,6 @@ chrome_java_sources = [ ...@@ -812,7 +812,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/incognito/interstitial/IncognitoInterstitialMediator.java", "java/src/org/chromium/chrome/browser/incognito/interstitial/IncognitoInterstitialMediator.java",
"java/src/org/chromium/chrome/browser/incognito/interstitial/IncognitoInterstitialProperties.java", "java/src/org/chromium/chrome/browser/incognito/interstitial/IncognitoInterstitialProperties.java",
"java/src/org/chromium/chrome/browser/incognito/interstitial/IncognitoInterstitialViewBinder.java", "java/src/org/chromium/chrome/browser/incognito/interstitial/IncognitoInterstitialViewBinder.java",
"java/src/org/chromium/chrome/browser/infobar/AdsBlockedInfoBar.java",
"java/src/org/chromium/chrome/browser/infobar/AutofillCreditCardFillingInfoBar.java", "java/src/org/chromium/chrome/browser/infobar/AutofillCreditCardFillingInfoBar.java",
"java/src/org/chromium/chrome/browser/infobar/AutofillSaveCardInfoBar.java", "java/src/org/chromium/chrome/browser/infobar/AutofillSaveCardInfoBar.java",
"java/src/org/chromium/chrome/browser/infobar/CardDetail.java", "java/src/org/chromium/chrome/browser/infobar/CardDetail.java",
......
...@@ -20,7 +20,6 @@ import org.chromium.base.test.util.CommandLineFlags; ...@@ -20,7 +20,6 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.DisabledTest;
import org.chromium.chrome.browser.MockSafeBrowsingApiHandler; import org.chromium.chrome.browser.MockSafeBrowsingApiHandler;
import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.infobar.AdsBlockedInfoBar;
import org.chromium.chrome.browser.infobar.InfoBarContainer; import org.chromium.chrome.browser.infobar.InfoBarContainer;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabCreationState; import org.chromium.chrome.browser.tab.TabCreationState;
...@@ -32,6 +31,7 @@ import org.chromium.chrome.test.ChromeTabbedActivityTestRule; ...@@ -32,6 +31,7 @@ import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils; import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.components.infobars.InfoBar; import org.chromium.components.infobars.InfoBar;
import org.chromium.components.safe_browsing.SafeBrowsingApiBridge; import org.chromium.components.safe_browsing.SafeBrowsingApiBridge;
import org.chromium.components.subresource_filter.AdsBlockedInfoBar;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.net.test.EmbeddedTestServer; import org.chromium.net.test.EmbeddedTestServer;
......
...@@ -272,6 +272,7 @@ include_rules = [ ...@@ -272,6 +272,7 @@ include_rules = [
"+components/startup_metric_utils/browser", "+components/startup_metric_utils/browser",
"+components/storage_monitor", "+components/storage_monitor",
"+components/strings/grit", "+components/strings/grit",
"+components/subresource_filter/android",
"+components/subresource_filter/content/browser", "+components/subresource_filter/content/browser",
"+components/subresource_filter/core/browser", "+components/subresource_filter/core/browser",
"+components/subresource_filter/core/common", "+components/subresource_filter/core/common",
......
...@@ -32,6 +32,7 @@ if (is_android) { ...@@ -32,6 +32,7 @@ if (is_android) {
"//chrome/test/android:chrome_java_test_support", "//chrome/test/android:chrome_java_test_support",
"//components/infobars/android:java", "//components/infobars/android:java",
"//components/safe_browsing/android:safe_browsing_java", "//components/safe_browsing/android:safe_browsing_java",
"//components/subresource_filter/android:java",
"//content/public/test/android:content_java_test_support", "//content/public/test/android:content_java_test_support",
"//net/android:net_java_test_support", "//net/android:net_java_test_support",
"//third_party/android_deps:androidx_test_runner_java", "//third_party/android_deps:androidx_test_runner_java",
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/metrics/public/cpp/ukm_source_id.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/browser/ui/android/content_settings/ads_blocked_infobar_delegate.h"
#include "chrome/browser/ui/android/infobars/chrome_confirm_infobar.h" #include "chrome/browser/ui/android/infobars/chrome_confirm_infobar.h"
#include "components/subresource_filter/android/ads_blocked_infobar_delegate.h"
#endif #endif
ChromeSubresourceFilterClient::ChromeSubresourceFilterClient( ChromeSubresourceFilterClient::ChromeSubresourceFilterClient(
...@@ -212,7 +212,7 @@ void ChromeSubresourceFilterClient::ShowUI(const GURL& url) { ...@@ -212,7 +212,7 @@ void ChromeSubresourceFilterClient::ShowUI(const GURL& url) {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
InfoBarService* infobar_service = InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents()); InfoBarService::FromWebContents(web_contents());
AdsBlockedInfobarDelegate::Create( subresource_filter::AdsBlockedInfobarDelegate::Create(
infobar_service, ChromeConfirmInfoBar::GetResourceIdMapper()); infobar_service, ChromeConfirmInfoBar::GetResourceIdMapper());
#endif #endif
// TODO(https://crbug.com/1103176): Plumb the actual frame reference here // TODO(https://crbug.com/1103176): Plumb the actual frame reference here
......
...@@ -662,8 +662,6 @@ static_library("ui") { ...@@ -662,8 +662,6 @@ static_library("ui") {
"android/chrome_http_auth_handler.h", "android/chrome_http_auth_handler.h",
"android/chrome_javascript_app_modal_dialog_android.cc", "android/chrome_javascript_app_modal_dialog_android.cc",
"android/color_chooser_dialog_android.cc", "android/color_chooser_dialog_android.cc",
"android/content_settings/ads_blocked_infobar_delegate.cc",
"android/content_settings/ads_blocked_infobar_delegate.h",
"android/context_menu_helper.cc", "android/context_menu_helper.cc",
"android/context_menu_helper.h", "android/context_menu_helper.h",
"android/device_dialog/bluetooth_chooser_android.cc", "android/device_dialog/bluetooth_chooser_android.cc",
...@@ -673,8 +671,6 @@ static_library("ui") { ...@@ -673,8 +671,6 @@ static_library("ui") {
"android/device_dialog/usb_chooser_dialog_android.cc", "android/device_dialog/usb_chooser_dialog_android.cc",
"android/device_dialog/usb_chooser_dialog_android.h", "android/device_dialog/usb_chooser_dialog_android.h",
"android/external_protocol_dialog_android.cc", "android/external_protocol_dialog_android.cc",
"android/infobars/ads_blocked_infobar.cc",
"android/infobars/ads_blocked_infobar.h",
"android/infobars/autofill_credit_card_filling_infobar.cc", "android/infobars/autofill_credit_card_filling_infobar.cc",
"android/infobars/autofill_credit_card_filling_infobar.h", "android/infobars/autofill_credit_card_filling_infobar.h",
"android/infobars/autofill_save_card_infobar.cc", "android/infobars/autofill_save_card_infobar.cc",
......
...@@ -5,27 +5,51 @@ ...@@ -5,27 +5,51 @@
import("//build/config/android/rules.gni") import("//build/config/android/rules.gni")
generate_jni("subresource_filter_jni_headers") { generate_jni("subresource_filter_jni_headers") {
sources = [ "java/src/org/chromium/components/subresource_filter/SubresourceFilterFeatureList.java" ] sources = [
"java/src/org/chromium/components/subresource_filter/AdsBlockedInfoBar.java",
"java/src/org/chromium/components/subresource_filter/SubresourceFilterFeatureList.java",
]
} }
android_library("java") { android_library("java") {
sources = [ "java/src/org/chromium/components/subresource_filter/SubresourceFilterFeatureList.java" ] sources = [
"java/src/org/chromium/components/subresource_filter/AdsBlockedInfoBar.java",
"java/src/org/chromium/components/subresource_filter/SubresourceFilterFeatureList.java",
]
deps = [ deps = [
":java_resources", ":java_resources",
":subresource_filter_jni_headers", ":subresource_filter_jni_headers",
"//base:base_java", "//base:base_java",
"//base:jni_java", "//base:jni_java",
"//components/infobars/android:infobar_android_enums_java",
"//components/infobars/android:java",
"//third_party/android_deps:androidx_appcompat_appcompat_java",
"//ui/android:ui_no_recycler_view_java",
] ]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
resources_package = "org.chromium.components.subresource_filter" resources_package = "org.chromium.components.subresource_filter"
} }
source_set("android") { source_set("android") {
sources = [ "subresource_filter_feature_list.cc" ] sources = [
"ads_blocked_infobar.cc",
"ads_blocked_infobar.h",
"ads_blocked_infobar_delegate.cc",
"ads_blocked_infobar_delegate.h",
"subresource_filter_feature_list.cc",
]
deps = [ deps = [
":subresource_filter_jni_headers", ":subresource_filter_jni_headers",
"//base", "//base",
"//components/infobars/android",
"//components/infobars/content",
"//components/infobars/core",
"//components/resources:android_resources",
"//components/strings:components_strings_grit",
"//components/subresource_filter/content/browser",
"//components/subresource_filter/core/browser", "//components/subresource_filter/core/browser",
"//content/public/browser",
"//ui/base",
] ]
} }
......
include_rules = [
"+components/infobars",
"+components/resources",
"+components/strings",
"+components/subresource_filter/content/browser",
"+content/public/browser",
"+ui/android/java",
"+ui/base/l10n",
]
...@@ -2,16 +2,18 @@ ...@@ -2,16 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/ui/android/infobars/ads_blocked_infobar.h" #include "components/subresource_filter/android/ads_blocked_infobar.h"
#include <utility> #include <utility>
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "chrome/android/chrome_jni_headers/AdsBlockedInfoBar_jni.h" #include "components/subresource_filter/android/subresource_filter_jni_headers/AdsBlockedInfoBar_jni.h"
using base::android::JavaParamRef; using base::android::JavaParamRef;
namespace subresource_filter {
AdsBlockedInfoBar::AdsBlockedInfoBar( AdsBlockedInfoBar::AdsBlockedInfoBar(
std::unique_ptr<AdsBlockedInfobarDelegate> delegate, std::unique_ptr<AdsBlockedInfobarDelegate> delegate,
const ResourceIdMapper& resource_id_mapper) const ResourceIdMapper& resource_id_mapper)
...@@ -40,3 +42,5 @@ AdsBlockedInfoBar::CreateRenderInfoBar(JNIEnv* env) { ...@@ -40,3 +42,5 @@ AdsBlockedInfoBar::CreateRenderInfoBar(JNIEnv* env) {
ok_button_text, reload_button_text, ok_button_text, reload_button_text,
toggle_text, explanation_message); toggle_text, explanation_message);
} }
} // namespace subresource_filter
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ANDROID_INFOBARS_ADS_BLOCKED_INFOBAR_H_ #ifndef COMPONENTS_SUBRESOURCE_FILTER_ANDROID_ADS_BLOCKED_INFOBAR_H_
#define CHROME_BROWSER_UI_ANDROID_INFOBARS_ADS_BLOCKED_INFOBAR_H_ #define COMPONENTS_SUBRESOURCE_FILTER_ANDROID_ADS_BLOCKED_INFOBAR_H_
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/ui/android/content_settings/ads_blocked_infobar_delegate.h"
#include "components/infobars/android/confirm_infobar.h" #include "components/infobars/android/confirm_infobar.h"
#include "components/subresource_filter/android/ads_blocked_infobar_delegate.h"
namespace subresource_filter {
class AdsBlockedInfoBar : public infobars::ConfirmInfoBar { class AdsBlockedInfoBar : public infobars::ConfirmInfoBar {
public: public:
...@@ -24,4 +26,6 @@ class AdsBlockedInfoBar : public infobars::ConfirmInfoBar { ...@@ -24,4 +26,6 @@ class AdsBlockedInfoBar : public infobars::ConfirmInfoBar {
DISALLOW_COPY_AND_ASSIGN(AdsBlockedInfoBar); DISALLOW_COPY_AND_ASSIGN(AdsBlockedInfoBar);
}; };
#endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_ADS_BLOCKED_INFOBAR_H_ } // namespace subresource_filter
#endif // COMPONENTS_SUBRESOURCE_FILTER_ANDROID_ADS_BLOCKED_INFOBAR_H_
...@@ -2,22 +2,24 @@ ...@@ -2,22 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/ui/android/content_settings/ads_blocked_infobar_delegate.h" #include "components/subresource_filter/android/ads_blocked_infobar_delegate.h"
#include <memory> #include <memory>
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/android/infobars/ads_blocked_infobar.h"
#include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/content/content_infobar_manager.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
#include "components/resources/android/theme_resources.h" #include "components/resources/android/theme_resources.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/subresource_filter/android/ads_blocked_infobar.h"
#include "components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.h" #include "components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.h"
#include "components/subresource_filter/core/browser/subresource_filter_constants.h" #include "components/subresource_filter/core/browser/subresource_filter_constants.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
namespace subresource_filter {
// static // static
void AdsBlockedInfobarDelegate::Create( void AdsBlockedInfobarDelegate::Create(
infobars::ContentInfoBarManager* infobar_manager, infobars::ContentInfoBarManager* infobar_manager,
...@@ -84,3 +86,5 @@ bool AdsBlockedInfobarDelegate::Cancel() { ...@@ -84,3 +86,5 @@ bool AdsBlockedInfobarDelegate::Cancel() {
} }
AdsBlockedInfobarDelegate::AdsBlockedInfobarDelegate() = default; AdsBlockedInfobarDelegate::AdsBlockedInfobarDelegate() = default;
} // namespace subresource_filter
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ANDROID_CONTENT_SETTINGS_ADS_BLOCKED_INFOBAR_DELEGATE_H_ #ifndef COMPONENTS_SUBRESOURCE_FILTER_ANDROID_ADS_BLOCKED_INFOBAR_DELEGATE_H_
#define CHROME_BROWSER_UI_ANDROID_CONTENT_SETTINGS_ADS_BLOCKED_INFOBAR_DELEGATE_H_ #define COMPONENTS_SUBRESOURCE_FILTER_ANDROID_ADS_BLOCKED_INFOBAR_DELEGATE_H_
#include "base/macros.h" #include "base/macros.h"
#include "components/infobars/android/infobar_android.h" #include "components/infobars/android/infobar_android.h"
...@@ -13,6 +13,8 @@ namespace infobars { ...@@ -13,6 +13,8 @@ namespace infobars {
class ContentInfoBarManager; class ContentInfoBarManager;
} }
namespace subresource_filter {
// This infobar appears when the user proceeds through Safe Browsing warning // This infobar appears when the user proceeds through Safe Browsing warning
// interstitials to a site with deceptive embedded content. It tells the user // interstitials to a site with deceptive embedded content. It tells the user
// ads have been blocked and provides a button to reload the page with the // ads have been blocked and provides a button to reload the page with the
...@@ -51,4 +53,6 @@ class AdsBlockedInfobarDelegate : public ConfirmInfoBarDelegate { ...@@ -51,4 +53,6 @@ class AdsBlockedInfobarDelegate : public ConfirmInfoBarDelegate {
DISALLOW_COPY_AND_ASSIGN(AdsBlockedInfobarDelegate); DISALLOW_COPY_AND_ASSIGN(AdsBlockedInfobarDelegate);
}; };
#endif // CHROME_BROWSER_UI_ANDROID_CONTENT_SETTINGS_ADS_BLOCKED_INFOBAR_DELEGATE_H_ } // namespace subresource_filter
#endif // COMPONENTS_SUBRESOURCE_FILTER_ANDROID_ADS_BLOCKED_INFOBAR_DELEGATE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.infobar; package org.chromium.components.subresource_filter;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
...@@ -14,11 +14,12 @@ import android.widget.CompoundButton.OnCheckedChangeListener; ...@@ -14,11 +14,12 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.browser.infobar.ActionType;
import org.chromium.components.infobars.ConfirmInfoBar; import org.chromium.components.infobars.ConfirmInfoBar;
import org.chromium.components.infobars.InfoBar; import org.chromium.components.infobars.InfoBar;
import org.chromium.components.infobars.InfoBarControlLayout; import org.chromium.components.infobars.InfoBarControlLayout;
import org.chromium.components.infobars.InfoBarLayout; import org.chromium.components.infobars.InfoBarLayout;
import org.chromium.components.subresource_filter.R;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
import org.chromium.ui.widget.ButtonCompat; import org.chromium.ui.widget.ButtonCompat;
...@@ -27,6 +28,7 @@ import org.chromium.ui.widget.ButtonCompat; ...@@ -27,6 +28,7 @@ import org.chromium.ui.widget.ButtonCompat;
* an interstitial warning that the site shows deceptive content, or when the site is known to show * an interstitial warning that the site shows deceptive content, or when the site is known to show
* intrusive ads. * intrusive ads.
*/ */
@JNINamespace("subresource_filter")
public class AdsBlockedInfoBar extends ConfirmInfoBar implements OnCheckedChangeListener { public class AdsBlockedInfoBar extends ConfirmInfoBar implements OnCheckedChangeListener {
private final String mMessage; private final String mMessage;
private final String mFollowUpMessage; private final String mFollowUpMessage;
......
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