From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Fri, 21 Aug 2020 22:39:23 +0200
Subject: Remove blocklisted URLs upon bookmark creation

License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
 .../chromium/chrome/browser/app/ChromeActivity.java |  1 -
 .../chrome/browser/bookmarks/TabBookmarker.java     | 13 +++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java
@@ -293,7 +293,6 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
     private TabContentManager mTabContentManager;
 
     private UmaSessionStats mUmaSessionStats;
-    private ContextReporter mContextReporter;
 
     private boolean mPartnerBrowserRefreshNeeded;
 
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/TabBookmarker.java b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/TabBookmarker.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/TabBookmarker.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/TabBookmarker.java
@@ -20,6 +20,11 @@ import org.chromium.components.bookmarks.BookmarkItem;
 import org.chromium.components.bookmarks.BookmarkType;
 import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
 
+import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.chrome.browser.suggestions.SuggestionsDependencyFactory;
+import org.chromium.chrome.browser.suggestions.mostvisited.MostVisitedSites;
+import org.chromium.url.GURL;
+
 /**
  * Helper class for managing the UI flow for bookmarking the active tab and kicking off the backend.
  * Shows a snackbar if a new bookmark was added. If the bookmark already exists, kicks off edit
@@ -31,6 +36,7 @@ public class TabBookmarker {
     private final Supplier<BottomSheetController> mBottomSheetControllerSupplier;
     private final Supplier<SnackbarManager> mSnackbarManagerSupplier;
     private final boolean mIsCustomTab;
+    private MostVisitedSites mMostVisitedSites;
 
     /**
      * Constructor.
@@ -97,6 +103,13 @@ public class TabBookmarker {
 
         // Defense in depth against the UI being erroneously enabled.
         BookmarkModel bridge = mBookmarkModelSupplier.get();
+	// remove blocklisted URL from most visited sites
+	if (mMostVisitedSites == null) {
+            mMostVisitedSites =
+                SuggestionsDependencyFactory.getInstance().createMostVisitedSites(Profile.getLastUsedRegularProfile());
+        }
+        mMostVisitedSites.removeBlocklistedUrl(tabToBookmark.getOriginalUrl());
+
         if (bridge == null || !bridge.isEditBookmarksEnabled()) {
             assert false;
             return;
--
2.25.1
