Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/renderer/spellchecker/hunspell_engine.h

Issue 11362063: Editing the custom spelling dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Exclude custom dictionary WebUI from mac Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_ 5 #ifndef CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_
6 #define CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_ 6 #define CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/common/spellcheck_common.h"
12 #include "chrome/renderer/spellchecker/spelling_engine.h" 13 #include "chrome/renderer/spellchecker/spelling_engine.h"
13 14
14 #include <string> 15 #include <string>
15 #include <vector> 16 #include <vector>
16 17
17 class Hunspell; 18 class Hunspell;
18 19
19 class HunspellEngine : public SpellingEngine { 20 class HunspellEngine : public SpellingEngine {
20 public: 21 public:
21 HunspellEngine(); 22 HunspellEngine();
22 virtual ~HunspellEngine(); 23 virtual ~HunspellEngine();
23 24
24 void Init(base::PlatformFile file, 25 void Init(base::PlatformFile file,
25 const std::vector<std::string>& custom_words); 26 const std::vector<std::string>& custom_words);
26 27
27 virtual bool InitializeIfNeeded() OVERRIDE; 28 virtual bool InitializeIfNeeded() OVERRIDE;
28 virtual bool IsEnabled() OVERRIDE; 29 virtual bool IsEnabled() OVERRIDE;
29 virtual bool CheckSpelling(const string16& word_to_check, int tag) OVERRIDE; 30 virtual bool CheckSpelling(const string16& word_to_check, int tag) OVERRIDE;
30 virtual void FillSuggestionList(const string16& wrong_word, 31 virtual void FillSuggestionList(const string16& wrong_word,
31 std::vector<string16>* optional_suggestions) OVERRIDE; 32 std::vector<string16>* optional_suggestions) OVERRIDE;
32 virtual void OnWordAdded(const std::string& word) OVERRIDE; 33 virtual void OnWordAdded(const std::string& word) OVERRIDE;
34 virtual void OnWordRemoved(const std::string& word) OVERRIDE;
35
33 private: 36 private:
34 // Initializes the Hunspell dictionary, or does nothing if |hunspell_| is 37 // Initializes the Hunspell dictionary, or does nothing if |hunspell_| is
35 // non-null. This blocks. 38 // non-null. This blocks.
36 void InitializeHunspell(); 39 void InitializeHunspell();
37 40
38 // Add the given custom word to |hunspell_|. 41 // Add the given custom word to |hunspell_|.
39 void AddWordToHunspell(const std::string& word); 42 void AddWordToHunspell(const std::string& word);
40 43
44 // Remove the given custom word from |hunspell_|.
45 void RemoveWordFromHunspell(const std::string& word);
46
41 // We memory-map the BDict file. 47 // We memory-map the BDict file.
42 scoped_ptr<file_util::MemoryMappedFile> bdict_file_; 48 scoped_ptr<file_util::MemoryMappedFile> bdict_file_;
43 49
44 // The hunspell dictionary in use. 50 // The hunspell dictionary in use.
45 scoped_ptr<Hunspell> hunspell_; 51 scoped_ptr<Hunspell> hunspell_;
46 52
47 std::vector<std::string> custom_words_; 53 chrome::spellcheck_common::WordList custom_words_;
48 54
49 base::PlatformFile file_; 55 base::PlatformFile file_;
50 56
51 // This flags is true if we have been intialized. 57 // This flags is true if we have been intialized.
52 // The value indicates whether we should request a 58 // The value indicates whether we should request a
53 // dictionary from the browser when the render view asks us to check the 59 // dictionary from the browser when the render view asks us to check the
54 // spelling of a word. 60 // spelling of a word.
55 bool initialized_; 61 bool initialized_;
56 62
57 // This flags is true if we have requested dictionary. 63 // This flags is true if we have requested dictionary.
58 bool dictionary_requested_; 64 bool dictionary_requested_;
59 65
60 }; 66 };
61 67
62 #endif // CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_ 68 #endif // CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_
63 69
OLDNEW
« no previous file with comments | « chrome/renderer/spellchecker/cocoa_spelling_engine_mac.cc ('k') | chrome/renderer/spellchecker/hunspell_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698