| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/spellchecker/spellcheck_service.h" | 5 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 6 | 6 |
| 7 #include "base/platform_file.h" | 7 #include "base/platform_file.h" |
| 8 #include "base/prefs/public/pref_member.h" | 8 #include "base/prefs/public/pref_member.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 g_status_event->Wait(); | 241 g_status_event->Wait(); |
| 242 return g_status_type; | 242 return g_status_type; |
| 243 } | 243 } |
| 244 | 244 |
| 245 void SpellcheckService::InitForAllRenderers() { | 245 void SpellcheckService::InitForAllRenderers() { |
| 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 247 for (content::RenderProcessHost::iterator i( | 247 for (content::RenderProcessHost::iterator i( |
| 248 content::RenderProcessHost::AllHostsIterator()); | 248 content::RenderProcessHost::AllHostsIterator()); |
| 249 !i.IsAtEnd(); i.Advance()) { | 249 !i.IsAtEnd(); i.Advance()) { |
| 250 content::RenderProcessHost* process = i.GetCurrentValue(); | 250 content::RenderProcessHost* process = i.GetCurrentValue(); |
| 251 if (process) | 251 if (process && process->GetHandle()) |
| 252 InitForRenderer(process); | 252 InitForRenderer(process); |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 | 255 |
| 256 void SpellcheckService::OnEnableAutoSpellCorrectChanged() { | 256 void SpellcheckService::OnEnableAutoSpellCorrectChanged() { |
| 257 bool enabled = pref_change_registrar_.prefs()->GetBoolean( | 257 bool enabled = pref_change_registrar_.prefs()->GetBoolean( |
| 258 prefs::kEnableAutoSpellCorrect); | 258 prefs::kEnableAutoSpellCorrect); |
| 259 for (content::RenderProcessHost::iterator i( | 259 for (content::RenderProcessHost::iterator i( |
| 260 content::RenderProcessHost::AllHostsIterator()); | 260 content::RenderProcessHost::AllHostsIterator()); |
| 261 !i.IsAtEnd(); i.Advance()) { | 261 !i.IsAtEnd(); i.Advance()) { |
| 262 content::RenderProcessHost* process = i.GetCurrentValue(); | 262 content::RenderProcessHost* process = i.GetCurrentValue(); |
| 263 process->Send(new SpellCheckMsg_EnableAutoSpellCorrect(enabled)); | 263 process->Send(new SpellCheckMsg_EnableAutoSpellCorrect(enabled)); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 void SpellcheckService::OnSpellCheckDictionaryChanged() { | 267 void SpellcheckService::OnSpellCheckDictionaryChanged() { |
| 268 if (hunspell_dictionary_.get()) | 268 if (hunspell_dictionary_.get()) |
| 269 hunspell_dictionary_->RemoveObserver(this); | 269 hunspell_dictionary_->RemoveObserver(this); |
| 270 hunspell_dictionary_.reset(new SpellcheckHunspellDictionary( | 270 hunspell_dictionary_.reset(new SpellcheckHunspellDictionary( |
| 271 profile_->GetPrefs()->GetString(prefs::kSpellCheckDictionary), | 271 profile_->GetPrefs()->GetString(prefs::kSpellCheckDictionary), |
| 272 profile_->GetRequestContext(), | 272 profile_->GetRequestContext(), |
| 273 this)); | 273 this)); |
| 274 hunspell_dictionary_->AddObserver(this); | 274 hunspell_dictionary_->AddObserver(this); |
| 275 hunspell_dictionary_->Load(); | 275 hunspell_dictionary_->Load(); |
| 276 } | 276 } |
| OLD | NEW |