Move SODA path retrieval to the browser process
This CL moves the code that retrieves the path of the Speech On-Device
API (SODA) binary and language config file from the speech recognition
process running a kSpeechRecognition sandbox to the browser process.
The Windows version of the kSpeechRecognition sandbox will not have
access to the PrefService, so the path must be determined by the
browser. This change also allows the linux sandbox to be tightened.
Bug: 1109405
Change-Id: Ieec05935348322cfaef2753ee49a533fa42c362a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317761
Reviewed-by: Matthew Denton <[email protected]>
Reviewed-by: Dominic Mazzoni <[email protected]>
Reviewed-by: Joshua Pawlicki <[email protected]>
Commit-Queue: Evan Liu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#793382}
diff --git a/chrome/browser/component_updater/soda_component_installer.cc b/chrome/browser/component_updater/soda_component_installer.cc
index 57557c6..1ca1dc01 100644
--- a/chrome/browser/component_updater/soda_component_installer.cc
+++ b/chrome/browser/component_updater/soda_component_installer.cc
@@ -36,6 +36,12 @@
const char kSODAManifestName[] = "SODA Library";
+constexpr base::FilePath::CharType kSodaBinaryRelativePath[] =
+ FILE_PATH_LITERAL("SODAFiles/libsoda.so");
+
+constexpr base::FilePath::CharType kSodaEnUsConfigFileRelativePath[] =
+ FILE_PATH_LITERAL("SODAFiles/en_us/dictation.ascii_proto");
+
} // namespace
SODAComponentInstallerPolicy::SODAComponentInstallerPolicy(
@@ -122,8 +128,10 @@
void UpdateSODAInstallDirPref(PrefService* prefs,
const base::FilePath& install_dir) {
#if !defined(OS_ANDROID)
- prefs->SetFilePath(prefs::kSODAPath,
- install_dir.Append(speech::kSodaBinaryRelativePath));
+ prefs->SetFilePath(prefs::kSodaBinaryPath,
+ install_dir.Append(kSodaBinaryRelativePath));
+ prefs->SetFilePath(prefs::kSodaEnUsConfigPath,
+ install_dir.Append(kSodaEnUsConfigFileRelativePath));
#endif
}
@@ -150,13 +158,15 @@
} else {
// Register and uninstall the SODA component to delete the previously
// installed SODA files.
- if (!prefs->GetFilePath(prefs::kSODAPath).empty()) {
+ if (!prefs->GetFilePath(prefs::kSodaBinaryPath).empty()) {
installer->Register(
cus,
base::BindOnce(
[](ComponentUpdateService* cus, PrefService* prefs) {
if (component_updater::UninstallSODAComponent(cus, prefs)) {
- prefs->SetFilePath(prefs::kSODAPath, base::FilePath());
+ prefs->SetFilePath(prefs::kSodaBinaryPath, base::FilePath());
+ prefs->SetFilePath(prefs::kSodaEnUsConfigPath,
+ base::FilePath());
}
},
cus, prefs));