chore: modernize ListValue code in session (#34656)

* chore: modernize ListValue code in session

* also in browser_context
This commit is contained in:
Jeremy Rose 2022-06-22 01:14:35 -07:00 committed by GitHub
parent ad7aab8338
commit 73c85410c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -1024,7 +1024,7 @@ base::Value Session::GetSpellCheckerLanguages() {
void Session::SetSpellCheckerLanguages(
gin_helper::ErrorThrower thrower,
const std::vector<std::string>& languages) {
base::ListValue language_codes;
base::Value::List language_codes;
for (const std::string& lang : languages) {
std::string code = spellcheck::GetCorrespondingSpellCheckLanguage(lang);
if (code.empty()) {
@ -1035,7 +1035,7 @@ void Session::SetSpellCheckerLanguages(
language_codes.Append(code);
}
browser_context_->prefs()->Set(spellcheck::prefs::kSpellCheckDictionaries,
language_codes);
base::Value(std::move(language_codes)));
// Enable spellcheck if > 0 languages, disable if no languages set
browser_context_->prefs()->SetBoolean(spellcheck::prefs::kSpellCheckEnable,
!languages.empty());

View file

@ -220,9 +220,10 @@ void ElectronBrowserContext::InitPrefs() {
std::string default_code = spellcheck::GetCorrespondingSpellCheckLanguage(
base::i18n::GetConfiguredLocale());
if (!default_code.empty()) {
base::ListValue language_codes;
base::Value::List language_codes;
language_codes.Append(default_code);
prefs()->Set(spellcheck::prefs::kSpellCheckDictionaries, language_codes);
prefs()->Set(spellcheck::prefs::kSpellCheckDictionaries,
base::Value(std::move(language_codes)));
}
}
#endif