Commit 49a0a7c1 authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[WebLayer] Set accessibility strings for icon.

This change moves three accessibility strings from chrome:// to components://
so they can be set for the security status icon in the WebLayer URL bar.

Bug: 1025607
Change-Id: I7298a14efbaa663315438c2a1675e0e248cc5ad4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2047025Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741453}
parent f0ea3f46
...@@ -136,7 +136,7 @@ public class StatusViewCoordinator implements View.OnClickListener, UrlTextChang ...@@ -136,7 +136,7 @@ public class StatusViewCoordinator implements View.OnClickListener, UrlTextChang
mMediator.setSecurityIconResource(mToolbarDataProvider.getSecurityIconResource(mIsTablet)); mMediator.setSecurityIconResource(mToolbarDataProvider.getSecurityIconResource(mIsTablet));
mMediator.setSecurityIconTint(mToolbarDataProvider.getSecurityIconColorStateList()); mMediator.setSecurityIconTint(mToolbarDataProvider.getSecurityIconColorStateList());
mMediator.setSecurityIconDescription( mMediator.setSecurityIconDescription(
mToolbarDataProvider.getSecurityIconContentDescription()); mToolbarDataProvider.getSecurityIconContentDescriptionResourceId());
// TODO(ender): drop these during final cleanup round. // TODO(ender): drop these during final cleanup round.
updateVerboseStatusVisibility(); updateVerboseStatusVisibility();
......
...@@ -12,11 +12,11 @@ import androidx.annotation.NonNull; ...@@ -12,11 +12,11 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.omnibox.UrlBarData; import org.chromium.chrome.browser.omnibox.UrlBarData;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.components.omnibox.SecurityStatusIcon;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
/** /**
...@@ -131,21 +131,8 @@ public interface ToolbarDataProvider extends ToolbarCommonPropertiesModel { ...@@ -131,21 +131,8 @@ public interface ToolbarDataProvider extends ToolbarCommonPropertiesModel {
* @return The resource ID of the content description for the security icon. * @return The resource ID of the content description for the security icon.
*/ */
@StringRes @StringRes
default int getSecurityIconContentDescription() { default int getSecurityIconContentDescriptionResourceId() {
switch (getSecurityLevel()) { return SecurityStatusIcon.getSecurityIconContentDescriptionResourceId(getSecurityLevel());
case ConnectionSecurityLevel.NONE:
case ConnectionSecurityLevel.WARNING:
return R.string.accessibility_security_btn_warn;
case ConnectionSecurityLevel.DANGEROUS:
return R.string.accessibility_security_btn_dangerous;
case ConnectionSecurityLevel.SECURE_WITH_POLICY_INSTALLED_CERT:
case ConnectionSecurityLevel.SECURE:
case ConnectionSecurityLevel.EV_SECURE:
return R.string.accessibility_security_btn_secure;
default:
assert false;
}
return 0;
} }
/** /**
......
...@@ -781,7 +781,8 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL ...@@ -781,7 +781,8 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL
mAnimDelegate.showSecurityButton(); mAnimDelegate.showSecurityButton();
} }
int contentDescriptionId = getToolbarDataProvider().getSecurityIconContentDescription(); int contentDescriptionId =
getToolbarDataProvider().getSecurityIconContentDescriptionResourceId();
String contentDescription = getContext().getString(contentDescriptionId); String contentDescription = getContext().getString(contentDescriptionId);
mSecurityButton.setContentDescription(contentDescription); mSecurityButton.setContentDescription(contentDescription);
......
...@@ -3067,15 +3067,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p ...@@ -3067,15 +3067,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_SITE_INFO" desc="Content description for the page icon that gives more site information when clicked. The icon can be a magnifier for search result pages, or other icons representing the page state."> <message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_SITE_INFO" desc="Content description for the page icon that gives more site information when clicked. The icon can be a magnifier for search result pages, or other icons representing the page state.">
Site information Site information
</message> </message>
<message name="IDS_ACCESSIBILITY_SECURITY_BTN_WARN" desc="Content description for the security icon for pages with insecure passive content. The content description also includes the call to action for opening the page info bubble (Site information).">
Your connection to this site is not secure. Site information
</message>
<message name="IDS_ACCESSIBILITY_SECURITY_BTN_SECURE" desc="Content description for the security icon for pages with a valid certificate. The content description also includes the call to action for opening the page info bubble (Site information).">
Connection is secure. Site information
</message>
<message name="IDS_ACCESSIBILITY_SECURITY_BTN_DANGEROUS" desc="Content description for the security icon for dangerous pages. The content description also includes the call to action for opening the page info bubble (Site information).">
This page is dangerous. Site information
</message>
<message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_MIC" desc="Content description for the voice search button."> <message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_MIC" desc="Content description for the voice search button.">
Start voice search Start voice search
</message> </message>
......
...@@ -327,6 +327,15 @@ ...@@ -327,6 +327,15 @@
<message name="IDS_SELECT_ITEMS" desc="Label shown on toolbar asking user to select items from the list."> <message name="IDS_SELECT_ITEMS" desc="Label shown on toolbar asking user to select items from the list.">
Select items Select items
</message> </message>
<message name="IDS_ACCESSIBILITY_SECURITY_BTN_SECURE" desc="Content description for the security icon for pages with a valid certificate. The content description also includes the call to action for opening the page info bubble (Site information).">
Connection is secure. Site information
</message>
<message name="IDS_ACCESSIBILITY_SECURITY_BTN_WARN" desc="Content description for the security icon for pages with insecure passive content. The content description also includes the call to action for opening the page info bubble (Site information).">
Your connection to this site is not secure. Site information
</message>
<message name="IDS_ACCESSIBILITY_SECURITY_BTN_DANGEROUS" desc="Content description for the security icon for dangerous pages. The content description also includes the call to action for opening the page info bubble (Site information).">
This page is dangerous. Site information
</message>
</messages> </messages>
</release> </release>
</grit> </grit>
...@@ -271,6 +271,7 @@ jumbo_static_library("browser") { ...@@ -271,6 +271,7 @@ jumbo_static_library("browser") {
if (is_android) { if (is_android) {
android_resources("java_resources") { android_resources("java_resources") {
resource_dirs = [ "android/java/res" ] resource_dirs = [ "android/java/res" ]
deps = [ "//components/browser_ui/strings/android:browser_ui_strings_grd" ]
custom_package = "org.chromium.components.omnibox" custom_package = "org.chromium.components.omnibox"
} }
......
...@@ -5,11 +5,15 @@ ...@@ -5,11 +5,15 @@
package org.chromium.components.omnibox; package org.chromium.components.omnibox;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
/** Utility class to get security state info for the omnibox. */ /** Utility class to get security state info for the omnibox. */
public class SecurityStatusIcon { public class SecurityStatusIcon {
/**
* @return the id of the resource identifying the icon corresponding to the securityLevel.
*/
@DrawableRes @DrawableRes
public static int getSecurityIconResource(@ConnectionSecurityLevel int securityLevel, public static int getSecurityIconResource(@ConnectionSecurityLevel int securityLevel,
boolean shouldShowDangerTriangleForWarningLevel, boolean isSmallDevice, boolean shouldShowDangerTriangleForWarningLevel, boolean isSmallDevice,
...@@ -34,4 +38,26 @@ public class SecurityStatusIcon { ...@@ -34,4 +38,26 @@ public class SecurityStatusIcon {
} }
return 0; return 0;
} }
/**
* @return The resource ID of the content description for the security icon.
*/
@StringRes
public static int getSecurityIconContentDescriptionResourceId(
@ConnectionSecurityLevel int securityLevel) {
switch (securityLevel) {
case ConnectionSecurityLevel.NONE:
case ConnectionSecurityLevel.WARNING:
return R.string.accessibility_security_btn_warn;
case ConnectionSecurityLevel.DANGEROUS:
return R.string.accessibility_security_btn_dangerous;
case ConnectionSecurityLevel.SECURE_WITH_POLICY_INSTALLED_CERT:
case ConnectionSecurityLevel.SECURE:
case ConnectionSecurityLevel.EV_SECURE:
return R.string.accessibility_security_btn_secure;
default:
assert false;
}
return 0;
}
} }
...@@ -118,9 +118,12 @@ public class UrlBarControllerImpl extends IUrlBarController.Stub { ...@@ -118,9 +118,12 @@ public class UrlBarControllerImpl extends IUrlBarController.Stub {
TypedValue.COMPLEX_UNIT_SP, Math.max(MINIMUM_TEXT_SIZE, mTextSize)); TypedValue.COMPLEX_UNIT_SP, Math.max(MINIMUM_TEXT_SIZE, mTextSize));
mSecurityButton.setImageResource(getSecurityIcon()); mSecurityButton.setImageResource(getSecurityIcon());
mSecurityButton.setContentDescription(getContext().getResources().getString(
SecurityStatusIcon.getSecurityIconContentDescriptionResourceId(
UrlBarControllerImplJni.get().getConnectionSecurityLevel(
mNativeUrlBarController))));
// TODO(crbug.com/1025607): Set content description for accessibility, and a click // TODO(crbug.com/1025607): Set a click listener to show Page Info UI.
// listener.
} }
@DrawableRes @DrawableRes
......
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