Commit 00ce430f authored by Livvie Lin's avatar Livvie Lin Committed by Commit Bot

Revert "[Desktop/Android] Prevent security icon downgrade to triangle on URL load"

This reverts commit b5a5de57.

Reason for revert: The issue addressed by this CL should be addressed with a
different approach.

Original change's description:
> [Desktop/Android] Prevent security icon downgrade to triangle on URL load
>
> Bug: 1031532
> Change-Id: I3bb24e86c146ee86f5eb6d4795b0b5397542d100
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1959412
> Reviewed-by: Tommy Li <tommycli@chromium.org>
> Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
> Commit-Queue: Livvie Lin <livvielin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#723472}

TBR=mthiesse@chromium.org,tommycli@chromium.org,livvielin@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1031532
Change-Id: I416e7a7fd718437747679edafd2b5eb165fe2cec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1962601
Commit-Queue: Livvie Lin <livvielin@chromium.org>
Reviewed-by: default avatarLivvie Lin <livvielin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#724073}
parent 67b65ff2
......@@ -38,14 +38,12 @@ public class SecurityStateModel {
/**
* Returns whether to use a danger icon instead of an info icon in the URL bar.
*
* @param webContents The web contents to check.
* @param securityLevel The ConnectionSecurityLevel of the page.
* @param url The URL to check.
* @return Whether to downgrade the info icon to a danger triangle.
*/
public static boolean shouldDowngradeNeutralStylingForWebContents(
WebContents webContents, String url) {
return SecurityStateModelJni.get().shouldDowngradeNeutralStylingForWebContents(
webContents, url);
public static boolean shouldDowngradeNeutralStyling(int securityLevel, String url) {
return SecurityStateModelJni.get().shouldDowngradeNeutralStyling(securityLevel, url);
}
private SecurityStateModel() {}
......@@ -54,6 +52,6 @@ public class SecurityStateModel {
interface Natives {
int getSecurityLevelForWebContents(WebContents webContents);
boolean isSchemeCryptographic(String url);
boolean shouldDowngradeNeutralStylingForWebContents(WebContents webContents, String url);
boolean shouldDowngradeNeutralStyling(int securityLevel, String url);
}
}
......@@ -412,8 +412,7 @@ public class LocationBarModel implements ToolbarDataProvider, ToolbarCommonPrope
// is NONE, but the security indicator should be shown on all devices.
if (mNativeLocationBarModelAndroid != 0
&& SecurityStateModel.isSchemeCryptographic(url)) {
return SecurityStateModel.shouldDowngradeNeutralStylingForWebContents(
getActiveWebContents(), url)
return SecurityStateModel.shouldDowngradeNeutralStyling(securityLevel, url)
? R.drawable.omnibox_not_secure_warning
: R.drawable.omnibox_info;
}
......@@ -426,8 +425,7 @@ public class LocationBarModel implements ToolbarDataProvider, ToolbarCommonPrope
if (mNativeLocationBarModelAndroid == 0) {
return R.drawable.omnibox_info;
}
if (SecurityStateModel.shouldDowngradeNeutralStylingForWebContents(
getActiveWebContents(), url)) {
if (SecurityStateModel.shouldDowngradeNeutralStyling(securityLevel, url)) {
return R.drawable.omnibox_not_secure_warning;
}
return R.drawable.omnibox_info;
......
......@@ -30,7 +30,6 @@ import org.chromium.chrome.browser.omnibox.LocationBarLayout;
import org.chromium.chrome.browser.ssl.SecurityStateModel;
import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.content_public.browser.WebContents;
/**
* Unit tests for {@link LocationBarLayout} class.
......@@ -77,8 +76,7 @@ public final class ToolbarSecurityIconTest {
}
@Implementation
public static boolean shouldDowngradeNeutralStylingForWebContents(
WebContents webContents, String url) {
public static boolean shouldDowngradeNeutralStyling(int securityLevel, String url) {
return sShouldDowngrade;
}
......
......@@ -38,25 +38,13 @@ jboolean JNI_SecurityStateModel_IsSchemeCryptographic(
}
// static
jboolean JNI_SecurityStateModel_ShouldDowngradeNeutralStylingForWebContents(
jboolean JNI_SecurityStateModel_ShouldDowngradeNeutralStyling(
JNIEnv* env,
const JavaParamRef<jobject>& jweb_contents,
jint jsecurity_level,
const JavaParamRef<jstring>& jurl) {
content::WebContents* web_contents =
content::WebContents::FromJavaWebContents(jweb_contents);
DCHECK(web_contents);
SecurityStateTabHelper::CreateForWebContents(web_contents);
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents);
DCHECK(helper);
// Icon shouldn't be downgraded while the URL is loading.
if (!helper->GetVisibleSecurityState()->connection_info_initialized) {
return false;
}
GURL url(ConvertJavaStringToUTF16(env, jurl));
auto security_level =
static_cast<security_state::SecurityLevel>(jsecurity_level);
return security_state::ShouldDowngradeNeutralStyling(
helper->GetSecurityLevel(), url,
base::BindRepeating(&content::IsOriginSecure));
security_level, url, base::BindRepeating(&content::IsOriginSecure));
}
......@@ -188,15 +188,11 @@ const gfx::VectorIcon& LocationBarModelImpl::GetVectorIcon() const {
GURL url = GetURL();
security_state::SecurityLevel security_level = GetSecurityLevel();
std::unique_ptr<security_state::VisibleSecurityState> visible_security_state =
delegate_->GetVisibleSecurityState();
switch (security_level) {
case security_state::NONE:
// Show a danger triangle icon on HTTPS pages with passive mixed content
// when kMarkHttpAsParameterDangerWarning is enabled. Only downgrade in
// cases where the URL has completed loading.
if (visible_security_state->connection_info_initialized &&
security_state::ShouldDowngradeNeutralStyling(
// when kMarkHttpAsParameterDangerWarning is enabled.
if (security_state::ShouldDowngradeNeutralStyling(
security_level, url,
base::BindRepeating(&content::IsOriginSecure))) {
return omnibox::kNotSecureWarningIcon;
......
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