Skip to content

Commit

Permalink
lacros - enable accessibilityFeatures in lacros
Browse files Browse the repository at this point in the history
For extension-controlled prefs where the underlying pref is stored in
ash, this change adds hooks for ChromeSetting get/set/clear.
Specifically this adds support for all prefs in accessibilityFeatures.

Lacros computes the expected value of all lacros extensions as normal
and stores the result in a new "container" pref that lives in Lacros,
in the EXTENSION_STORE prefstore. The computed value is then sent to Ash
where it is stored in the STANDALONE_BROWSER_STORE prefstore.

The Lacros version of the pref is stored under a new "container" pref
value. This is not strictly necessary, though in at least one case
(focusHighlight) the pref actually exists in both Lacros and Ash,
but is only extension controlled in Ash. It also allows us to keep most
of the existing extension-controlled-pref logic as-is and simply transfer
the value to Ash.

Observers will be implemented in a future change. Additional sync
behavior (i.e. sending the value of the pref on startup) will also be
implemented in a future change.

Bug: 1218145
Change-Id: Ib643de37f7bb4b9e540623fea63b80d177f59a9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3136914
Commit-Queue: Ian Helmke <helmke@google.com>
Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1001215}
  • Loading branch information
Ian Helmke authored and Chromium LUCI CQ committed May 9, 2022
1 parent 756501a commit c4a4e45
Show file tree
Hide file tree
Showing 22 changed files with 928 additions and 93 deletions.
20 changes: 20 additions & 0 deletions chrome/browser/chromeos/extensions/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import("//build/config/chromeos/ui_mode.gni")
import("//extensions/buildflags/buildflags.gni")

assert(enable_extensions)
assert(is_chromeos)

source_set("constants") {
sources = [
"controlled_pref_mapping.cc",
"controlled_pref_mapping.h",
]
deps = [
"//base",
"//build:chromeos_buildflags",
"//chrome/common:constants",
]
if (is_chromeos_ash) {
deps += [ "//ash/constants" ]
}
}
81 changes: 81 additions & 0 deletions chrome/browser/chromeos/extensions/controlled_pref_mapping.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright 2022 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 <stddef.h>

#include "build/build_config.h"
#include "build/chromeos_buildflags.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_pref_names.h"
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/common/pref_names.h"
#endif

