Commit 36b99bd7 authored by David Maunder's avatar David Maunder Committed by Commit Bot

Disable Server fetcher for incognito tab model

We should not be enabling the server fetcher for an incognito tab
model due to privacy constraints.

Bug: 1108571
Change-Id: I30b99d0fff8b85e3333f8c50f5bd8157f957e2c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315241Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: David Maunder <davidjm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792395}
parent ac7c01b1
...@@ -78,12 +78,13 @@ public class TabContext { ...@@ -78,12 +78,13 @@ public class TabContext {
public final String title; public final String title;
public final String originalUrl; public final String originalUrl;
public final String visibleUrl; public final String visibleUrl;
public final boolean isIncognito;
/** /**
* Constructs a new TabInfo object * Constructs a new TabInfo object
*/ */
protected TabInfo(int id, String title, String url, String originalUrl, String referrerUrl, protected TabInfo(int id, String title, String url, String originalUrl, String referrerUrl,
long timestampMillis, String visibleUrl) { long timestampMillis, String visibleUrl, boolean isIncognito) {
this.id = id; this.id = id;
this.title = title; this.title = title;
this.url = url; this.url = url;
...@@ -91,6 +92,15 @@ public class TabContext { ...@@ -91,6 +92,15 @@ public class TabContext {
this.referrerUrl = referrerUrl; this.referrerUrl = referrerUrl;
this.timestampMillis = timestampMillis; this.timestampMillis = timestampMillis;
this.visibleUrl = visibleUrl; this.visibleUrl = visibleUrl;
this.isIncognito = isIncognito;
}
/**
* Constructs a new non-incognito TabInfo object
*/
protected TabInfo(int id, String title, String url, String originalUrl, String referrerUrl,
long timestampMillis, String visibleUrl) {
this(id, title, url, originalUrl, referrerUrl, timestampMillis, visibleUrl, false);
} }
/** /**
...@@ -100,7 +110,7 @@ public class TabContext { ...@@ -100,7 +110,7 @@ public class TabContext {
String referrerUrl = getReferrerUrlFromTab(tab); String referrerUrl = getReferrerUrlFromTab(tab);
return new TabInfo(tab.getId(), tab.getTitle(), tab.getUrlString(), return new TabInfo(tab.getId(), tab.getTitle(), tab.getUrlString(),
tab.getOriginalUrl(), referrerUrl != null ? referrerUrl : "", tab.getOriginalUrl(), referrerUrl != null ? referrerUrl : "",
tab.getTimestampMillis(), tab.getUrlString()); tab.getTimestampMillis(), tab.getUrlString(), tab.isIncognito());
} }
public double getSiteEngagementScore() { public double getSiteEngagementScore() {
...@@ -272,7 +282,8 @@ public class TabContext { ...@@ -272,7 +282,8 @@ public class TabContext {
tabs.add(new TabContext.TabInfo(Integer.parseInt(jsonTab.getString(ID_KEY)), tabs.add(new TabContext.TabInfo(Integer.parseInt(jsonTab.getString(ID_KEY)),
jsonTab.getString(TITLE_KEY), jsonTab.getString(URL_KEY), null, jsonTab.getString(TITLE_KEY), jsonTab.getString(URL_KEY), null,
jsonTab.getString(REFERRER_KEY), jsonTab.getString(REFERRER_KEY),
Long.parseLong(jsonTab.getString(TIMESTAMP_KEY)), null)); Long.parseLong(jsonTab.getString(TIMESTAMP_KEY)), null,
false /** Only support non-incognito for now*/));
} }
return tabs; return tabs;
} }
......
...@@ -63,6 +63,13 @@ public class TabSuggestionsServerFetcher implements TabSuggestionsFetcher { ...@@ -63,6 +63,13 @@ public class TabSuggestionsServerFetcher implements TabSuggestionsFetcher {
@Override @Override
public void fetch(TabContext tabContext, Callback<TabSuggestionsFetcherResults> callback) { public void fetch(TabContext tabContext, Callback<TabSuggestionsFetcherResults> callback) {
try { try {
for (TabContext.TabInfo tabInfo : tabContext.getUngroupedTabs()) {
if (tabInfo.isIncognito) {
callback.onResult(
new TabSuggestionsFetcherResults(Collections.emptyList(), tabContext));
return;
}
}
EndpointFetcher.fetchUsingChromeAPIKey(res EndpointFetcher.fetchUsingChromeAPIKey(res
-> { fetchCallback(res, callback, tabContext); }, -> { fetchCallback(res, callback, tabContext); },
mProfileForTesting == null ? Profile.getLastUsedRegularProfile() mProfileForTesting == null ? Profile.getLastUsedRegularProfile()
......
...@@ -57,6 +57,8 @@ public class TabSuggestionsServerFetcherUnitTest { ...@@ -57,6 +57,8 @@ public class TabSuggestionsServerFetcherUnitTest {
2, "Amazon.com", "https://www.amazon.com", "", "", 1588817215266L, ""); 2, "Amazon.com", "https://www.amazon.com", "", "", 1588817215266L, "");
private static final TabContext.TabInfo TAB_INFO_GOOGLE = new TabContext.TabInfo( private static final TabContext.TabInfo TAB_INFO_GOOGLE = new TabContext.TabInfo(
3, "Google", "https://www.google.com", "", "", 1588817256727L, ""); 3, "Google", "https://www.google.com", "", "", 1588817256727L, "");
private static final TabContext.TabInfo TAB_INFO_INCOGNITO = new TabContext.TabInfo(
4, "Incognito site", "https://www.incognito.com", "", "", 158881926727L, "");
private static final TabContext TAB_CONTEXT_GROUP_ALL = private static final TabContext TAB_CONTEXT_GROUP_ALL =
new TabContext(Arrays.asList(TAB_INFO_YANDEX, TAB_INFO_BING, TAB_INFO_GOOGLE), new TabContext(Arrays.asList(TAB_INFO_YANDEX, TAB_INFO_BING, TAB_INFO_GOOGLE),
Collections.emptyList()); Collections.emptyList());
...@@ -211,4 +213,13 @@ public class TabSuggestionsServerFetcherUnitTest { ...@@ -211,4 +213,13 @@ public class TabSuggestionsServerFetcherUnitTest {
} }
} }
} }
@Test
public void testServerFetcherDisabledIncognito() throws InterruptedException {
TabContext tabContext =
new TabContext(Arrays.asList(TAB_INFO_INCOGNITO), Collections.emptyList());
mTabSuggestionsServerFetcher.fetch(tabContext, (fetcherResults) -> {
Assert.assertTrue(fetcherResults.tabSuggestions.isEmpty());
});
}
} }
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