| 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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ | 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class SupportsUserData; | 30 class SupportsUserData; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace content { | 33 namespace content { |
| 34 class RenderProcessHost; | 34 class RenderProcessHost; |
| 35 class BrowserContext; | 35 class BrowserContext; |
| 36 class NotificationDetails; | 36 class NotificationDetails; |
| 37 class NotificationSource; | 37 class NotificationSource; |
| 38 } | 38 } |
| 39 | 39 |
| 40 namespace spellcheck { | |
| 41 class FeedbackSender; | |
| 42 } | |
| 43 | |
| 44 // Encapsulates the browser side spellcheck service. There is one of these per | 40 // Encapsulates the browser side spellcheck service. There is one of these per |
| 45 // profile and each is created by the SpellCheckServiceFactory. The | 41 // profile and each is created by the SpellCheckServiceFactory. The |
| 46 // SpellcheckService maintains any per-profile information about spellcheck. | 42 // SpellcheckService maintains any per-profile information about spellcheck. |
| 47 class SpellcheckService : public KeyedService, | 43 class SpellcheckService : public KeyedService, |
| 48 public content::NotificationObserver, | 44 public content::NotificationObserver, |
| 49 public SpellcheckCustomDictionary::Observer, | 45 public SpellcheckCustomDictionary::Observer, |
| 50 public SpellcheckHunspellDictionary::Observer { | 46 public SpellcheckHunspellDictionary::Observer { |
| 51 public: | 47 public: |
| 52 // Event types used for reporting the status of this class and its derived | 48 // Event types used for reporting the status of this class and its derived |
| 53 // classes to browser tests. | 49 // classes to browser tests. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 104 |
| 109 // Returns the instance of the custom dictionary. | 105 // Returns the instance of the custom dictionary. |
| 110 SpellcheckCustomDictionary* GetCustomDictionary(); | 106 SpellcheckCustomDictionary* GetCustomDictionary(); |
| 111 | 107 |
| 112 // Starts the process of loading the Hunspell dictionaries. | 108 // Starts the process of loading the Hunspell dictionaries. |
| 113 void LoadHunspellDictionaries(); | 109 void LoadHunspellDictionaries(); |
| 114 | 110 |
| 115 // Returns the instance of the vector of Hunspell dictionaries. | 111 // Returns the instance of the vector of Hunspell dictionaries. |
| 116 const ScopedVector<SpellcheckHunspellDictionary>& GetHunspellDictionaries(); | 112 const ScopedVector<SpellcheckHunspellDictionary>& GetHunspellDictionaries(); |
| 117 | 113 |
| 118 // Returns the instance of the spelling service feedback sender. | |
| 119 spellcheck::FeedbackSender* GetFeedbackSender(); | |
| 120 | |
| 121 // Load a dictionary from a given path. Format specifies how the dictionary | 114 // Load a dictionary from a given path. Format specifies how the dictionary |
| 122 // is stored. Return value is true if successful. | 115 // is stored. Return value is true if successful. |
| 123 bool LoadExternalDictionary(std::string language, | 116 bool LoadExternalDictionary(std::string language, |
| 124 std::string locale, | 117 std::string locale, |
| 125 std::string path, | 118 std::string path, |
| 126 DictionaryFormat format); | 119 DictionaryFormat format); |
| 127 | 120 |
| 128 // Unload a dictionary. The path is given to identify the dictionary. | 121 // Unload a dictionary. The path is given to identify the dictionary. |
| 129 // Return value is true if successful. | 122 // Return value is true if successful. |
| 130 bool UnloadExternalDictionary(const std::string& /* path */); | 123 bool UnloadExternalDictionary(const std::string& /* path */); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 void OnSpellCheckDictionariesChanged(); | 157 void OnSpellCheckDictionariesChanged(); |
| 165 | 158 |
| 166 // Notification handler for changes to prefs::kSpellCheckUseSpellingService. | 159 // Notification handler for changes to prefs::kSpellCheckUseSpellingService. |
| 167 void OnUseSpellingServiceChanged(); | 160 void OnUseSpellingServiceChanged(); |
| 168 | 161 |
| 169 // Notification handler for changes to prefs::kAcceptLanguages. Removes from | 162 // Notification handler for changes to prefs::kAcceptLanguages. Removes from |
| 170 // prefs::kSpellCheckDictionaries any languages that are not in | 163 // prefs::kSpellCheckDictionaries any languages that are not in |
| 171 // prefs::kAcceptLanguages. | 164 // prefs::kAcceptLanguages. |
| 172 void OnAcceptLanguagesChanged(); | 165 void OnAcceptLanguagesChanged(); |
| 173 | 166 |
| 174 // Enables the feedback sender if spelling server is available and enabled. | |
| 175 // Otherwise disables the feedback sender. | |
| 176 void UpdateFeedbackSenderState(); | |
| 177 | |
| 178 PrefChangeRegistrar pref_change_registrar_; | 167 PrefChangeRegistrar pref_change_registrar_; |
| 179 content::NotificationRegistrar registrar_; | 168 content::NotificationRegistrar registrar_; |
| 180 | 169 |
| 181 // A pointer to the BrowserContext which this service refers to. | 170 // A pointer to the BrowserContext which this service refers to. |
| 182 content::BrowserContext* context_; | 171 content::BrowserContext* context_; |
| 183 | 172 |
| 184 std::unique_ptr<SpellCheckHostMetrics> metrics_; | 173 std::unique_ptr<SpellCheckHostMetrics> metrics_; |
| 185 | 174 |
| 186 std::unique_ptr<SpellcheckCustomDictionary> custom_dictionary_; | 175 std::unique_ptr<SpellcheckCustomDictionary> custom_dictionary_; |
| 187 | 176 |
| 188 ScopedVector<SpellcheckHunspellDictionary> hunspell_dictionaries_; | 177 ScopedVector<SpellcheckHunspellDictionary> hunspell_dictionaries_; |
| 189 | 178 |
| 190 std::unique_ptr<spellcheck::FeedbackSender> feedback_sender_; | |
| 191 | |
| 192 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; | 179 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; |
| 193 | 180 |
| 194 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); | 181 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); |
| 195 }; | 182 }; |
| 196 | 183 |
| 197 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ | 184 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ |
| OLD | NEW |