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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_custom_dictionary.h

Issue 11293241: Cleaning up the custom dictionary code relative to the SpellcheckService to make the custom diction… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/spellchecker/spellcheck_custom_dictionary.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BROWSER_SPELLCHECKER_SPELLCHECK_CUSTOM_DICTIONARY_H_ 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_CUSTOM_DICTIONARY_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_CUSTOM_DICTIONARY_H_ 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_CUSTOM_DICTIONARY_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/spellchecker/spellcheck_dictionary.h" 14 #include "chrome/browser/spellchecker/spellcheck_dictionary.h"
14 #include "chrome/common/spellcheck_common.h" 15 #include "chrome/common/spellcheck_common.h"
15 16
16 // Defines a custom dictionary which users can add their own words to. 17 // Defines a custom dictionary which users can add their own words to.
17 class SpellcheckCustomDictionary : public SpellcheckDictionary { 18 class SpellcheckCustomDictionary : public SpellcheckDictionary {
18 public: 19 public:
19 explicit SpellcheckCustomDictionary(Profile* profile); 20 explicit SpellcheckCustomDictionary(Profile* profile);
20 virtual ~SpellcheckCustomDictionary(); 21 virtual ~SpellcheckCustomDictionary();
21 22
22 virtual void Load() OVERRIDE; 23 virtual void Load() OVERRIDE;
23 void WriteWordToCustomDictionary(const std::string& word); 24 void WriteWordToCustomDictionary(const std::string& word);
24 25
25 // Returns true if successful. False otherwise. Takes ownership of 26 // Returns true if successful. False otherwise. Takes ownership of
26 // custom_words and replaces pointer with an empty vector. 27 // custom_words and replaces pointer with an empty vector.
27 bool SetCustomWordList(chrome::spellcheck_common::WordList* custom_words); 28 bool SetCustomWordList(chrome::spellcheck_common::WordList* custom_words);
28 const chrome::spellcheck_common::WordList& GetCustomWords() const; 29 const chrome::spellcheck_common::WordList& GetCustomWords() const;
29 void CustomWordAddedLocally(const std::string& word); 30 void CustomWordAddedLocally(const std::string& word);
30 void LoadDictionaryIntoCustomWordList( 31 void LoadDictionaryIntoCustomWordList(
31 chrome::spellcheck_common::WordList* custom_words); 32 chrome::spellcheck_common::WordList* custom_words);
32 33
34 // Adds the given word to the custom words list and inform renderer of the
35 // update.
36 void AddWord(const std::string& word);
37
38 // The reply point for PostTaskAndReply. Called when AddWord is finished
39 // adding a word in the background.
40 void AddWordComplete(const std::string& word);
41
33 private: 42 private:
34 // In-memory cache of the custom words file. 43 // In-memory cache of the custom words file.
35 chrome::spellcheck_common::WordList custom_words_; 44 chrome::spellcheck_common::WordList custom_words_;
36 45
37 // A path for custom dictionary per profile. 46 // A path for custom dictionary per profile.
38 FilePath custom_dictionary_path_; 47 FilePath custom_dictionary_path_;
39 48
49 base::WeakPtrFactory<SpellcheckCustomDictionary> weak_ptr_factory_;
50
40 DISALLOW_COPY_AND_ASSIGN(SpellcheckCustomDictionary); 51 DISALLOW_COPY_AND_ASSIGN(SpellcheckCustomDictionary);
41 }; 52 };
42 53
43 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_CUSTOM_DICTIONARY_H_ 54 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_CUSTOM_DICTIONARY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/spellchecker/spellcheck_custom_dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698