namespace chromeos {
namespace prefs {
#if BUILDFLAG(IS_CHROMEOS_ASH)
const char* kAccessibilityFocusHighlightEnabled =
ash::prefs::kAccessibilityFocusHighlightEnabled;
const char* kAccessibilityAutoclickEnabled =
ash::prefs::kAccessibilityAutoclickEnabled;
const char* kAccessibilityCaretHighlightEnabled =
ash::prefs::kAccessibilityCaretHighlightEnabled;
const char* kAccessibilityCursorColorEnabled =
ash::prefs::kAccessibilityCursorColorEnabled;
const char* kAccessibilityCursorHighlightEnabled =
ash::prefs::kAccessibilityCursorHighlightEnabled;
const char* kAccessibilityDictationEnabled =
ash::prefs::kAccessibilityDictationEnabled;
const char* kAccessibilityHighContrastEnabled =
ash::prefs::kAccessibilityHighContrastEnabled;
const char* kAccessibilityLargeCursorEnabled =
ash::prefs::kAccessibilityLargeCursorEnabled;
const char* kAccessibilityScreenMagnifierEnabled =
ash::prefs::kAccessibilityScreenMagnifierEnabled;
const char* kAccessibilitySelectToSpeakEnabled =
ash::prefs::kAccessibilitySelectToSpeakEnabled;
const char* kAccessibilitySpokenFeedbackEnabled =
ash::prefs::kAccessibilitySpokenFeedbackEnabled;
const char* kAccessibilityStickyKeysEnabled =
ash::prefs::kAccessibilityStickyKeysEnabled;
const char* kAccessibilitySwitchAccessEnabled =
ash::prefs::kAccessibilitySwitchAccessEnabled;
const char* kAccessibilityVirtualKeyboardEnabled =
ash::prefs::kAccessibilityVirtualKeyboardEnabled;
const char* kDockedMagnifierEnabled = ash::prefs::kDockedMagnifierEnabled;
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
const char* kAccessibilityFocusHighlightEnabled =
::prefs::kLacrosAccessibilityFocusHighlightEnabled;
const char* kAccessibilityAutoclickEnabled =
::prefs::kLacrosAccessibilityAutoclickEnabled;
const char* kAccessibilityCaretHighlightEnabled =
::prefs::kLacrosAccessibilityCaretHighlightEnabled;
const char* kAccessibilityCursorColorEnabled =
::prefs::kLacrosAccessibilityCursorColorEnabled;
const char* kAccessibilityCursorHighlightEnabled =
::prefs::kLacrosAccessibilityCursorHighlightEnabled;
const char* kAccessibilityDictationEnabled =
::prefs::kLacrosAccessibilityDictationEnabled;
const char* kAccessibilityHighContrastEnabled =
::prefs::kLacrosAccessibilityHighContrastEnabled;
const char* kAccessibilityLargeCursorEnabled =
::prefs::kLacrosAccessibilityLargeCursorEnabled;
const char* kAccessibilityScreenMagnifierEnabled =
::prefs::kLacrosAccessibilityScreenMagnifierEnabled;
const char* kAccessibilitySelectToSpeakEnabled =
::prefs::kLacrosAccessibilitySelectToSpeakEnabled;
const char* kAccessibilitySpokenFeedbackEnabled =
::prefs::kLacrosAccessibilitySpokenFeedbackEnabled;
const char* kAccessibilityStickyKeysEnabled =
::prefs::kLacrosAccessibilityStickyKeysEnabled;
const char* kAccessibilitySwitchAccessEnabled =
::prefs::kLacrosAccessibilitySwitchAccessEnabled;
const char* kAccessibilityVirtualKeyboardEnabled =
::prefs::kLacrosAccessibilityVirtualKeyboardEnabled;
const char* kDockedMagnifierEnabled = ::prefs::kLacrosDockedMagnifierEnabled;
#endif

} // namespace prefs
} // namespace chromeos
40 changes: 40 additions & 0 deletions chrome/browser/chromeos/extensions/controlled_pref_mapping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2022 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_CHROMEOS_EXTENSIONS_CONTROLLED_PREF_MAPPING_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_CONTROLLED_PREF_MAPPING_H_

#include <stddef.h>

namespace chromeos {
namespace prefs {

// These constants are used with extension controlled prefs where the underlying
// preference being controlled live in ash. In lacros they map to a pref used
// to hold the value of the pref of all extensions, which is shipped to ash.
// in ash, they map to the actual pref controlling the feature.

// FocusHighlight is special as the feature exists on several platforms.
// However, extensions can only set the ash-value.
extern const char* kAccessibilityFocusHighlightEnabled;

extern const char* kAccessibilityAutoclickEnabled;
extern const char* kAccessibilityCaretHighlightEnabled;
extern const char* kAccessibilityCursorColorEnabled;
extern const char* kAccessibilityCursorHighlightEnabled;
extern const char* kAccessibilityDictationEnabled;
extern const char* kAccessibilityHighContrastEnabled;
extern const char* kAccessibilityLargeCursorEnabled;
extern const char* kAccessibilityScreenMagnifierEnabled;
extern const char* kAccessibilitySelectToSpeakEnabled;
extern const char* kAccessibilitySpokenFeedbackEnabled;
extern const char* kAccessibilityStickyKeysEnabled;
extern const char* kAccessibilitySwitchAccessEnabled;
extern const char* kAccessibilityVirtualKeyboardEnabled;
extern const char* kDockedMagnifierEnabled;

} // namespace prefs
} // namespace chromeos

#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_CONTROLLED_PREF_MAPPING_H_
1 change: 1 addition & 0 deletions chrome/browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ static_library("extensions") {
]
}
deps += [
"//chrome/browser/chromeos/extensions:constants",
"//chrome/browser/chromeos/extensions/login_screen",
"//chromeos/components/quick_answers/public/cpp:prefs",
"//chromeos/crosapi/cpp",
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/extensions/api/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ function_registration("api_registration") {
"//third_party/metrics_proto",
"//ui/accessibility:ax_enums_mojo",
]
if (is_chromeos) {
deps += [ "//chrome/browser/chromeos/extensions:constants" ]
}
}

0 comments on commit c4a4e45

Please sign in to comment.