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 { ...@@ -38,14 +38,12 @@ public class SecurityStateModel {
/** /**
* Returns whether to use a danger icon instead of an info icon in the URL bar. * 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. * @param url The URL to check.
* @return Whether to downgrade the info icon to a danger triangle. * @return Whether to downgrade the info icon to a danger triangle.
*/ */
public static boolean shouldDowngradeNeutralStylingForWebContents( public static boolean shouldDowngradeNeutralStyling(int securityLevel, String url) {
WebContents webContents, String url) { return SecurityStateModelJni.get().shouldDowngradeNeutralStyling(securityLevel, url);
return SecurityStateModelJni.get().shouldDowngradeNeutralStylingForWebContents(
webContents, url);
} }
private SecurityStateModel() {} private SecurityStateModel() {}
...@@ -54,6 +52,6 @@ public class SecurityStateModel { ...@@ -54,6 +52,6 @@ public class SecurityStateModel {
interface Natives { interface Natives {
int getSecurityLevelForWebContents(WebContents webContents); int getSecurityLevelForWebContents(WebContents webContents);
boolean isSchemeCryptographic(String url); 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 ...@@ -412,8 +412,7 @@ public class LocationBarModel implements ToolbarDataProvider, ToolbarCommonPrope
// is NONE, but the security indicator should be shown on all devices. // is NONE, but the security indicator should be shown on all devices.
if (mNativeLocationBarModelAndroid != 0 if (mNativeLocationBarModelAndroid != 0
&& SecurityStateModel.isSchemeCryptographic(url)) { && SecurityStateModel.isSchemeCryptographic(url)) {
return SecurityStateModel.shouldDowngradeNeutralStylingForWebContents( return SecurityStateModel.shouldDowngradeNeutralStyling(securityLevel, url)
getActiveWebContents(), url)
? R.drawable.omnibox_not_secure_warning ? R.drawable.omnibox_not_secure_warning
: R.drawable.omnibox_info; : R.drawable.omnibox_info;
} }
...@@ -426,8 +425,7 @@ public class LocationBarModel implements ToolbarDataProvider, ToolbarCommonPrope ...@@ -426,8 +425,7 @@ public class LocationBarModel implements ToolbarDataProvider, ToolbarCommonPrope
if (mNativeLocationBarModelAndroid == 0) { if (mNativeLocationBarModelAndroid == 0) {
return R.drawable.omnibox_info; return R.drawable.omnibox_info;
} }
if (SecurityStateModel.shouldDowngradeNeutralStylingForWebContents( if (SecurityStateModel.shouldDowngradeNeutralStyling(securityLevel, url)) {
getActiveWebContents(), url)) {
return R.drawable.omnibox_not_secure_warning; return R.drawable.omnibox_not_secure_warning;
} }
return R.drawable.omnibox_info; return R.drawable.omnibox_info;
......
...@@ -30,7 +30,6 @@ import org.chromium.chrome.browser.omnibox.LocationBarLayout; ...@@ -30,7 +30,6 @@ import org.chromium.chrome.browser.omnibox.LocationBarLayout;
import org.chromium.chrome.browser.ssl.SecurityStateModel; import org.chromium.chrome.browser.ssl.SecurityStateModel;
import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.content_public.browser.WebContents;
/** /**
* Unit tests for {@link LocationBarLayout} class. * Unit tests for {@link LocationBarLayout} class.
...@@ -77,8 +76,7 @@ public final class ToolbarSecurityIconTest { ...@@ -77,8 +76,7 @@ public final class ToolbarSecurityIconTest {
} }
@Implementation @Implementation
public static boolean shouldDowngradeNeutralStylingForWebContents( public static boolean shouldDowngradeNeutralStyling(int securityLevel, String url) {
WebContents webContents, String url) {
return sShouldDowngrade; return sShouldDowngrade;
} }
......
...@@ -38,25 +38,13 @@ jboolean JNI_SecurityStateModel_IsSchemeCryptographic( ...@@ -38,25 +38,13 @@ jboolean JNI_SecurityStateModel_IsSchemeCryptographic(
} }
// static // static
jboolean JNI_SecurityStateModel_ShouldDowngradeNeutralStylingForWebContents( jboolean JNI_SecurityStateModel_ShouldDowngradeNeutralStyling(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& jweb_contents, jint jsecurity_level,
const JavaParamRef<jstring>& jurl) { 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)); GURL url(ConvertJavaStringToUTF16(env, jurl));
auto security_level =
static_cast<security_state::SecurityLevel>(jsecurity_level);
return security_state::ShouldDowngradeNeutralStyling( return security_state::ShouldDowngradeNeutralStyling(
helper->GetSecurityLevel(), url, security_level, url, base::BindRepeating(&content::IsOriginSecure));
base::BindRepeating(&content::IsOriginSecure));
} }
...@@ -188,15 +188,11 @@ const gfx::VectorIcon& LocationBarModelImpl::GetVectorIcon() const { ...@@ -188,15 +188,11 @@ const gfx::VectorIcon& LocationBarModelImpl::GetVectorIcon() const {
GURL url = GetURL(); GURL url = GetURL();
security_state::SecurityLevel security_level = GetSecurityLevel(); security_state::SecurityLevel security_level = GetSecurityLevel();
std::unique_ptr<security_state::VisibleSecurityState> visible_security_state =
delegate_->GetVisibleSecurityState();
switch (security_level) { switch (security_level) {
case security_state::NONE: case security_state::NONE:
// Show a danger triangle icon on HTTPS pages with passive mixed content // Show a danger triangle icon on HTTPS pages with passive mixed content
// when kMarkHttpAsParameterDangerWarning is enabled. Only downgrade in // when kMarkHttpAsParameterDangerWarning is enabled.
// cases where the URL has completed loading. if (security_state::ShouldDowngradeNeutralStyling(
if (visible_security_state->connection_info_initialized &&
security_state::ShouldDowngradeNeutralStyling(
security_level, url, security_level, url,
base::BindRepeating(&content::IsOriginSecure))) { base::BindRepeating(&content::IsOriginSecure))) {
return omnibox::kNotSecureWarningIcon; 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