Skip to content

Commit

Permalink
chore: modernize ListValue code in session (electron#34656)
Browse files Browse the repository at this point in the history
* chore: modernize ListValue code in session

* also in browser_context
  • Loading branch information
nornagon authored and schetle committed Aug 18, 2022
1 parent bc1c294 commit 589cdf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions shell/browser/api/electron_api_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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());
Expand Down
5 changes: 3 additions & 2 deletions shell/browser/electron_browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 589cdf2

Please sign in to comment.