Commit 6f401eef authored by tedchoc's avatar tedchoc Committed by Commit bot

Enforce HTTPS URLs to show app banners.

BUG=459773

Review URL: https://codereview.chromium.org/932703006

Cr-Commit-Position: refs/heads/master@{#317116}
parent 0acea6ae
...@@ -140,6 +140,12 @@ public class AppBannerManager extends EmptyTabObserver { ...@@ -140,6 +140,12 @@ public class AppBannerManager extends EmptyTabObserver {
nativeSetTimeDeltaForTesting(days); nativeSetTimeDeltaForTesting(days);
} }
/** Disables the HTTPS scheme requirement for testing. */
@VisibleForTesting
static void disableSecureSchemeCheckForTesting() {
nativeDisableSecureSchemeCheckForTesting();
}
/** Returns whether a BitmapFetcher is actively retrieving an app icon. */ /** Returns whether a BitmapFetcher is actively retrieving an app icon. */
@VisibleForTesting @VisibleForTesting
public boolean isFetcherActiveForTesting() { public boolean isFetcherActiveForTesting() {
...@@ -156,5 +162,6 @@ public class AppBannerManager extends EmptyTabObserver { ...@@ -156,5 +162,6 @@ public class AppBannerManager extends EmptyTabObserver {
// Testing methods. // Testing methods.
private static native void nativeSetTimeDeltaForTesting(int days); private static native void nativeSetTimeDeltaForTesting(int days);
private static native void nativeDisableSecureSchemeCheckForTesting();
private native boolean nativeIsFetcherActive(long nativeAppBannerManager); private native boolean nativeIsFetcherActive(long nativeAppBannerManager);
} }
...@@ -93,6 +93,7 @@ public class AppBannerManagerTest extends ChromeShellTestBase { ...@@ -93,6 +93,7 @@ public class AppBannerManagerTest extends ChromeShellTestBase {
mActivityTab = getActivity().getActiveTab(); mActivityTab = getActivity().getActiveTab();
mInfoBarContainer = mActivityTab.getInfoBarContainer(); mInfoBarContainer = mActivityTab.getInfoBarContainer();
mAppBannerManager = mActivityTab.getAppBannerManagerForTesting(); mAppBannerManager = mActivityTab.getAppBannerManagerForTesting();
AppBannerManager.disableSecureSchemeCheckForTesting();
} }
private boolean waitUntilNoInfoBarsExist() throws Exception { private boolean waitUntilNoInfoBarsExist() throws Exception {
......
...@@ -44,6 +44,7 @@ using base::android::ConvertUTF16ToJavaString; ...@@ -44,6 +44,7 @@ using base::android::ConvertUTF16ToJavaString;
namespace { namespace {
const char kBannerTag[] = "google-play-id"; const char kBannerTag[] = "google-play-id";
base::TimeDelta gTimeDeltaForTesting; base::TimeDelta gTimeDeltaForTesting;
bool gDisableSecureCheckForTesting = false;
} // namespace } // namespace
namespace banners { namespace banners {
...@@ -132,6 +133,11 @@ void AppBannerManager::DidFinishLoad( ...@@ -132,6 +133,11 @@ void AppBannerManager::DidFinishLoad(
return; return;
validated_url_ = validated_url; validated_url_ = validated_url;
// A secure scheme is required to show banners, so exit early if we see the
// URL is invalid.
if (!validated_url_.SchemeIsSecure() && !gDisableSecureCheckForTesting)
return;
// See if the page has a manifest. Using Unretained(this) here is safe as the // See if the page has a manifest. Using Unretained(this) here is safe as the
// lifetime of this object extends beyond the lifetime of the web_contents(), // lifetime of this object extends beyond the lifetime of the web_contents(),
// and when web_contents() is destroyed it will call OnDidGetManifest. // and when web_contents() is destroyed it will call OnDidGetManifest.
...@@ -363,6 +369,10 @@ void SetTimeDeltaForTesting(JNIEnv* env, jclass clazz, jint days) { ...@@ -363,6 +369,10 @@ void SetTimeDeltaForTesting(JNIEnv* env, jclass clazz, jint days) {
gTimeDeltaForTesting = base::TimeDelta::FromDays(days); gTimeDeltaForTesting = base::TimeDelta::FromDays(days);
} }
void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) {
gDisableSecureCheckForTesting = true;
}
// Register native methods // Register native methods
bool RegisterAppBannerManager(JNIEnv* env) { bool RegisterAppBannerManager(JNIEnv* env) {
return RegisterNativesImpl(env); return RegisterNativesImpl(env);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace { namespace {
const char kTestURL[] = "http://www.google.com"; const char kTestURL[] = "https://www.google.com";
const char kTestPackageName[] = "test.package"; const char kTestPackageName[] = "test.package";
base::Time GetReferenceTime() { base::Time GetReferenceTime() {
......
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