| OLD | NEW |
| 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 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 class Observer { | 68 class Observer { |
| 69 public: | 69 public: |
| 70 // Called when the custom dictionary has been loaded. | 70 // Called when the custom dictionary has been loaded. |
| 71 virtual void OnCustomDictionaryLoaded() = 0; | 71 virtual void OnCustomDictionaryLoaded() = 0; |
| 72 | 72 |
| 73 // Called when the custom dictionary has been changed. | 73 // Called when the custom dictionary has been changed. |
| 74 virtual void OnCustomDictionaryChanged(const Change& dictionary_change) = 0; | 74 virtual void OnCustomDictionaryChanged(const Change& dictionary_change) = 0; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 explicit SpellcheckCustomDictionary(const base::FilePath& path); | 77 explicit SpellcheckCustomDictionary(const base::FilePath& path); |
| 78 virtual ~SpellcheckCustomDictionary(); | 78 ~SpellcheckCustomDictionary() override; |
| 79 | 79 |
| 80 // Returns the in-memory cache of words in the custom dictionary. | 80 // Returns the in-memory cache of words in the custom dictionary. |
| 81 const chrome::spellcheck_common::WordSet& GetWords() const; | 81 const chrome::spellcheck_common::WordSet& GetWords() const; |
| 82 | 82 |
| 83 // Adds |word| to the dictionary, schedules a write to disk, and notifies | 83 // Adds |word| to the dictionary, schedules a write to disk, and notifies |
| 84 // observers of the change. Returns true if |word| is valid and not a | 84 // observers of the change. Returns true if |word| is valid and not a |
| 85 // duplicate. Otherwise returns false. | 85 // duplicate. Otherwise returns false. |
| 86 bool AddWord(const std::string& word); | 86 bool AddWord(const std::string& word); |
| 87 | 87 |
| 88 // Removes |word| from the dictionary, schedules a write to disk, and notifies | 88 // Removes |word| from the dictionary, schedules a write to disk, and notifies |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 // Removes |observer| to stop notifications of dictionary events and changes. | 99 // Removes |observer| to stop notifications of dictionary events and changes. |
| 100 void RemoveObserver(Observer* observer); | 100 void RemoveObserver(Observer* observer); |
| 101 | 101 |
| 102 // Returns true if the dictionary has been loaded. Otherwise returns false. | 102 // Returns true if the dictionary has been loaded. Otherwise returns false. |
| 103 bool IsLoaded(); | 103 bool IsLoaded(); |
| 104 | 104 |
| 105 // Returns true if the dictionary is being synced. Otherwise returns false. | 105 // Returns true if the dictionary is being synced. Otherwise returns false. |
| 106 bool IsSyncing(); | 106 bool IsSyncing(); |
| 107 | 107 |
| 108 // Overridden from SpellcheckDictionary: | 108 // Overridden from SpellcheckDictionary: |
| 109 virtual void Load() override; | 109 void Load() override; |
| 110 | 110 |
| 111 // Overridden from syncer::SyncableService: | 111 // Overridden from syncer::SyncableService: |
| 112 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 112 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 113 syncer::ModelType type, | 113 syncer::ModelType type, |
| 114 const syncer::SyncDataList& initial_sync_data, | 114 const syncer::SyncDataList& initial_sync_data, |
| 115 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 115 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 116 scoped_ptr<syncer::SyncErrorFactory> sync_error_handler) override; | 116 scoped_ptr<syncer::SyncErrorFactory> sync_error_handler) override; |
| 117 virtual void StopSyncing(syncer::ModelType type) override; | 117 void StopSyncing(syncer::ModelType type) override; |
| 118 virtual syncer::SyncDataList GetAllSyncData( | 118 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 119 syncer::ModelType type) const override; | 119 syncer::SyncError ProcessSyncChanges( |
| 120 virtual syncer::SyncError ProcessSyncChanges( | |
| 121 const tracked_objects::Location& from_here, | 120 const tracked_objects::Location& from_here, |
| 122 const syncer::SyncChangeList& change_list) override; | 121 const syncer::SyncChangeList& change_list) override; |
| 123 | 122 |
| 124 private: | 123 private: |
| 125 friend class DictionarySyncIntegrationTestHelper; | 124 friend class DictionarySyncIntegrationTestHelper; |
| 126 friend class SpellcheckCustomDictionaryTest; | 125 friend class SpellcheckCustomDictionaryTest; |
| 127 | 126 |
| 128 // Returns the list of words in the custom spellcheck dictionary at |path|. | 127 // Returns the list of words in the custom spellcheck dictionary at |path|. |
| 129 // Makes sure that the custom dictionary file does not have duplicates and | 128 // Makes sure that the custom dictionary file does not have duplicates and |
| 130 // contains only valid words. | 129 // contains only valid words. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // True if the dictionary has been loaded. Otherwise false. | 177 // True if the dictionary has been loaded. Otherwise false. |
| 179 bool is_loaded_; | 178 bool is_loaded_; |
| 180 | 179 |
| 181 // Used to create weak pointers for an instance of this class. | 180 // Used to create weak pointers for an instance of this class. |
| 182 base::WeakPtrFactory<SpellcheckCustomDictionary> weak_ptr_factory_; | 181 base::WeakPtrFactory<SpellcheckCustomDictionary> weak_ptr_factory_; |
| 183 | 182 |
| 184 DISALLOW_COPY_AND_ASSIGN(SpellcheckCustomDictionary); | 183 DISALLOW_COPY_AND_ASSIGN(SpellcheckCustomDictionary); |
| 185 }; | 184 }; |
| 186 | 185 |
| 187 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_CUSTOM_DICTIONARY_H_ | 186 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_CUSTOM_DICTIONARY_H_ |
| OLD | NEW |