| 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/string_split.h" | 8 #include "base/string_split.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "chrome/browser/api/prefs/pref_member.h" | 10 #include "chrome/browser/api/prefs/pref_member.h" |
| 11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 13 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 14 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" | 14 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" |
| 15 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 15 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
| 16 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 16 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/common/spellcheck_messages.h" | 18 #include "chrome/common/spellcheck_messages.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
| 22 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 23 #include "ipc/ipc_platform_file.h" | 23 #include "ipc/ipc_platform_file.h" |
| 24 | 24 |
| 25 using content::BrowserThread; | 25 using content::BrowserThread; |
| 26 using chrome::spellcheck_common::WordList; | 26 using chrome::spellcheck_common::WordList; |
| 27 | 27 |
| 28 // TODO(rlp): I do not like globals, but keeping thsese for now during | 28 // TODO(rlp): I do not like globals, but keeping these for now during |
| 29 // transition. | 29 // transition. |
| 30 // An event used by browser tests to receive status events from this class and | 30 // An event used by browser tests to receive status events from this class and |
| 31 // its derived classes. | 31 // its derived classes. |
| 32 base::WaitableEvent* g_status_event = NULL; | 32 base::WaitableEvent* g_status_event = NULL; |
| 33 SpellcheckService::EventType g_status_type = | 33 SpellcheckService::EventType g_status_type = |
| 34 SpellcheckService::BDICT_NOTINITIALIZED; | 34 SpellcheckService::BDICT_NOTINITIALIZED; |
| 35 | 35 |
| 36 SpellcheckService::SpellcheckService(Profile* profile) | 36 SpellcheckService::SpellcheckService(Profile* profile) |
| 37 : profile_(profile), | 37 : profile_(profile), |
| 38 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 38 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 DUPLICATE_SAME_ACCESS); | 180 DUPLICATE_SAME_ACCESS); |
| 181 DCHECK(ok) << ::GetLastError(); | 181 DCHECK(ok) << ::GetLastError(); |
| 182 #endif | 182 #endif |
| 183 } | 183 } |
| 184 | 184 |
| 185 process->Send(new SpellCheckMsg_Init( | 185 process->Send(new SpellCheckMsg_Init( |
| 186 file, | 186 file, |
| 187 custom_dictionary_->GetWords(), | 187 custom_dictionary_->GetWords(), |
| 188 hunspell_dictionary_->GetLanguage(), | 188 hunspell_dictionary_->GetLanguage(), |
| 189 prefs->GetBoolean(prefs::kEnableAutoSpellCorrect))); | 189 prefs->GetBoolean(prefs::kEnableAutoSpellCorrect))); |
| 190 process->Send(new SpellCheckMsg_EnableSpellCheck( |
| 191 prefs->GetBoolean(prefs::kEnableSpellCheck))); |
| 190 } | 192 } |
| 191 | 193 |
| 192 SpellCheckHostMetrics* SpellcheckService::GetMetrics() const { | 194 SpellCheckHostMetrics* SpellcheckService::GetMetrics() const { |
| 193 return metrics_.get(); | 195 return metrics_.get(); |
| 194 } | 196 } |
| 195 | 197 |
| 196 SpellcheckCustomDictionary* SpellcheckService::GetCustomDictionary() { | 198 SpellcheckCustomDictionary* SpellcheckService::GetCustomDictionary() { |
| 197 return custom_dictionary_.get(); | 199 return custom_dictionary_.get(); |
| 198 } | 200 } |
| 199 | 201 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 237 } |
| 236 | 238 |
| 237 // static | 239 // static |
| 238 SpellcheckService::EventType SpellcheckService::WaitStatusEvent() { | 240 SpellcheckService::EventType SpellcheckService::WaitStatusEvent() { |
| 239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 240 | 242 |
| 241 if (g_status_event) | 243 if (g_status_event) |
| 242 g_status_event->Wait(); | 244 g_status_event->Wait(); |
| 243 return g_status_type; | 245 return g_status_type; |
| 244 } | 246 } |
| OLD | NEW |