| 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..e58377b49a8ec98632e95aca5ee7d94afd5b9247 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,28 @@ 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.
|
| + // word_list is loaded in LoadCustomDictionaryOnFileThread,
|
| + // and the method transfers its ownership to this method.
|
| + // After the ownership is transferred, word_list should be
|
| + // touched only in UI thread, and it will be deleted
|
| + // when a new word_list is trasferred or when this object is deleted.
|
| + 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 +114,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 +137,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_;
|
|
|
|
|