| 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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
| 13 #include "chrome/browser/spellchecker/feedback_sender.h" |
| 13 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" | 14 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" |
| 14 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" | 15 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" |
| 15 #include "chrome/common/spellcheck_common.h" | 16 #include "chrome/common/spellcheck_common.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 17 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 19 | 20 |
| 20 class PrefService; | 21 class PrefService; |
| 21 class SpellCheckHostMetrics; | 22 class SpellCheckHostMetrics; |
| 22 | 23 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Returns a metrics counter associated with this object, | 87 // Returns a metrics counter associated with this object, |
| 87 // or null when metrics recording is disabled. | 88 // or null when metrics recording is disabled. |
| 88 SpellCheckHostMetrics* GetMetrics() const; | 89 SpellCheckHostMetrics* GetMetrics() const; |
| 89 | 90 |
| 90 // Returns the instance of the custom dictionary. | 91 // Returns the instance of the custom dictionary. |
| 91 SpellcheckCustomDictionary* GetCustomDictionary(); | 92 SpellcheckCustomDictionary* GetCustomDictionary(); |
| 92 | 93 |
| 93 // Returns the instance of the Hunspell dictionary. | 94 // Returns the instance of the Hunspell dictionary. |
| 94 SpellcheckHunspellDictionary* GetHunspellDictionary(); | 95 SpellcheckHunspellDictionary* GetHunspellDictionary(); |
| 95 | 96 |
| 97 // Returns the instance of the spelling service feedback sender. |
| 98 spellcheck::FeedbackSender* GetFeedbackSender(); |
| 99 |
| 96 // Load a dictionary from a given path. Format specifies how the dictionary | 100 // Load a dictionary from a given path. Format specifies how the dictionary |
| 97 // is stored. Return value is true if successful. | 101 // is stored. Return value is true if successful. |
| 98 bool LoadExternalDictionary(std::string language, | 102 bool LoadExternalDictionary(std::string language, |
| 99 std::string locale, | 103 std::string locale, |
| 100 std::string path, | 104 std::string path, |
| 101 DictionaryFormat format); | 105 DictionaryFormat format); |
| 102 | 106 |
| 103 // Unload a dictionary. The path is given to identify the dictionary. | 107 // Unload a dictionary. The path is given to identify the dictionary. |
| 104 // Return value is true if successful. | 108 // Return value is true if successful. |
| 105 bool UnloadExternalDictionary(std::string path); | 109 bool UnloadExternalDictionary(std::string path); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 136 // be enabled. | 140 // be enabled. |
| 137 void OnEnableAutoSpellCorrectChanged(); | 141 void OnEnableAutoSpellCorrectChanged(); |
| 138 | 142 |
| 139 // Reacts to a change in user preference on which language should be used for | 143 // Reacts to a change in user preference on which language should be used for |
| 140 // spellchecking. | 144 // spellchecking. |
| 141 void OnSpellCheckDictionaryChanged(); | 145 void OnSpellCheckDictionaryChanged(); |
| 142 | 146 |
| 143 // Notification handler for changes to prefs::kSpellCheckUseSpellingService. | 147 // Notification handler for changes to prefs::kSpellCheckUseSpellingService. |
| 144 void OnUseSpellingServiceChanged(); | 148 void OnUseSpellingServiceChanged(); |
| 145 | 149 |
| 150 // Enables the feedback sender if spelling server is available and enabled. |
| 151 // Otherwise disables the feedback sender. |
| 152 void UpdateFeedbackSenderState(); |
| 153 |
| 146 PrefChangeRegistrar pref_change_registrar_; | 154 PrefChangeRegistrar pref_change_registrar_; |
| 147 content::NotificationRegistrar registrar_; | 155 content::NotificationRegistrar registrar_; |
| 148 | 156 |
| 149 // A pointer to the BrowserContext which this service refers to. | 157 // A pointer to the BrowserContext which this service refers to. |
| 150 content::BrowserContext* context_; | 158 content::BrowserContext* context_; |
| 151 | 159 |
| 152 scoped_ptr<SpellCheckHostMetrics> metrics_; | 160 scoped_ptr<SpellCheckHostMetrics> metrics_; |
| 153 | 161 |
| 154 scoped_ptr<SpellcheckCustomDictionary> custom_dictionary_; | 162 scoped_ptr<SpellcheckCustomDictionary> custom_dictionary_; |
| 155 | 163 |
| 156 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; | 164 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; |
| 157 | 165 |
| 166 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; |
| 167 |
| 158 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; | 168 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; |
| 159 | 169 |
| 160 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); | 170 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); |
| 161 }; | 171 }; |
| 162 | 172 |
| 163 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ | 173 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ |
| OLD | NEW |