OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/spellcheck.h" | 5 #include "chrome/renderer/spellchecker/spellcheck.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { | 29 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { |
30 bool handled = true; | 30 bool handled = true; |
31 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) | 31 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) |
32 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit) | 32 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit) |
33 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnWordAdded) | 33 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnWordAdded) |
34 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect, | 34 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect, |
35 OnEnableAutoSpellCorrect) | 35 OnEnableAutoSpellCorrect) |
36 IPC_MESSAGE_UNHANDLED(handled = false) | 36 IPC_MESSAGE_UNHANDLED(handled = false) |
37 IPC_END_MESSAGE_MAP() | 37 IPC_END_MESSAGE_MAP() |
38 | 38 |
39 if (message.type() == ViewMsg_PurgeMemory::ID) { | |
40 delete this; | |
41 new SpellCheck(); | |
42 } | |
43 | |
44 return handled; | 39 return handled; |
45 } | 40 } |
46 | 41 |
47 void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file, | 42 void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file, |
48 const std::vector<std::string>& custom_words, | 43 const std::vector<std::string>& custom_words, |
49 const std::string& language, | 44 const std::string& language, |
50 bool auto_spell_correct) { | 45 bool auto_spell_correct) { |
51 Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file), | 46 Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file), |
52 custom_words, language); | 47 custom_words, language); |
53 auto_spell_correct_turned_on_ = auto_spell_correct; | 48 auto_spell_correct_turned_on_ = auto_spell_correct; |
54 } | 49 } |
55 | 50 |
56 void SpellCheck::OnWordAdded(const std::string& word) { | 51 void SpellCheck::OnWordAdded(const std::string& word) { |
57 if (is_using_platform_spelling_engine_) | 52 if (is_using_platform_spelling_engine_) |
58 return; | 53 return; |
59 | 54 |
60 if (!hunspell_.get()) { | 55 if (!hunspell_.get()) { |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 298 |
304 string16 word; | 299 string16 word; |
305 int word_start; | 300 int word_start; |
306 int word_length; | 301 int word_length; |
307 while (word_iterator.GetNextWord(&word, &word_start, &word_length)) { | 302 while (word_iterator.GetNextWord(&word, &word_start, &word_length)) { |
308 if (!CheckSpelling(word, tag)) | 303 if (!CheckSpelling(word, tag)) |
309 return false; | 304 return false; |
310 } | 305 } |
311 return true; | 306 return true; |
312 } | 307 } |
OLD | NEW |