Commit 3746e638 authored by tedchoc's avatar tedchoc Committed by Commit bot

Disable contextual search if the FRE has not been completed.

BUG=673522

Review-Url: https://codereview.chromium.org/2602813002
Cr-Commit-Position: refs/heads/master@{#440898}
parent 0fab3560
...@@ -10,6 +10,7 @@ import android.view.ContextMenu; ...@@ -10,6 +10,7 @@ import android.view.ContextMenu;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChangeReason; import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChangeReason;
import org.chromium.chrome.browser.firstrun.FirstRunStatus;
import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.TemplateUrlService; import org.chromium.chrome.browser.search_engines.TemplateUrlService;
...@@ -216,6 +217,7 @@ public class ContextualSearchTabHelper ...@@ -216,6 +217,7 @@ public class ContextualSearchTabHelper
if (manager == null) return false; if (manager == null) return false;
return !cvc.getWebContents().isIncognito() return !cvc.getWebContents().isIncognito()
&& FirstRunStatus.getFirstRunFlowComplete()
&& !PrefServiceBridge.getInstance().isContextualSearchDisabled() && !PrefServiceBridge.getInstance().isContextualSearchDisabled()
&& TemplateUrlService.getInstance().isDefaultSearchEngineGoogle() && TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()
// Svelte and Accessibility devices are incompatible with the first-run flow and // Svelte and Accessibility devices are incompatible with the first-run flow and
......
...@@ -13,6 +13,7 @@ import android.app.Instrumentation.ActivityMonitor; ...@@ -13,6 +13,7 @@ import android.app.Instrumentation.ActivityMonitor;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Point; import android.graphics.Point;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.test.filters.SmallTest; import android.support.test.filters.SmallTest;
...@@ -46,6 +47,7 @@ import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ...@@ -46,6 +47,7 @@ import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context
import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchQuickActionControl; import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchQuickActionControl;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchFakeServer.FakeSlowResolveSearch; import org.chromium.chrome.browser.contextualsearch.ContextualSearchFakeServer.FakeSlowResolveSearch;
import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler;
import org.chromium.chrome.browser.firstrun.FirstRunStatus;
import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection; import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection;
import org.chromium.chrome.browser.omnibox.UrlBar; import org.chromium.chrome.browser.omnibox.UrlBar;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
...@@ -120,6 +122,12 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro ...@@ -120,6 +122,12 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro
// We have to set up the test server before starting the activity. // We have to set up the test server before starting the activity.
mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext()); mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
FirstRunStatus.setFirstRunFlowComplete(true);
}
});
super.setUp(); super.setUp();
mManager = getActivity().getContextualSearchManager(); mManager = getActivity().getContextualSearchManager();
...@@ -151,6 +159,12 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro ...@@ -151,6 +159,12 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
mTestServer.stopAndDestroyServer(); mTestServer.stopAndDestroyServer();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
FirstRunStatus.setFirstRunFlowComplete(false);
}
});
super.tearDown(); super.tearDown();
} }
...@@ -971,7 +985,12 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro ...@@ -971,7 +985,12 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override @Override
public void run() { public void run() {
ContextUtils.getAppSharedPreferences().edit().clear().apply(); SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
boolean freStatus = prefs.getBoolean(FirstRunStatus.FIRST_RUN_FLOW_COMPLETE, false);
prefs.edit()
.clear()
.putBoolean(FirstRunStatus.FIRST_RUN_FLOW_COMPLETE, freStatus)
.apply();
} }
}); });
} }
......
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