Chromium Code Reviews| Index: chrome/browser/spellchecker/spellcheck_custom_dictionary.h |
| diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary.h b/chrome/browser/spellchecker/spellcheck_custom_dictionary.h |
| index 939a349e9f9558171afce10918fc2fd28d438383..510c98eda7c5f8214430672f564eb30917a609e6 100644 |
| --- a/chrome/browser/spellchecker/spellcheck_custom_dictionary.h |
| +++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary.h |
| @@ -17,37 +17,68 @@ |
| // Defines a custom dictionary which users can add their own words to. |
| class SpellcheckCustomDictionary : public SpellcheckDictionary { |
| public: |
| + class Observer { |
| + public: |
| + virtual void OnCustomDictionaryLoaded() = 0; |
| + virtual void OnCustomDictionaryWordAdded(const std::string& word) = 0; |
| + virtual void OnCustomDictionaryWordRemoved(const std::string& word) = 0; |
| + }; |
| + |
| explicit SpellcheckCustomDictionary(Profile* profile); |
| virtual ~SpellcheckCustomDictionary(); |
| + // Overridden from SpellcheckDictionary: |
| virtual void Load() OVERRIDE; |
| - void WriteWordToCustomDictionary(const std::string& word); |
| - // Returns true if successful. False otherwise. Takes ownership of |
| - // custom_words and replaces pointer with an empty vector. |
| - bool SetCustomWordList(chrome::spellcheck_common::WordList* custom_words); |
| - const chrome::spellcheck_common::WordList& GetCustomWords() const; |
| - void CustomWordAddedLocally(const std::string& word); |
| + const chrome::spellcheck_common::WordList& GetWords() const; |
| + |
| + // Returns a newly allocated list of words read from custom dictionary file. |
|
rpetterson
2012/11/14 19:47:09
Who owns this new list? Can you add that to the co
please use gerrit instead
2012/11/14 22:54:46
The caller owns this new list. Added to the commen
|
| + chrome::spellcheck_common::WordList* LoadDictionary(); |
| + |
| void LoadDictionaryIntoCustomWordList( |
| chrome::spellcheck_common::WordList* custom_words); |
| + // The reply point for PostTaskAndReplyWithResult. Called when LoadDictionary |
| + // is finished reading words from custom dictionary file. Takes ownership of |
| + // custom_words and replaces pointer with an empty vector. |
| + void SetCustomWordList(chrome::spellcheck_common::WordList* custom_words); |
| + |
| // Adds the given word to the custom words list and inform renderer of the |
| // update. |
| void AddWord(const std::string& word); |
| + void CustomWordAddedLocally(const std::string& word); |
| + void WriteWordToCustomDictionary(const std::string& word); |
| + |
| // The reply point for PostTaskAndReply. Called when AddWord is finished |
| // adding a word in the background. |
| void AddWordComplete(const std::string& word); |
| + // Removes the given word from the custom words list and inform renderer of |
| + // the update. |
| + void RemoveWord(const std::string& word); |
| + |
| + void CustomWordRemovedLocally(const std::string& word); |
| + void EraseWordFromCustomDictionary(const std::string& word); |
| + |
| + // The reply point for PostTaskAndReply. Called when RemoveWord is finished |
| + // removing a word in the background. |
| + void RemoveWordComplete(const std::string& word); |
| + |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| private: |
| // In-memory cache of the custom words file. |
| - chrome::spellcheck_common::WordList custom_words_; |
| + chrome::spellcheck_common::WordList words_; |
| // A path for custom dictionary per profile. |
| FilePath custom_dictionary_path_; |
| base::WeakPtrFactory<SpellcheckCustomDictionary> weak_ptr_factory_; |
| + std::vector<Observer*> observers_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(SpellcheckCustomDictionary); |
| }; |