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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 DICT_HUNSPELL, | 57 DICT_HUNSPELL, |
58 DICT_TEXT, | 58 DICT_TEXT, |
59 DICT_UNKNOWN, | 59 DICT_UNKNOWN, |
60 }; | 60 }; |
61 | 61 |
62 explicit SpellcheckService(content::BrowserContext* context); | 62 explicit SpellcheckService(content::BrowserContext* context); |
63 ~SpellcheckService() override; | 63 ~SpellcheckService() override; |
64 | 64 |
65 base::WeakPtr<SpellcheckService> GetWeakPtr(); | 65 base::WeakPtr<SpellcheckService> GetWeakPtr(); |
66 | 66 |
67 // This function computes a vector of strings which are to be displayed in | 67 #if !defined(OS_MACOSX) |
68 // the context menu over a text area for changing spell check languages. It | 68 // Computes |languages| to display in the context menu over a text area for |
69 // returns the index of the current spell check language in the vector. | 69 // changing spellcheck languages. Returns the number of languages that are |
| 70 // enabled, which are always at the beginning of |languages|. |
70 // TODO(port): this should take a vector of base::string16, but the | 71 // TODO(port): this should take a vector of base::string16, but the |
71 // implementation has some dependencies in l10n util that need porting first. | 72 // implementation has some dependencies in l10n util that need porting first. |
72 static int GetSpellCheckLanguages(base::SupportsUserData* context, | 73 static size_t GetSpellCheckLanguages(base::SupportsUserData* context, |
73 std::vector<std::string>* languages); | 74 std::vector<std::string>* languages); |
| 75 #endif // !OS_MACOSX |
74 | 76 |
75 // Signals the event attached by AttachTestEvent() to report the specified | 77 // Signals the event attached by AttachTestEvent() to report the specified |
76 // event to browser tests. This function is called by this class and its | 78 // event to browser tests. This function is called by this class and its |
77 // derived classes to report their status. This function does not do anything | 79 // derived classes to report their status. This function does not do anything |
78 // when we do not set an event to |status_event_|. | 80 // when we do not set an event to |status_event_|. |
79 static bool SignalStatusEvent(EventType type); | 81 static bool SignalStatusEvent(EventType type); |
80 | 82 |
81 // Instantiates SpellCheckHostMetrics object and makes it ready for recording | 83 // Instantiates SpellCheckHostMetrics object and makes it ready for recording |
82 // metrics. This should be called only if the metrics recording is active. | 84 // metrics. This should be called only if the metrics recording is active. |
83 void StartRecordingMetrics(bool spellcheck_enabled); | 85 void StartRecordingMetrics(bool spellcheck_enabled); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // Returns the status event type. | 137 // Returns the status event type. |
136 static EventType GetStatusEvent(); | 138 static EventType GetStatusEvent(); |
137 | 139 |
138 // Pass all renderers some basic initialization information. | 140 // Pass all renderers some basic initialization information. |
139 void InitForAllRenderers(); | 141 void InitForAllRenderers(); |
140 | 142 |
141 // Reacts to a change in user preferences on whether auto-spell-correct should | 143 // Reacts to a change in user preferences on whether auto-spell-correct should |
142 // be enabled. | 144 // be enabled. |
143 void OnEnableAutoSpellCorrectChanged(); | 145 void OnEnableAutoSpellCorrectChanged(); |
144 | 146 |
145 // Reacts to a change in user preference on which language should be used for | 147 // Reacts to a change in user preference on which languages should be used for |
146 // spellchecking. | 148 // spellchecking. |
147 void OnSpellCheckDictionaryChanged(); | 149 void OnSpellCheckDictionariesChanged(); |
148 | 150 |
149 // Notification handler for changes to prefs::kSpellCheckUseSpellingService. | 151 // Notification handler for changes to prefs::kSpellCheckUseSpellingService. |
150 void OnUseSpellingServiceChanged(); | 152 void OnUseSpellingServiceChanged(); |
151 | 153 |
152 // Enables the feedback sender if spelling server is available and enabled. | 154 // Enables the feedback sender if spelling server is available and enabled. |
153 // Otherwise disables the feedback sender. | 155 // Otherwise disables the feedback sender. |
154 void UpdateFeedbackSenderState(); | 156 void UpdateFeedbackSenderState(); |
155 | 157 |
156 PrefChangeRegistrar pref_change_registrar_; | 158 PrefChangeRegistrar pref_change_registrar_; |
157 content::NotificationRegistrar registrar_; | 159 content::NotificationRegistrar registrar_; |
158 | 160 |
159 // A pointer to the BrowserContext which this service refers to. | 161 // A pointer to the BrowserContext which this service refers to. |
160 content::BrowserContext* context_; | 162 content::BrowserContext* context_; |
161 | 163 |
162 scoped_ptr<SpellCheckHostMetrics> metrics_; | 164 scoped_ptr<SpellCheckHostMetrics> metrics_; |
163 | 165 |
164 scoped_ptr<SpellcheckCustomDictionary> custom_dictionary_; | 166 scoped_ptr<SpellcheckCustomDictionary> custom_dictionary_; |
165 | 167 |
166 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; | 168 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; |
167 | 169 |
168 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; | 170 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; |
169 | 171 |
170 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; | 172 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; |
171 | 173 |
172 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); | 174 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); |
173 }; | 175 }; |
174 | 176 |
175 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ | 177 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ |
OLD | NEW |