| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/spellcheck_host.h" | 5 #include "chrome/browser/spellcheck_host.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // The current dictionary language should be there. | 118 // The current dictionary language should be there. |
| 119 languages->push_back(dictionary_language); | 119 languages->push_back(dictionary_language); |
| 120 | 120 |
| 121 // Now scan through the list of accept languages, and find possible mappings | 121 // Now scan through the list of accept languages, and find possible mappings |
| 122 // from this list to the existing list of spell check languages. | 122 // from this list to the existing list of spell check languages. |
| 123 std::vector<std::string> accept_languages; | 123 std::vector<std::string> accept_languages; |
| 124 | 124 |
| 125 if (SpellCheckerPlatform::SpellCheckerAvailable()) | 125 if (SpellCheckerPlatform::SpellCheckerAvailable()) |
| 126 SpellCheckerPlatform::GetAvailableLanguages(&accept_languages); | 126 SpellCheckerPlatform::GetAvailableLanguages(&accept_languages); |
| 127 else | 127 else |
| 128 SplitString(accept_languages_pref.GetValue(), ',', &accept_languages); | 128 base::SplitString(accept_languages_pref.GetValue(), ',', &accept_languages); |
| 129 | 129 |
| 130 for (std::vector<std::string>::const_iterator i = accept_languages.begin(); | 130 for (std::vector<std::string>::const_iterator i = accept_languages.begin(); |
| 131 i != accept_languages.end(); ++i) { | 131 i != accept_languages.end(); ++i) { |
| 132 std::string language = | 132 std::string language = |
| 133 SpellCheckCommon::GetCorrespondingSpellCheckLanguage(*i); | 133 SpellCheckCommon::GetCorrespondingSpellCheckLanguage(*i); |
| 134 if (!language.empty() && | 134 if (!language.empty() && |
| 135 std::find(languages->begin(), languages->end(), language) == | 135 std::find(languages->begin(), languages->end(), language) == |
| 136 languages->end()) { | 136 languages->end()) { |
| 137 languages->push_back(language); | 137 languages->push_back(language); |
| 138 } | 138 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 return; | 182 return; |
| 183 } | 183 } |
| 184 | 184 |
| 185 request_context_getter_ = NULL; | 185 request_context_getter_ = NULL; |
| 186 | 186 |
| 187 if (file_ != base::kInvalidPlatformFileValue) { | 187 if (file_ != base::kInvalidPlatformFileValue) { |
| 188 // Load custom dictionary. | 188 // Load custom dictionary. |
| 189 std::string contents; | 189 std::string contents; |
| 190 file_util::ReadFileToString(custom_dictionary_file_, &contents); | 190 file_util::ReadFileToString(custom_dictionary_file_, &contents); |
| 191 std::vector<std::string> list_of_words; | 191 std::vector<std::string> list_of_words; |
| 192 SplitString(contents, '\n', &list_of_words); | 192 base::SplitString(contents, '\n', &list_of_words); |
| 193 for (size_t i = 0; i < list_of_words.size(); ++i) | 193 for (size_t i = 0; i < list_of_words.size(); ++i) |
| 194 custom_words_.push_back(list_of_words[i]); | 194 custom_words_.push_back(list_of_words[i]); |
| 195 } | 195 } |
| 196 | 196 |
| 197 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 197 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 198 NewRunnableMethod(this, | 198 NewRunnableMethod(this, |
| 199 &SpellCheckHost::InformObserverOfInitialization)); | 199 &SpellCheckHost::InformObserverOfInitialization)); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void SpellCheckHost::InitializeOnFileThread() { | 202 void SpellCheckHost::InitializeOnFileThread() { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 302 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 303 NewRunnableMethod(this, | 303 NewRunnableMethod(this, |
| 304 &SpellCheckHost::InformObserverOfInitialization)); | 304 &SpellCheckHost::InformObserverOfInitialization)); |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 | 308 |
| 309 data_.clear(); | 309 data_.clear(); |
| 310 Initialize(); | 310 Initialize(); |
| 311 } | 311 } |
| OLD | NEW |