Commit 4eb08e30 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[WebLayer] Fix app name in site settings warning strings

The strings telling users to turn on Android system settings had
"Chrome" hardcoded in them. This was incorrect for WebLayer, as well as
Chromium and non-stable Chrome versions.

Skip-Translation-Screenshots-Check: True
Bug: 1063433
Change-Id: I267b0b30cca0cca5074bceb981157e56ce78ccf6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2284354
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785810}
parent bc353a6f
......@@ -177,4 +177,9 @@ public class ChromeSiteSettingsClient implements SiteSettingsClient {
public String getChannelIdForOrigin(String origin) {
return SiteChannelsManager.getInstance().getChannelIdForOrigin(origin);
}
@Override
public String getAppName() {
return mContext.getString(R.string.app_name);
}
}
......@@ -1064,8 +1064,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
// Show the link to system settings since permission is disabled.
ChromeBasePreference osWarning = new ChromeBasePreference(getStyledContext(), null);
ChromeBasePreference osWarningExtra = new ChromeBasePreference(getStyledContext(), null);
mCategory.configurePermissionIsOffPreferences(
osWarning, osWarningExtra, getActivity(), true);
mCategory.configurePermissionIsOffPreferences(osWarning, osWarningExtra, getActivity(),
true, getSiteSettingsClient().getAppName());
if (osWarning.getTitle() != null) {
osWarning.setKey(SingleWebsiteSettings.PREF_OS_PERMISSIONS_WARNING);
screen.addPreference(osWarning);
......
......@@ -660,8 +660,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
} else {
Preference osWarning = findPreference(PREF_OS_PERMISSIONS_WARNING);
Preference osWarningExtra = findPreference(PREF_OS_PERMISSIONS_WARNING_EXTRA);
categoryWithWarning.configurePermissionIsOffPreferences(
osWarning, osWarningExtra, getActivity(), false);
categoryWithWarning.configurePermissionIsOffPreferences(osWarning, osWarningExtra,
getActivity(), false, getSiteSettingsClient().getAppName());
if (osWarning.getTitle() == null) {
preferenceScreen.removePreference(osWarning);
} else if (osWarningExtra.getTitle() == null) {
......
......@@ -354,12 +354,14 @@ public class SiteSettingsCategory {
* @param activity The current activity.
* @param specificCategory Whether the warnings refer to a single category or is an aggregate
* for many permissions.
* @param appName The name of the app to use in warning strings.
*/
public void configurePermissionIsOffPreferences(Preference osWarning, Preference osWarningExtra,
Activity activity, boolean specificCategory) {
Activity activity, boolean specificCategory, String appName) {
Intent perAppIntent = getIntentToEnableOsPerAppPermission(activity);
Intent globalIntent = getIntentToEnableOsGlobalPermission(activity);
String perAppMessage = getMessageForEnablingOsPerAppPermission(activity, !specificCategory);
String perAppMessage =
getMessageForEnablingOsPerAppPermission(activity, !specificCategory, appName);
String globalMessage = getMessageForEnablingOsGlobalPermission(activity);
String unsupportedMessage = getMessageIfNotSupported(activity);
......@@ -491,7 +493,8 @@ public class SiteSettingsCategory {
* Returns the message to display when per-app permission is blocked.
* @param plural Whether it applies to one per-app permission or multiple.
*/
protected String getMessageForEnablingOsPerAppPermission(Activity activity, boolean plural) {
protected String getMessageForEnablingOsPerAppPermission(
Activity activity, boolean plural, String appName) {
@ContentSettingsType
int type = this.getContentSettingsType();
int permission_string = R.string.android_permission_off;
......@@ -507,7 +510,7 @@ public class SiteSettingsCategory {
permission_string = R.string.android_notifications_permission_off;
}
return activity.getResources().getString(
plural ? R.string.android_permission_off_plural : permission_string);
plural ? R.string.android_permission_off_plural : permission_string, appName);
}
/**
......
......@@ -71,4 +71,9 @@ public interface SiteSettingsClient {
*/
// TODO(crbug.com/1069895): Remove this once WebLayer supports notifications.
String getChannelIdForOrigin(String origin);
/**
* @return The name of the app the settings are associated with.
*/
String getAppName();
}
......@@ -121,10 +121,10 @@
Managed by app
</message>
<message name="IDS_ANDROID_PERMISSION_OFF" desc="Text at the top of the Website list, explaining to the user that a permission, such as the location service, is turned off. Contains a link to the settings menu to change it.">
Turn on permission for Chrome in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
Turn on permission for <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message>
<message name="IDS_ANDROID_PERMISSION_OFF_PLURAL" desc="Text at the top of the Website list, explaining to the user that multiple permissions, such as the location service, are turned off. Contains a link to the settings menu to change it.">
Turn on permissions for Chrome in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
Turn on permissions for <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message>
<message name="IDS_WEBSITE_SETTINGS_EMBEDDED_ON" desc="String used to indicate the embedder origin of a site">
Embedded on <ph name="WEBSITE_URL">%1$s<ex>google.com</ex></ph>
......@@ -252,7 +252,7 @@
Block sites from creating a 3D map of your surroundings or tracking camera position
</message>
<message name="IDS_ANDROID_AR_CAMERA_PERMISSION_OFF" desc="The message to show when the camera permission needs to be turned on in Android settings in order to use Augmented Reality.">
To let Chrome use AR, also turn on camera in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
To let <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> use AR, also turn on camera in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message>
<!-- Automatic downloads -->
......@@ -294,7 +294,7 @@
Access your camera
</message>
<message name="IDS_ANDROID_CAMERA_PERMISSION_OFF" desc="The message to show when the camera permission needs to be turned on not just in Chrome, but also in Android settings.">
To let Chrome access your camera, also turn on camera in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
To let <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> access your camera, also turn on camera in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message>
<!-- Clipboard -->
......@@ -372,7 +372,7 @@
Location access is off for this device. Turn it on in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message>
<message name="IDS_ANDROID_LOCATION_PERMISSION_OFF" desc="The message to show when the location permission needs to be turned on not just in Chrome, but also in Android settings.">
To let Chrome access your location, also turn on location in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
To let <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> access your location, also turn on location in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message>
<!-- Microphone -->
......@@ -384,7 +384,7 @@
Ask first before allowing sites to use your microphone (recommended)
</message>
<message name="IDS_ANDROID_MICROPHONE_PERMISSION_OFF" desc="The message to show when the microphone permission needs to be turned on not just in Chrome, but also in Android settings.">
To let Chrome access your microphone, also turn on microphone in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
To let <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> access your microphone, also turn on microphone in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message>
<!-- Motion/Light sensors -->
......@@ -432,7 +432,7 @@
Managed by <ph name="APP_NAME">%1$s<ex>Notification App Name</ex></ph>
</message>
<message name="IDS_ANDROID_NOTIFICATIONS_PERMISSION_OFF" desc="The message to show when the notifications permission needs to be turned on not just in Chrome, but also in Android settings.">
To let Chrome send you notifications, also turn on notifications in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
To let <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> send you notifications, also turn on notifications in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Android Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
</message>
<message name="IDS_WEBSITE_NOTIFICATION_SETTINGS" desc="Accessibility string for the notification settings">
Open notification settings
......
......@@ -86,6 +86,11 @@ public class WebLayerSiteSettingsClient
return null;
}
@Override
public String getAppName() {
return WebLayerImpl.getClientApplicationName();
}
// ManagedPrefrenceDelegate implementation:
// A no-op because WebLayer doesn't support managed preferences.
......
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