| Index: chrome/browser/spellchecker/spellcheck_service.cc
|
| diff --git a/chrome/browser/spellchecker/spellcheck_service.cc b/chrome/browser/spellchecker/spellcheck_service.cc
|
| index e496d8909d595f1bb2fe556828561e700f2dec96..cf86778ba821d57661601d8e86604524fb5cb435 100644
|
| --- a/chrome/browser/spellchecker/spellcheck_service.cc
|
| +++ b/chrome/browser/spellchecker/spellcheck_service.cc
|
| @@ -20,9 +20,8 @@
|
| #include "components/spellcheck/browser/spellcheck_host_metrics.h"
|
| #include "components/spellcheck/browser/spellcheck_platform.h"
|
| #include "components/spellcheck/browser/spelling_service_client.h"
|
| -#include "components/spellcheck/common/spellcheck_bdict_language.h"
|
| +#include "components/spellcheck/common/spellcheck.mojom.h"
|
| #include "components/spellcheck/common/spellcheck_common.h"
|
| -#include "components/spellcheck/common/spellcheck_messages.h"
|
| #include "components/spellcheck/spellcheck_build_features.h"
|
| #include "components/user_prefs/user_prefs.h"
|
| #include "content/public/browser/browser_context.h"
|
| @@ -31,7 +30,6 @@
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/storage_partition.h"
|
| -#include "ipc/ipc_platform_file.h"
|
|
|
| using content::BrowserThread;
|
|
|
| @@ -174,27 +172,27 @@ void SpellcheckService::InitForRenderer(content::RenderProcessHost* process) {
|
| if (SpellcheckServiceFactory::GetForContext(context) != this)
|
| return;
|
|
|
| - PrefService* prefs = user_prefs::UserPrefs::Get(context);
|
| - std::vector<SpellCheckBDictLanguage> bdict_languages;
|
| + const PrefService* prefs = user_prefs::UserPrefs::Get(context);
|
| + std::vector<spellcheck::mojom::SpellCheckBDictLanguagePtr> dictionaries;
|
|
|
| for (const auto& hunspell_dictionary : hunspell_dictionaries_) {
|
| - bdict_languages.push_back(SpellCheckBDictLanguage());
|
| - bdict_languages.back().language = hunspell_dictionary->GetLanguage();
|
| - bdict_languages.back().file =
|
| - hunspell_dictionary->GetDictionaryFile().IsValid()
|
| - ? IPC::GetPlatformFileForTransit(
|
| - hunspell_dictionary->GetDictionaryFile().GetPlatformFile(),
|
| - false)
|
| - : IPC::InvalidPlatformFileForTransit();
|
| + dictionaries.push_back(spellcheck::mojom::SpellCheckBDictLanguage::New(
|
| + hunspell_dictionary->GetDictionaryFile().Duplicate(),
|
| + hunspell_dictionary->GetLanguage()));
|
| }
|
|
|
| - bool enabled =
|
| - prefs->GetBoolean(spellcheck::prefs::kEnableSpellcheck) &&
|
| - !bdict_languages.empty();
|
| - process->Send(new SpellCheckMsg_Init(
|
| - bdict_languages,
|
| - enabled ? custom_dictionary_->GetWords() : std::set<std::string>()));
|
| - process->Send(new SpellCheckMsg_EnableSpellCheck(enabled));
|
| + bool enable = prefs->GetBoolean(spellcheck::prefs::kEnableSpellcheck) &&
|
| + !dictionaries.empty();
|
| +
|
| + std::vector<std::string> custom_words;
|
| + if (enable) {
|
| + custom_words.assign(custom_dictionary_->GetWords().begin(),
|
| + custom_dictionary_->GetWords().end());
|
| + }
|
| +
|
| + spellcheck::mojom::SpellCheckerPtr spellchecker;
|
| + content::BindInterface(process, &spellchecker);
|
| + spellchecker->Initialize(std::move(dictionaries), custom_words, enable);
|
| }
|
|
|
| SpellCheckHostMetrics* SpellcheckService::GetMetrics() const {
|
| @@ -257,13 +255,20 @@ void SpellcheckService::OnCustomDictionaryLoaded() {
|
| }
|
|
|
| void SpellcheckService::OnCustomDictionaryChanged(
|
| - const SpellcheckCustomDictionary::Change& dictionary_change) {
|
| - for (content::RenderProcessHost::iterator i(
|
| - content::RenderProcessHost::AllHostsIterator());
|
| - !i.IsAtEnd(); i.Advance()) {
|
| - i.GetCurrentValue()->Send(new SpellCheckMsg_CustomDictionaryChanged(
|
| - dictionary_change.to_add(),
|
| - dictionary_change.to_remove()));
|
| + const SpellcheckCustomDictionary::Change& change) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + auto process_hosts(content::RenderProcessHost::AllHostsIterator());
|
| +
|
| + const std::vector<std::string> additions(change.to_add().begin(),
|
| + change.to_add().end());
|
| + const std::vector<std::string> deletions(change.to_remove().begin(),
|
| + change.to_remove().end());
|
| + while (!process_hosts.IsAtEnd()) {
|
| + spellcheck::mojom::SpellCheckerPtr spellchecker;
|
| + content::BindInterface(process_hosts.GetCurrentValue(), &spellchecker);
|
| + spellchecker->CustomDictionaryChanged(additions, deletions);
|
| + process_hosts.Advance();
|
| }
|
| }
|
|
|
|
|