| Index: chrome/browser/spellchecker/spellcheck_service.cc
|
| diff --git a/chrome/browser/spellchecker/spellcheck_service.cc b/chrome/browser/spellchecker/spellcheck_service.cc
|
| index e4e79f71b6bb8c7bc412c42ca2f59e4223c3d42b..47cfcaf131f5a5ed8285c5554e5b4c8d62d9ccbb 100644
|
| --- a/chrome/browser/spellchecker/spellcheck_service.cc
|
| +++ b/chrome/browser/spellchecker/spellcheck_service.cc
|
| @@ -51,6 +51,7 @@ SpellcheckService::SpellcheckService(Profile* profile)
|
| hunspell_dictionary_->Initialize();
|
|
|
| custom_dictionary_.reset(new SpellcheckCustomDictionary(profile_));
|
| + custom_dictionary_->AddObserver(this);
|
| custom_dictionary_->Load();
|
|
|
| registrar_.Add(weak_ptr_factory_.GetWeakPtr(),
|
| @@ -131,32 +132,22 @@ bool SpellcheckService::SignalStatusEvent(
|
| return true;
|
| }
|
|
|
| -// static
|
| -void SpellcheckService::AttachStatusEvent(base::WaitableEvent* status_event) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - g_status_event = status_event;
|
| -}
|
| -
|
| -// static
|
| -SpellcheckService::EventType SpellcheckService::WaitStatusEvent() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - if (g_status_event)
|
| - g_status_event->Wait();
|
| - return g_status_type;
|
| -}
|
| -
|
| -void SpellcheckService::Initialize() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - hunspell_dictionary_->Initialize();
|
| -}
|
| -
|
| void SpellcheckService::StartRecordingMetrics(bool spellcheck_enabled) {
|
| metrics_.reset(new SpellCheckHostMetrics());
|
| metrics_->RecordEnabledStats(spellcheck_enabled);
|
| }
|
|
|
| +void SpellcheckService::InitForAllRenderers() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + for (content::RenderProcessHost::iterator i(
|
| + content::RenderProcessHost::AllHostsIterator());
|
| + !i.IsAtEnd(); i.Advance()) {
|
| + content::RenderProcessHost* process = i.GetCurrentValue();
|
| + if (process)
|
| + InitForRenderer(process);
|
| + }
|
| +}
|
| +
|
| void SpellcheckService::InitForRenderer(content::RenderProcessHost* process) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -184,15 +175,37 @@ void SpellcheckService::InitForRenderer(content::RenderProcessHost* process) {
|
| #endif
|
| }
|
|
|
| - WordList custom_words = GetCustomDictionary()->GetCustomWords();
|
| -
|
| process->Send(new SpellCheckMsg_Init(
|
| file,
|
| - custom_words,
|
| + custom_dictionary_->GetWords(),
|
| hunspell_dictionary_->GetLanguage(),
|
| prefs->GetBoolean(prefs::kEnableAutoSpellCorrect)));
|
| }
|
|
|
| +bool SpellcheckService::IsReady() const {
|
| + return hunspell_dictionary_->IsReady();
|
| +}
|
| +
|
| +const base::PlatformFile& SpellcheckService::GetDictionaryFile() const {
|
| + return hunspell_dictionary_->GetDictionaryFile();
|
| +}
|
| +
|
| +const std::string& SpellcheckService::GetLanguage() const {
|
| + return hunspell_dictionary_->GetLanguage();
|
| +}
|
| +
|
| +bool SpellcheckService::IsUsingPlatformChecker() const {
|
| + return hunspell_dictionary_->IsUsingPlatformChecker();
|
| +}
|
| +
|
| +SpellCheckHostMetrics* SpellcheckService::GetMetrics() const {
|
| + return metrics_.get();
|
| +}
|
| +
|
| +SpellcheckCustomDictionary* SpellcheckService::GetCustomDictionary() {
|
| + return custom_dictionary_.get();
|
| +}
|
| +
|
| void SpellcheckService::Observe(int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| @@ -207,7 +220,7 @@ void SpellcheckService::OnPreferenceChanged(PrefServiceBase* prefs,
|
| DCHECK(prefs);
|
| if (pref_name_in == prefs::kSpellCheckDictionary ||
|
| pref_name_in == prefs::kEnableSpellCheck) {
|
| - InformProfileOfInitializationWithCustomWords(NULL);
|
| + InitForAllRenderers();
|
| } else if (pref_name_in == prefs::kEnableAutoSpellCorrect) {
|
| bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect);
|
| for (content::RenderProcessHost::iterator i(
|
| @@ -219,44 +232,28 @@ void SpellcheckService::OnPreferenceChanged(PrefServiceBase* prefs,
|
| }
|
| }
|
|
|
| -SpellCheckHostMetrics* SpellcheckService::GetMetrics() const {
|
| - return metrics_.get();
|
| +void SpellcheckService::OnCustomDictionaryLoaded() {
|
| + InitForAllRenderers();
|
| }
|
|
|
| -SpellcheckCustomDictionary* SpellcheckService::GetCustomDictionary() {
|
| - return custom_dictionary_.get();
|
| +void SpellcheckService::OnCustomDictionaryWordAdded(const std::string& word) {
|
| }
|
|
|
| -bool SpellcheckService::IsReady() const {
|
| - return hunspell_dictionary_->IsReady();
|
| +void SpellcheckService::OnCustomDictionaryWordRemoved(const std::string& word) {
|
| }
|
|
|
| -bool SpellcheckService::IsUsingPlatformChecker() const {
|
| - return hunspell_dictionary_->IsUsingPlatformChecker();
|
| -}
|
| -
|
| -const base::PlatformFile& SpellcheckService::GetDictionaryFile() const {
|
| - return hunspell_dictionary_->GetDictionaryFile();
|
| -}
|
| +// static
|
| +void SpellcheckService::AttachStatusEvent(base::WaitableEvent* status_event) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| -const std::string& SpellcheckService::GetLanguage() const {
|
| - return hunspell_dictionary_->GetLanguage();
|
| + g_status_event = status_event;
|
| }
|
|
|
| -// TODO(rlp): rename to something more logical.
|
| -void SpellcheckService::InformProfileOfInitializationWithCustomWords(
|
| - WordList* custom_words) {
|
| +// static
|
| +SpellcheckService::EventType SpellcheckService::WaitStatusEvent() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| - if (custom_words) {
|
| - GetCustomDictionary()->SetCustomWordList(custom_words);
|
| - }
|
| -
|
| - for (content::RenderProcessHost::iterator i(
|
| - content::RenderProcessHost::AllHostsIterator());
|
| - !i.IsAtEnd(); i.Advance()) {
|
| - content::RenderProcessHost* process = i.GetCurrentValue();
|
| - if (process)
|
| - InitForRenderer(process);
|
| - }
|
| + if (g_status_event)
|
| + g_status_event->Wait();
|
| + return g_status_type;
|
| }
|
|
|