Commit c168f357 authored by Theresa Wellington's avatar Theresa Wellington Committed by Commit Bot

[Android] Update history manager (i) icon when privacy disclaimers avail

Explicitly update the info icon visibility when the history backend
alerts that whether the user has other forms of browsing data has
changed. This fixes a bug where sometimes the info icon wouldn't appear
until after a user scrolled for users who had previously chosen to hide
history info.

BUG=1071468

Change-Id: I293e78b46fd6fbe5fd8200cbac0bfb7dfc937f3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153930Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Theresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760133}
parent 2a0a9412
......@@ -273,6 +273,7 @@ public class HistoryAdapter extends DateDividedAdapter implements BrowsingHistor
public void hasOtherFormsOfBrowsingData(boolean hasOtherForms) {
mHasOtherFormsOfBrowsingData = hasOtherForms;
setPrivacyDisclaimer();
mHistoryManager.onHasPrivacyDisclaimersChanged();
}
@Override
......
......@@ -504,6 +504,13 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
&& !mSelectionDelegate.isSelectionEnabled();
}
/**
* Called to notify when privacy disclaimers visibility has changed.
*/
void onHasPrivacyDisclaimersChanged() {
mToolbar.updateInfoMenuItem(shouldShowInfoButton(), shouldShowInfoHeaderIfAvailable());
}
/**
* @return True if the available privacy disclaimers should be shown.
* Note that this may return true even if there are currently no privacy disclaimers.
......
......@@ -51,6 +51,7 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.widget.DateDividedAdapter;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils;
import org.chromium.chrome.test.util.browser.signin.SigninTestUtil;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.components.browser_ui.widget.selectable_list.SelectableItemView;
......@@ -66,6 +67,7 @@ import org.chromium.ui.base.PageTransition;
import org.chromium.ui.test.util.UiRestriction;
import java.util.Date;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
/**
......@@ -429,6 +431,29 @@ public class HistoryActivityTest {
signinController.setSignedInAccountName(null);
}
@Test
@SmallTest
public void testInfoIcon_OtherFormsOfBrowsingData() throws ExecutionException {
final HistoryManagerToolbar toolbar = mHistoryManager.getToolbarForTests();
final MenuItem infoMenuItem = toolbar.getItemById(R.id.info_menu_id);
setHasOtherFormsOfBrowsingData(true);
Assert.assertTrue("Info icon should be visible.", infoMenuItem.isVisible());
// Hide disclaimers to simulate setup for https://crbug.com/1071468.
TestThreadUtils.runOnUiThreadBlocking(() -> mHistoryManager.onMenuItemClick(infoMenuItem));
Assert.assertFalse("Privacy disclaimers should be hidden.",
mHistoryManager.shouldShowInfoHeaderIfAvailable());
// Simulate call indicating there are not other forms of browsing data.
setHasOtherFormsOfBrowsingData(false);
RecyclerViewTestUtils.waitForStableRecyclerView(mRecyclerView);
Assert.assertFalse("Info menu item should be hidden.", infoMenuItem.isVisible());
// Simulate call indicating there are other forms of browsing data.
setHasOtherFormsOfBrowsingData(true);
Assert.assertTrue("Info menu item should bre visible.", infoMenuItem.isVisible());
}
@Test
@SmallTest
public void testInfoHeaderInSearchMode() throws Exception {
......
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