Adds image labels option to accessibility settings on all platforms.
This is hidden behind the feature flag. Strings are not finalized yet,
so strings are marked as untranslatable and no screenshots have been
uploaded yet.
Bug: 905419
Change-Id: I223a3a759b5dfd6449155f21a5118d2c4b9656b9
Reviewed-on: https://chromium-review.googlesource.com/c/1394314
Commit-Queue: Katie Dektar <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: Dan Beam <[email protected]>
Reviewed-by: David Tseng <[email protected]>
Cr-Commit-Position: refs/heads/master@{#620614}
diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp
index 4f22917d..97eec90 100644
--- a/chrome/app/settings_strings.grdp
+++ b/chrome/app/settings_strings.grdp
@@ -174,6 +174,12 @@
<message name="IDS_SETTINGS_MORE_FEATURES_LINK_DESCRIPTION" desc="Description for the link about additional accessibility features.">
Enable accessibility features
</message>
+ <message name="IDS_SETTINGS_ACCESSIBLE_IMAGE_LABELS_TITLE" desc="Description for screen reader image labels feature. Text WIP, marking not translatable until strings are finalized" translateable="false">
+ Enable image labels for accessibility
+ </message>
+ <message name="IDS_SETTINGS_ACCESSIBLE_IMAGE_LABELS_SUBTITLE" desc="Subtitle for screen reader image labels feature. Text WIP, marking not translatable until strings are finalized" translateable="false">
+ Enables image labels when a screen reader is running
+ </message>
<if expr="chromeos">
<message name="IDS_SETTINGS_OPTIONS_IN_MENU_LABEL" desc="Label for checkbox which enables showing accessibility options in the system menu.">
Always show accessibility options in the system menu
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 27bdf8f..8058dee 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -85,6 +85,8 @@
sources = [
"about_flags.cc",
"about_flags.h",
+ "accessibility/accessibility_labels_prefs.cc",
+ "accessibility/accessibility_labels_prefs.h",
"accessibility/accessibility_permission_context.cc",
"accessibility/accessibility_permission_context.h",
"accessibility/accessibility_ui.cc",
diff --git a/chrome/browser/accessibility/accessibility_labels_prefs.cc b/chrome/browser/accessibility/accessibility_labels_prefs.cc
new file mode 100644
index 0000000..5cf704f
--- /dev/null
+++ b/chrome/browser/accessibility/accessibility_labels_prefs.cc
@@ -0,0 +1,17 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/accessibility/accessibility_labels_prefs.h"
+
+#include "chrome/common/pref_names.h"
+#include "components/pref_registry/pref_registry_syncable.h"
+
+namespace accessibility_prefs {
+
+void RegisterAccessibilityLabelsProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(prefs::kAccessibilityImageLabelsEnabled, false);
+}
+
+} // namespace accessibility_prefs
diff --git a/chrome/browser/accessibility/accessibility_labels_prefs.h b/chrome/browser/accessibility/accessibility_labels_prefs.h
new file mode 100644
index 0000000..fd7471f
--- /dev/null
+++ b/chrome/browser/accessibility/accessibility_labels_prefs.h
@@ -0,0 +1,20 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_LABELS_PREFS_H_
+#define CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_LABELS_PREFS_H_
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+namespace accessibility_prefs {
+
+// The accessibility labels preference should be registered on a user profile.
+void RegisterAccessibilityLabelsProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry);
+
+} // namespace accessibility_prefs
+
+#endif // CHROME_BROWSER_ACCESSIBILITY_ACCESSIBILITY_LABELS_PREFS_H_
diff --git a/chrome/browser/accessibility/invert_bubble_prefs.cc b/chrome/browser/accessibility/invert_bubble_prefs.cc
index 44d90f0..1fcc049e 100644
--- a/chrome/browser/accessibility/invert_bubble_prefs.cc
+++ b/chrome/browser/accessibility/invert_bubble_prefs.cc
@@ -7,6 +7,10 @@
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
+namespace accessibility_prefs {
+
void RegisterInvertBubbleUserPrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kInvertNotificationShown, false);
}
+
+} // namespace accessibility_prefs
diff --git a/chrome/browser/accessibility/invert_bubble_prefs.h b/chrome/browser/accessibility/invert_bubble_prefs.h
index 0513cf1..3969a4f 100644
--- a/chrome/browser/accessibility/invert_bubble_prefs.h
+++ b/chrome/browser/accessibility/invert_bubble_prefs.h
@@ -9,6 +9,10 @@
class PrefRegistrySyncable;
}
+namespace accessibility_prefs {
+
void RegisterInvertBubbleUserPrefs(user_prefs::PrefRegistrySyncable* registry);
+} // namespace accessibility_prefs
+
#endif // CHROME_BROWSER_ACCESSIBILITY_INVERT_BUBBLE_PREFS_H_
diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc
index 8b64091..ad1233d 100644
--- a/chrome/browser/extensions/api/settings_private/prefs_util.cc
+++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc
@@ -284,6 +284,10 @@
(*s_whitelist)[browsing_data::prefs::kLastClearBrowsingDataTab] =
settings_api::PrefType::PREF_TYPE_NUMBER;
+ // Accessibility.
+ (*s_whitelist)[::prefs::kAccessibilityImageLabelsEnabled] =
+ settings_api::PrefType::PREF_TYPE_BOOLEAN;
+
#if defined(OS_CHROMEOS)
// Accounts / Users / People.
(*s_whitelist)[chromeos::kAccountsPrefAllowGuest] =
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 58dfb84..5d57bb1 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -10,6 +10,7 @@
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "chrome/browser/about_flags.h"
+#include "chrome/browser/accessibility/accessibility_labels_prefs.h"
#include "chrome/browser/accessibility/accessibility_ui.h"
#include "chrome/browser/accessibility/invert_bubble_prefs.h"
#include "chrome/browser/browser_process_impl.h"
@@ -558,6 +559,7 @@
TRACE_EVENT0("browser", "chrome::RegisterProfilePrefs");
SCOPED_UMA_HISTOGRAM_TIMER("Settings.RegisterProfilePrefsTime");
// User prefs. Please keep this list alphabetized.
+ accessibility_prefs::RegisterAccessibilityLabelsProfilePrefs(registry);
AccessibilityUIMessageHandler::RegisterProfilePrefs(registry);
autofill::prefs::RegisterProfilePrefs(registry);
browsing_data::prefs::RegisterBrowserUserPrefs(registry);
@@ -761,8 +763,8 @@
#endif
#if defined(TOOLKIT_VIEWS)
+ accessibility_prefs::RegisterInvertBubbleUserPrefs(registry);
RegisterBrowserViewProfilePrefs(registry);
- RegisterInvertBubbleUserPrefs(registry);
#endif
#if defined(OS_CHROMEOS)
diff --git a/chrome/browser/resources/settings/a11y_page/a11y_page.html b/chrome/browser/resources/settings/a11y_page/a11y_page.html
index d1f72326..5065cd8 100644
--- a/chrome/browser/resources/settings/a11y_page/a11y_page.html
+++ b/chrome/browser/resources/settings/a11y_page/a11y_page.html
@@ -16,6 +16,13 @@
<dom-module id="settings-a11y-page">
<template>
<style include="settings-shared"></style>
+ <!-- TODO(katie): Remove hidden calculation before launch. -->
+ <settings-toggle-button
+ hidden$="[[!showExperimentalAccessibilityLabels_]]"
+ pref="{{prefs.settings.a11y.enable_accessibility_image_labels}}"
+ label="$i18n{accessibleImageLabelsTitle}"
+ sub-label="$i18n{accessibleImageLabelsSubtitle}">
+ </settings-toggle-button>
<if expr="chromeos">
<settings-animated-pages id="pages" current-route="{{currentRoute}}"
section="a11y" focus-config="[[focusConfig_]]">
diff --git a/chrome/browser/resources/settings/a11y_page/a11y_page.js b/chrome/browser/resources/settings/a11y_page/a11y_page.js
index 7c1a912..53234581 100644
--- a/chrome/browser/resources/settings/a11y_page/a11y_page.js
+++ b/chrome/browser/resources/settings/a11y_page/a11y_page.js
@@ -43,6 +43,17 @@
},
},
+ /**
+ * Whether to show experimental accessibility label features.
+ * @private {boolean}
+ */
+ showExperimentalAccessibilityLabels_: {
+ type: Boolean,
+ value: function() {
+ return loadTimeData.getBoolean('showExperimentalA11yLabels');
+ },
+ },
+
// <if expr="chromeos">
/**
* Whether to show experimental accessibility features.
diff --git a/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
index 0eadddc..31aae81f 100644
--- a/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
+++ b/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
@@ -168,6 +168,9 @@
static constexpr LocalizedString kLocalizedStrings[] = {
{"a11yPageTitle", IDS_SETTINGS_ACCESSIBILITY},
{"a11yWebStore", IDS_SETTINGS_ACCESSIBILITY_WEB_STORE},
+ {"accessibleImageLabelsTitle", IDS_SETTINGS_ACCESSIBLE_IMAGE_LABELS_TITLE},
+ {"accessibleImageLabelsSubtitle",
+ IDS_SETTINGS_ACCESSIBLE_IMAGE_LABELS_SUBTITLE},
{"moreFeaturesLink", IDS_SETTINGS_MORE_FEATURES_LINK},
{"moreFeaturesLinkDescription",
IDS_SETTINGS_MORE_FEATURES_LINK_DESCRIPTION},
@@ -314,24 +317,26 @@
AddLocalizedStringsBulk(html_source, kLocalizedStrings,
base::size(kLocalizedStrings));
+ base::CommandLine& cmd = *base::CommandLine::ForCurrentProcess();
+ html_source->AddBoolean(
+ "showExperimentalA11yLabels",
+ cmd.HasSwitch(::switches::kEnableExperimentalAccessibilityLabels));
+
#if defined(OS_CHROMEOS)
html_source->AddString("a11yLearnMoreUrl",
chrome::kChromeAccessibilityHelpURL);
html_source->AddBoolean(
"showExperimentalA11yFeatures",
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kEnableExperimentalAccessibilityFeatures));
+ cmd.HasSwitch(::switches::kEnableExperimentalAccessibilityFeatures));
html_source->AddBoolean(
"showExperimentalAccessibilityAutoclick",
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kEnableExperimentalAccessibilityAutoclick));
+ cmd.HasSwitch(::switches::kEnableExperimentalAccessibilityAutoclick));
html_source->AddBoolean(
"showExperimentalAccessibilitySwitchAccess",
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kEnableExperimentalAccessibilitySwitchAccess));
+ cmd.HasSwitch(::switches::kEnableExperimentalAccessibilitySwitchAccess));
html_source->AddBoolean("dockedMagnifierFeatureEnabled",
ash::features::IsDockedMagnifierEnabled());
@@ -794,17 +799,15 @@
IDS_SETTINGS_DISPLAY_TOUCH_CALIBRATION_TEXT}};
AddLocalizedStringsBulk(html_source, kDisplayStrings,
base::size(kDisplayStrings));
+ base::CommandLine& cmd = *base::CommandLine::ForCurrentProcess();
html_source->AddBoolean("unifiedDesktopAvailable",
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kEnableUnifiedDesktop));
+ cmd.HasSwitch(::switches::kEnableUnifiedDesktop));
html_source->AddBoolean("multiMirroringAvailable",
- !base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kDisableMultiMirroring));
+ !cmd.HasSwitch(::switches::kDisableMultiMirroring));
html_source->AddBoolean(
"enableTouchCalibrationSetting",
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kEnableTouchCalibrationSetting));
+ cmd.HasSwitch(chromeos::switches::kEnableTouchCalibrationSetting));
html_source->AddBoolean("hasExternalTouchDevice",
display::HasExternalTouchscreenDevice());
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 09168e9..c907fea 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1016,6 +1016,10 @@
const char kShowInternalAccessibilityTree[] =
"accessibility.show_internal_accessibility_tree";
+// Additional features for image labels for accessibility.
+const char kAccessibilityImageLabelsEnabled[] =
+ "settings.a11y.enable_accessibility_image_labels";
+
#if defined(OS_MACOSX)
// Boolean that indicates whether the application should show the info bar
// asking the user to set up automatic updates when Keystone promotion is
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index d67fac0..98be27a 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -168,6 +168,7 @@
extern const char kContextualSearchEnabledValue[];
#endif // defined(OS_ANDROID)
extern const char kShowInternalAccessibilityTree[];
+extern const char kAccessibilityImageLabelsEnabled[];
#if defined(OS_MACOSX)
extern const char kConfirmToQuitEnabled[];
extern const char kShowFullscreenToolbar[];