Commit c7557ad5 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[TTS] Remove special treatment of plain HTTP pages

Removes the special treatment of plain HTTP pages with respect to
privacy. These pages were considered privacy-insensitive, but now
we treat them the same way as secure HTTPS pages.

BUG=1124397

Change-Id: Ic3f5640ffa020e7f4656a78965b6f87662c039a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2393526
Commit-Queue: Donn Denman <donnd@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Reviewed-by: default avatarJinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805448}
parent ce5dd206
......@@ -153,7 +153,7 @@ class ContextualSearchPolicy {
return false;
}
return isPromoAvailable() ? isBasePageHTTP(mNetworkCommunicator.getBasePageUrl()) : true;
return !isUserUndecided(); // The user must have decided on privacy to resolve page content.
}
/** @return Whether a long-press gesture can resolve. */
......@@ -169,7 +169,7 @@ class ContextualSearchPolicy {
boolean canSendSurroundings() {
if (mDidOverrideDecidedStateForTesting) return mDecidedStateForTesting;
return isPromoAvailable() ? isBasePageHTTP(mNetworkCommunicator.getBasePageUrl()) : true;
return !isUserUndecided(); // The user must have decided on privacy to send page content.
}
/**
......
......@@ -57,7 +57,6 @@ class ContextualSearchFakeServer
private boolean mUseInvalidLowPriorityPath;
private String mSearchTermRequested;
private boolean mShouldUseHttps;
private boolean mIsOnline = true;
private boolean mIsExactResolve;
......@@ -463,14 +462,6 @@ class ContextualSearchFakeServer
return mLoadedUrlCount;
}
/**
* Sets whether to return an HTTPS URL instead of HTTP, from {@link #getBasePageUrl}.
*/
@VisibleForTesting
void setShouldUseHttps(boolean setting) {
mShouldUseHttps = setting;
}
/**
* @return Whether onShow() was ever called for the current {@code WebContents}.
*/
......@@ -494,7 +485,6 @@ class ContextualSearchFakeServer
void reset() {
mLoadedUrl = null;
mSearchTermRequested = null;
mShouldUseHttps = false;
mIsOnline = true;
mLoadedUrlCount = 0;
mUseInvalidLowPriorityPath = false;
......@@ -570,11 +560,13 @@ class ContextualSearchFakeServer
@Nullable
public URL getBasePageUrl() {
URL baseUrl = mBaseManager.getBasePageUrl();
if (mShouldUseHttps && baseUrl != null) {
if (baseUrl != null) {
try {
return new URL(baseUrl.toString().replace("http://", "https://"));
// Return plain HTTP URLs so we can test that we don't give them our legacy privacy
// exceptions.
return new URL(baseUrl.toString().replace("https://", "http://"));
} catch (MalformedURLException e) {
// TODO(donnd): Auto-generated catch block
// TODO(donnd): Replace Auto-generated catch block
e.printStackTrace();
}
}
......
......@@ -2030,62 +2030,31 @@ public class ContextualSearchManagerTest {
}
//============================================================================================
// HTTP/HTTPS for Undecided/Decided users.
// Undecided/Decided users.
//============================================================================================
/**
* Tests that HTTPS does not resolve or preload when the privacy Opt-in has not been accepted.
* Tests that we do not resolve or preload when the privacy Opt-in has not been accepted.
*/
@Test
@SmallTest
@Feature({"ContextualSearch"})
@ParameterAnnotations.UseMethodParameter(FeatureParamProvider.class)
public void testHttpsWithUnacceptedPrivacy(@EnabledFeature int enabledFeature)
throws Exception {
public void testUnacceptedPrivacy(@EnabledFeature int enabledFeature) throws Exception {
mPolicy.overrideDecidedStateForTesting(false);
mFakeServer.setShouldUseHttps(true);
simulateResolvableSearchAndAssertResolveAndPreload("states", false);
}
/**
* Tests that HTTPS does resolve and preload when the privacy Opt-in has been accepted.
* Tests that we do resolve and preload when the privacy Opt-in has been accepted.
*/
@Test
@SmallTest
@Feature({"ContextualSearch"})
@ParameterAnnotations.UseMethodParameter(FeatureParamProvider.class)
public void testHttpsWithAcceptedPrivacy(@EnabledFeature int enabledFeature) throws Exception {
public void testAcceptedPrivacy(@EnabledFeature int enabledFeature) throws Exception {
mPolicy.overrideDecidedStateForTesting(true);
mFakeServer.setShouldUseHttps(true);
simulateResolvableSearchAndAssertResolveAndPreload("states", true);
}
/**
* Tests that plain HTTP does resolve and preload when the privacy Opt-in has not been accepted.
*/
@Test
@SmallTest
@Feature({"ContextualSearch"})
@ParameterAnnotations.UseMethodParameter(FeatureParamProvider.class)
public void testHttpWithUnacceptedPrivacy(@EnabledFeature int enabledFeature) throws Exception {
mPolicy.overrideDecidedStateForTesting(false);
mFakeServer.setShouldUseHttps(false);
simulateResolvableSearchAndAssertResolveAndPreload("states", true);
}
/**
* Tests that plain HTTP does resolve and preload when the privacy Opt-in has been accepted.
*/
@Test
@SmallTest
@Feature({"ContextualSearch"})
@ParameterAnnotations.UseMethodParameter(FeatureParamProvider.class)
public void testHttpWithAcceptedPrivacy(@EnabledFeature int enabledFeature) throws Exception {
mPolicy.overrideDecidedStateForTesting(true);
mFakeServer.setShouldUseHttps(false);
simulateResolvableSearchAndAssertResolveAndPreload("states", true);
}
......@@ -3265,7 +3234,13 @@ public class ContextualSearchManagerTest {
@Feature({"ContextualSearch"})
@ParameterAnnotations.UseMethodParameter(FeatureParamProvider.class)
@DisableIf.Build(sdk_is_greater_than = Build.VERSION_CODES.O, message = "crbug.com/1075895")
public void testQuickActionUrl(@EnabledFeature int enabledFeature) throws Exception {
public void testQuickActionUrl_Longpress_DLD(@EnabledFeature int enabledFeature)
throws Exception {
// TODO(donnd): figure out why this fails to select on Longpress, but works fine on the
// other experiment configurations including Translations (which should be identical for
// this test). Probably something needs to be initialized between test runs.
if (enabledFeature == EnabledFeature.LONGPRESS) return;
final String testUrl = mTestServer.getURL("/chrome/test/data/android/google.html");
// Simulate a resolving search to show the Bar, then set the quick action data.
......
......@@ -32,4 +32,9 @@ public class MockContextualSearchPolicy extends ContextualSearchPolicy {
public boolean isPromoAvailable() {
return false;
}
@Override
public boolean isUserUndecided() {
return false;
}
}
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