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/renderer/spellchecker/custom_dictionary_engine.h" | 5 #include "chrome/renderer/spellchecker/custom_dictionary_engine.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 | 9 |
10 CustomDictionaryEngine::CustomDictionaryEngine() { | 10 CustomDictionaryEngine::CustomDictionaryEngine() { |
(...skipping 23 matching lines...) Expand all Loading... |
34 dictionary_.insert(UTF8ToUTF16(*it)); | 34 dictionary_.insert(UTF8ToUTF16(*it)); |
35 } | 35 } |
36 for (std::vector<std::string>::const_iterator it = words_removed.begin(); | 36 for (std::vector<std::string>::const_iterator it = words_removed.begin(); |
37 it != words_removed.end(); | 37 it != words_removed.end(); |
38 ++it) { | 38 ++it) { |
39 dictionary_.erase(UTF8ToUTF16(*it)); | 39 dictionary_.erase(UTF8ToUTF16(*it)); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 bool CustomDictionaryEngine::SpellCheckWord( | 43 bool CustomDictionaryEngine::SpellCheckWord( |
44 const string16& text, | 44 const base::string16& text, |
45 int misspelling_start, | 45 int misspelling_start, |
46 int misspelling_len) { | 46 int misspelling_len) { |
47 // The text to be checked is empty on OSX(async) right now. | 47 // The text to be checked is empty on OSX(async) right now. |
48 // TODO(groby): Fix as part of async hook-up. (http://crbug.com/178241) | 48 // TODO(groby): Fix as part of async hook-up. (http://crbug.com/178241) |
49 return | 49 return |
50 misspelling_start >= 0 && | 50 misspelling_start >= 0 && |
51 misspelling_len > 0 && | 51 misspelling_len > 0 && |
52 size_t(misspelling_start + misspelling_len) <= text.length() && | 52 size_t(misspelling_start + misspelling_len) <= text.length() && |
53 dictionary_.count(text.substr(misspelling_start, misspelling_len)) > 0; | 53 dictionary_.count(text.substr(misspelling_start, misspelling_len)) > 0; |
54 } | 54 } |
OLD | NEW |