From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Sat, 10 Nov 2018 17:20:21 +0100
Subject: Disable promos displayed in bookmarks manager

Remove personalized signin promo view from
bookmarks, never reach signin thresholds.
---
 .../personalized_signin_promo_view_bookmarks.xml   | 30 ----------------------
 .../browser/bookmarks/BookmarkItemsAdapter.java    | 23 ++---------------
 .../browser/signin/SigninPromoController.java      | 19 ++------------
 chrome/android/java_sources.gni                    |  1 -
 4 files changed, 4 insertions(+), 69 deletions(-)
 delete mode 100644 chrome/android/java/res/layout/personalized_signin_promo_view_bookmarks.xml

diff --git a/chrome/android/java/res/layout/personalized_signin_promo_view_bookmarks.xml b/chrome/android/java/res/layout/personalized_signin_promo_view_bookmarks.xml
deleted file mode 100644
--- a/chrome/android/java/res/layout/personalized_signin_promo_view_bookmarks.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright 2017 The Chromium Authors. All rights reserved.
-     Use of this source code is governed by a BSD-style license that can be
-     found in the LICENSE file. -->
-
-<org.chromium.chrome.browser.signin.PersonalizedSigninPromoView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/signin_promo_view_container"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:layout_margin="16dp"
-    android:background="@drawable/hairline_border_card_background"
-    android:gravity="center_horizontal"
-    android:orientation="vertical"
-    android:paddingBottom="12dp"
-    android:paddingTop="14dp">
-
-    <FrameLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginBottom="12dp"
-        android:layout_marginEnd="12dp"
-        android:layout_marginStart="12dp">
-
-        <include layout="@layout/personalized_signin_promo_view_header"/>
-    </FrameLayout>
-
-    <include layout="@layout/personalized_signin_promo_view_body"/>
-
-</org.chromium.chrome.browser.signin.PersonalizedSigninPromoView>
\ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkItemsAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkItemsAdapter.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkItemsAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkItemsAdapter.java
@@ -57,7 +57,6 @@ class BookmarkItemsAdapter
 
     private BookmarkDelegate mDelegate;
     private Context mContext;
-    private BookmarkPromoHeader mPromoHeaderManager;
     private String mSearchText;
     private BookmarkId mCurrentFolder;
 
@@ -211,9 +210,9 @@ class BookmarkItemsAdapter
 
         switch (viewType) {
             case ViewType.PERSONALIZED_SIGNIN_PROMO:
-                return mPromoHeaderManager.createPersonalizedSigninPromoHolder(parent);
+                return null;
             case ViewType.SYNC_PROMO:
-                return mPromoHeaderManager.createSyncPromoHolder(parent);
+                return null;
             case ViewType.FOLDER:
                 BookmarkFolderRow folder = (BookmarkFolderRow) LayoutInflater.from(
                         parent.getContext()).inflate(R.layout.bookmark_folder_row, parent, false);
@@ -234,8 +233,6 @@ class BookmarkItemsAdapter
     public void onBindViewHolder(ViewHolder holder, int position) {
         switch (holder.getItemViewType()) {
             case ViewType.PERSONALIZED_SIGNIN_PROMO:
-                PersonalizedSigninPromoView view = (PersonalizedSigninPromoView) holder.itemView;
-                mPromoHeaderManager.setupPersonalizedSigninPromo(view);
                 break;
             case ViewType.SYNC_PROMO:
                 break;
@@ -254,7 +251,6 @@ class BookmarkItemsAdapter
     public void onViewRecycled(ViewHolder holder) {
         switch (holder.getItemViewType()) {
             case ViewType.PERSONALIZED_SIGNIN_PROMO:
-                mPromoHeaderManager.detachPersonalizePromoView();
                 break;
             default:
                 // Other view holders don't have special recycling code.
@@ -289,7 +285,6 @@ class BookmarkItemsAdapter
             }
         };
 
-        mPromoHeaderManager = new BookmarkPromoHeader(mContext, promoHeaderChangeAction);
         populateTopLevelFoldersList();
         notifyDataSetChanged();
     }
@@ -300,7 +295,6 @@ class BookmarkItemsAdapter
         mDelegate.removeUIObserver(this);
         mDelegate.getModel().removeObserver(mBookmarkModelObserver);
         mDelegate = null;
-        mPromoHeaderManager.destroy();
     }
 
     @Override
@@ -367,19 +361,6 @@ class BookmarkItemsAdapter
         if (currentUIState == BookmarkUIState.STATE_SEARCHING) return;
 
         assert currentUIState == BookmarkUIState.STATE_FOLDER : "Unexpected UI state";
-
-        switch (mPromoHeaderManager.getPromoState()) {
-            case BookmarkPromoHeader.PromoState.PROMO_NONE:
-                return;
-            case BookmarkPromoHeader.PromoState.PROMO_SIGNIN_PERSONALIZED:
-                mPromoHeaderSection.add(ViewType.PERSONALIZED_SIGNIN_PROMO);
-                return;
-            case BookmarkPromoHeader.PromoState.PROMO_SYNC:
-                mPromoHeaderSection.add(ViewType.SYNC_PROMO);
-                return;
-            default:
-                assert false : "Unexpected value for promo state!";
-        }
     }
 
     private void populateTopLevelFoldersList() {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/SigninPromoController.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/SigninPromoController.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/signin/SigninPromoController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/SigninPromoController.java
@@ -77,23 +77,8 @@ public class SigninPromoController {
      */
     public static boolean hasNotReachedImpressionLimit(@AccessPoint int accessPoint) {
         SharedPreferences sharedPreferences = ContextUtils.getAppSharedPreferences();
-        switch (accessPoint) {
-            case SigninAccessPoint.BOOKMARK_MANAGER:
-                return sharedPreferences.getInt(SIGNIN_PROMO_IMPRESSIONS_COUNT_BOOKMARKS, 0)
-                        < MAX_IMPRESSIONS_BOOKMARKS;
-            case SigninAccessPoint.NTP_CONTENT_SUGGESTIONS:
-                // There is no impression limit for NTP content suggestions.
-                return true;
-            case SigninAccessPoint.RECENT_TABS:
-                // There is no impression limit for Recent Tabs.
-                return true;
-            case SigninAccessPoint.SETTINGS:
-                return sharedPreferences.getInt(SIGNIN_PROMO_IMPRESSIONS_COUNT_SETTINGS, 0)
-                        < MAX_IMPRESSIONS_SETTINGS;
-            default:
-                assert false : "Unexpected value for access point: " + accessPoint;
-                return false;
-        }
+        // never show anything
+        return true;
     }
 
     /**
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni
--- a/chrome/android/java_sources.gni
+++ b/chrome/android/java_sources.gni
@@ -166,7 +166,6 @@ chrome_java_sources = [
   "java/src/org/chromium/chrome/browser/bookmarks/BookmarkManager.java",
   "java/src/org/chromium/chrome/browser/bookmarks/BookmarkModel.java",
   "java/src/org/chromium/chrome/browser/bookmarks/BookmarkPage.java",
-  "java/src/org/chromium/chrome/browser/bookmarks/BookmarkPromoHeader.java",
   "java/src/org/chromium/chrome/browser/bookmarks/BookmarkRow.java",
   "java/src/org/chromium/chrome/browser/bookmarks/BookmarkUIObserver.java",
   "java/src/org/chromium/chrome/browser/bookmarks/BookmarkUIState.java",
-- 
2.11.0

