Commit ffa498cf authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

[ExpandablePaymentHandler] Improve Security Icon

Before change:
* Security icon is not updated on new navigation until visible security
state has changed.
* if Connection Security Level is NONE, set an omnibox_info icon
* if Connection Security Level is WARNING, set omnibox_info icon

After change:
* Security icon is cleared once PH page starts new navigation.
* if Connection Security Level is NONE and the device has a small
screen, set an empty icon
* if Connection Security Level is WARNING, whether to show a
"not secure" icon or an "info" icon depends on
SecurityStateModel.shouldShowDangerTriangleForWarningLevel().

Change:
Remove the custom Security Level-Icon mapping logic; replace it with
SecurityStatusIcon.getSecurityIconResource() which is used by the
browser toolbar.

Bug: 1052133

Change-Id: I5347e1040cd2ceae99192977dc41e2d089a4e27e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2058910Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742839}
parent 9c98fa88
...@@ -12,6 +12,7 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageUtils; ...@@ -12,6 +12,7 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
import org.chromium.chrome.browser.page_info.PageInfoController; import org.chromium.chrome.browser.page_info.PageInfoController;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor; import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import org.chromium.url.URI; import org.chromium.url.URI;
...@@ -66,8 +67,9 @@ public class PaymentHandlerToolbarCoordinator { ...@@ -66,8 +67,9 @@ public class PaymentHandlerToolbarCoordinator {
ConnectionSecurityLevel.NONE) ConnectionSecurityLevel.NONE)
.with(PaymentHandlerToolbarProperties.URL, url) .with(PaymentHandlerToolbarProperties.URL, url)
.build(); .build();
boolean isSmallDevice = !DeviceFormFactor.isNonMultiDisplayContextOnTablet(context);
PaymentHandlerToolbarMediator mediator = PaymentHandlerToolbarMediator mediator =
new PaymentHandlerToolbarMediator(model, webContents, observer); new PaymentHandlerToolbarMediator(model, webContents, observer, isSmallDevice);
webContents.addObserver(mediator); webContents.addObserver(mediator);
PropertyModelChangeProcessor changeProcessor = PropertyModelChangeProcessor.create( PropertyModelChangeProcessor changeProcessor = PropertyModelChangeProcessor.create(
model, mToolbarView, PaymentHandlerToolbarViewBinder::bind); model, mToolbarView, PaymentHandlerToolbarViewBinder::bind);
......
...@@ -8,9 +8,9 @@ import android.os.Handler; ...@@ -8,9 +8,9 @@ import android.os.Handler;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.payments.handler.toolbar.PaymentHandlerToolbarCoordinator.PaymentHandlerToolbarObserver; import org.chromium.chrome.browser.payments.handler.toolbar.PaymentHandlerToolbarCoordinator.PaymentHandlerToolbarObserver;
import org.chromium.chrome.browser.ssl.SecurityStateModel; import org.chromium.chrome.browser.ssl.SecurityStateModel;
import org.chromium.components.omnibox.SecurityStatusIcon;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.content_public.browser.NavigationHandle; import org.chromium.content_public.browser.NavigationHandle;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
...@@ -41,6 +41,7 @@ import java.net.URISyntaxException; ...@@ -41,6 +41,7 @@ import java.net.URISyntaxException;
private Handler mHideProgressBarHandler; private Handler mHideProgressBarHandler;
/** Postfixed with "Ref" to distinguish from mWebContent in WebContentsObserver. */ /** Postfixed with "Ref" to distinguish from mWebContent in WebContentsObserver. */
private final WebContents mWebContentsRef; private final WebContents mWebContentsRef;
private final boolean mIsSmallDevice;
/** /**
* Build a new mediator that handle events from outside the payment handler toolbar component. * Build a new mediator that handle events from outside the payment handler toolbar component.
...@@ -48,10 +49,12 @@ import java.net.URISyntaxException; ...@@ -48,10 +49,12 @@ import java.net.URISyntaxException;
* the payment handler toolbar component. * the payment handler toolbar component.
* @param webContents The web-contents that loads the payment app. * @param webContents The web-contents that loads the payment app.
* @param observer The observer of this toolbar. * @param observer The observer of this toolbar.
* @param isSmallDevice Whether the device screen is considered small.
*/ */
/* package */ PaymentHandlerToolbarMediator( /* package */ PaymentHandlerToolbarMediator(PropertyModel model, WebContents webContents,
PropertyModel model, WebContents webContents, PaymentHandlerToolbarObserver observer) { PaymentHandlerToolbarObserver observer, boolean isSmallDevice) {
super(webContents); super(webContents);
mIsSmallDevice = isSmallDevice;
mWebContentsRef = webContents; mWebContentsRef = webContents;
mModel = model; mModel = model;
mObserver = observer; mObserver = observer;
...@@ -91,6 +94,8 @@ import java.net.URISyntaxException; ...@@ -91,6 +94,8 @@ import java.net.URISyntaxException;
Log.e(TAG, "Failed to instantiate a URI with the url \"%s\".", url); Log.e(TAG, "Failed to instantiate a URI with the url \"%s\".", url);
mObserver.onToolbarError(); mObserver.onToolbarError();
} }
mModel.set(PaymentHandlerToolbarProperties.SECURITY_ICON,
getSecurityIconResource(ConnectionSecurityLevel.NONE));
} }
@Override @Override
...@@ -114,21 +119,10 @@ import java.net.URISyntaxException; ...@@ -114,21 +119,10 @@ import java.net.URISyntaxException;
} }
@DrawableRes @DrawableRes
private static int getSecurityIconResource(@ConnectionSecurityLevel int securityLevel) { private int getSecurityIconResource(@ConnectionSecurityLevel int securityLevel) {
switch (securityLevel) { return SecurityStatusIcon.getSecurityIconResource(securityLevel,
case ConnectionSecurityLevel.NONE: SecurityStateModel.shouldShowDangerTriangleForWarningLevel(), mIsSmallDevice,
case ConnectionSecurityLevel.WARNING: /*skipIconForNeutralState=*/true);
return R.drawable.omnibox_info;
case ConnectionSecurityLevel.DANGEROUS:
return R.drawable.omnibox_not_secure_warning;
case ConnectionSecurityLevel.SECURE_WITH_POLICY_INSTALLED_CERT:
case ConnectionSecurityLevel.SECURE:
case ConnectionSecurityLevel.EV_SECURE:
return R.drawable.omnibox_https_valid;
default:
assert false;
}
return 0;
} }
@Override @Override
......
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