Index: chrome/browser/spellchecker/spellcheck_profile.h |
diff --git a/chrome/browser/spellchecker/spellcheck_profile.h b/chrome/browser/spellchecker/spellcheck_profile.h |
index 7a7bf0d511aca8cd8ba34b7f3e735de0823670ef..7c35202a47815793bc90120562b1c9a9a4326f0e 100644 |
--- a/chrome/browser/spellchecker/spellcheck_profile.h |
+++ b/chrome/browser/spellchecker/spellcheck_profile.h |
@@ -9,9 +9,12 @@ |
#include <string> |
#include <vector> |
+#include "base/file_path.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/ref_counted.h" |
#include "chrome/browser/spellchecker/spellcheck_profile_provider.h" |
+#include "chrome/common/chrome_constants.h" |
+#include "chrome/common/chrome_paths.h" |
class Profile; |
class SpellCheckHost; |
@@ -39,7 +42,9 @@ class URLRequestContextGetter; |
// The class is intended to be owned and managed by ProfileImpl internally. |
// Any usable APIs are provided by SpellCheckHost interface, |
// which can be retrieved from Profile::GetSpellCheckHost(). |
-class SpellCheckProfile : public SpellCheckProfileProvider { |
+class SpellCheckProfile |
+ : public SpellCheckProfileProvider, |
+ public base::RefCountedThreadSafe<SpellCheckProfile> { |
public: |
// Return value of ReinitializeHost() |
enum ReinitializeResult { |
@@ -57,7 +62,6 @@ class SpellCheckProfile : public SpellCheckProfileProvider { |
}; |
SpellCheckProfile(); |
- virtual ~SpellCheckProfile(); |
// Retrieves SpellCheckHost object. |
// This can return NULL when the spell-checking is disabled |
@@ -81,12 +85,23 @@ class SpellCheckProfile : public SpellCheckProfileProvider { |
// This should be called only if the metrics recording is active. |
void StartRecordingMetrics(bool spellcheck_enabled); |
+ // Removes all words form the in-memory dictionary. This is intended to |
+ // be used in tests. |
+ void ClearCustomWords(); |
+ |
// SpellCheckProfileProvider implementation. |
- virtual void SpellCheckHostInitialized(CustomWordList* custom_words); |
+ virtual void LoadCustomDictionary(); |
+ virtual void SpellCheckHostInitialized(); |
virtual const CustomWordList& GetCustomWords() const; |
virtual void CustomWordAddedLocally(const std::string& word); |
+ // Called when LoadCustomDirectory finished. |
gmorrita
2011/10/12 11:03:36
Could you mention about a lifetime/ownership of wo
|
+ void CustomDictionaryLoaded(CustomWordList* word_list); |
+ |
protected: |
+ friend class base::RefCountedThreadSafe<SpellCheckProfile>; |
+ virtual ~SpellCheckProfile(); |
+ |
// Only tests should override this. |
virtual SpellCheckHost* CreateHost( |
SpellCheckProfileProvider* provider, |
@@ -94,9 +109,22 @@ class SpellCheckProfile : public SpellCheckProfileProvider { |
net::URLRequestContextGetter* request_context, |
SpellCheckHostMetrics* metrics); |
+ virtual void WriteWordToCustomDictionary(const std::string& word); |
+ |
virtual bool IsTesting() const; |
+ // Tests should override this. |
+ virtual FilePath GetCustomDictionaryDir(); |
+ |
private: |
+ // Load a custom dictionary on file thread. |
+ void LoadCustomDictionaryOnFileThread(); |
+ |
+ // Write a custom dictionary addition to disk. |
+ void WriteWordToCustomDictionaryOnFileThread(const std::string& word); |
+ |
+ const FilePath& GetCustomDictionaryFile(); |
+ |
scoped_refptr<SpellCheckHost> host_; |
scoped_ptr<SpellCheckHostMetrics> metrics_; |
@@ -104,6 +132,9 @@ class SpellCheckProfile : public SpellCheckProfileProvider { |
// finished. |
bool host_ready_; |
+ // The location of the custom words file. Empty if not initialized. |
+ FilePath custom_dictionary_file_; |
+ |
// In-memory cache of the custom words file. |
scoped_ptr<CustomWordList> custom_words_; |