From 63271da3b3740aadd3bd5d186bf7bd2b33ee6347 Mon Sep 17 00:00:00 2001 From: "sidchat@google.com" Date: Wed, 17 Sep 2008 20:02:04 +0000 Subject: Add support for "Add to dictionary" in the context menu. Review URL: http://codereview.chromium.org/2446 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2322 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/spellchecker.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'chrome/browser/spellchecker.h') diff --git a/chrome/browser/spellchecker.h b/chrome/browser/spellchecker.h index da17ee5..932d3c9 100644 --- a/chrome/browser/spellchecker.h +++ b/chrome/browser/spellchecker.h @@ -35,9 +35,13 @@ class SpellChecker : public base::RefCountedThreadSafe { // // The request context is used to download dictionaries if they do not exist. // This can be NULL if you don't want this (like in tests). + // The |custom_dictionary_file_name| should be left blank so that Spellchecker + // can figure out the custom dictionary file. It is non empty only for unit + // testing. SpellChecker(const std::wstring& dict_dir, const std::wstring& language, - URLRequestContext* request_context); + URLRequestContext* request_context, + const std::wstring& custom_dictionary_file_name); static void RegisterUserPrefs(PrefService* prefs); @@ -58,6 +62,11 @@ class SpellChecker : public base::RefCountedThreadSafe { int* misspelling_len, std::vector* optional_suggestions); + // Add custom word to the dictionary, which means: + // a) Add it to the current hunspell object for immediate use, + // b) Add the word to a file in disk for custom dictionary. + void AddWord(const std::wstring& word); + private: // Download dictionary files when required. class DictionaryDownloadController; @@ -67,6 +76,10 @@ class SpellChecker : public base::RefCountedThreadSafe { // Initializes the Hunspell Dictionary. bool Initialize(); + // After |hunspell_| is initialized, this function is called to add custom + // words from the custom dictionary to the |hunspell_| + void AddCustomWordsToHunspell(); + void set_file_is_downloading(bool value); // Memory maps the given .bdic file. On success, it will return true and will @@ -80,6 +93,9 @@ class SpellChecker : public base::RefCountedThreadSafe { // Path to the spellchecker file. std::wstring bdict_file_name_; + // Path to the custom dictionary file. + std::wstring custom_dictionary_file_name_; + // We memory-map the BDict file for spellchecking. These are the handles // necessary for that. HANDLE bdict_file_; -- cgit v1.1