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 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/prefs/pref_change_registrar.h" | 15 #include "base/prefs/pref_change_registrar.h" |
16 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" | 16 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" |
17 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" | 17 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" |
18 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
21 | 21 |
22 class SpellCheckHostMetrics; | 22 class SpellCheckHostMetrics; |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 class WaitableEvent; | 25 class WaitableEvent; |
26 class SupportsUserData; | |
26 } | 27 } |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 class RenderProcessHost; | 30 class RenderProcessHost; |
30 class BrowserContext; | 31 class BrowserContext; |
31 class NotificationDetails; | 32 class NotificationDetails; |
32 class NotificationSource; | 33 class NotificationSource; |
33 } | 34 } |
34 | 35 |
35 namespace spellcheck { | 36 namespace spellcheck { |
(...skipping 20 matching lines...) Expand all Loading... | |
56 DICT_HUNSPELL, | 57 DICT_HUNSPELL, |
57 DICT_TEXT, | 58 DICT_TEXT, |
58 DICT_UNKNOWN, | 59 DICT_UNKNOWN, |
59 }; | 60 }; |
60 | 61 |
61 explicit SpellcheckService(content::BrowserContext* context); | 62 explicit SpellcheckService(content::BrowserContext* context); |
62 ~SpellcheckService() override; | 63 ~SpellcheckService() override; |
63 | 64 |
64 base::WeakPtr<SpellcheckService> GetWeakPtr(); | 65 base::WeakPtr<SpellcheckService> GetWeakPtr(); |
65 | 66 |
66 // This function computes a vector of strings which are to be displayed in | 67 #if !defined(OS_MACOSX) |
67 // 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 |
68 // 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|. | |
69 // 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 |
70 // implementation has some dependencies in l10n util that need porting first. | 72 // implementation has some dependencies in l10n util that need porting first. |
71 static int GetSpellCheckLanguages(content::BrowserContext* context, | 73 static size_t GetSpellCheckLanguages(base::SupportsUserData* context, |
72 std::vector<std::string>* languages); | 74 std::vector<std::string>* languages); |
73 | 75 #endif |
74 // Computes a vector of strings which are to be displayed in the context | |
75 // menu from |accept_languages| and |dictionary_language|. | |
76 static void GetSpellCheckLanguagesFromAcceptLanguages( | |
77 const std::vector<std::string>& accept_languages, | |
78 const std::string& dictionary_language, | |
79 std::vector<std::string>* languages); | |
80 | 76 |
81 // Signals the event attached by AttachTestEvent() to report the specified | 77 // Signals the event attached by AttachTestEvent() to report the specified |
82 // 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 |
83 // 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 |
84 // when we do not set an event to |status_event_|. | 80 // when we do not set an event to |status_event_|. |
85 static bool SignalStatusEvent(EventType type); | 81 static bool SignalStatusEvent(EventType type); |
86 | 82 |
87 // Instantiates SpellCheckHostMetrics object and makes it ready for recording | 83 // Instantiates SpellCheckHostMetrics object and makes it ready for recording |
88 // 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. |
89 void StartRecordingMetrics(bool spellcheck_enabled); | 85 void StartRecordingMetrics(bool spellcheck_enabled); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 // Returns the status event type. | 137 // Returns the status event type. |
142 static EventType GetStatusEvent(); | 138 static EventType GetStatusEvent(); |
143 | 139 |
144 // Pass all renderers some basic initialization information. | 140 // Pass all renderers some basic initialization information. |
145 void InitForAllRenderers(); | 141 void InitForAllRenderers(); |
146 | 142 |
147 // 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 |
148 // be enabled. | 144 // be enabled. |
149 void OnEnableAutoSpellCorrectChanged(); | 145 void OnEnableAutoSpellCorrectChanged(); |
150 | 146 |
151 // Reacts to a change in user preference on which language should be used for | 147 // Reacts to a change in user preference on which language should be used for |
please use gerrit instead
2015/06/23 00:43:06
Move the comment inside of #if
Julius
2015/06/24 21:17:59
Done.
| |
152 // spellchecking. | 148 // spellchecking. |
149 #if !defined(OS_MACOSX) | |
153 void OnSpellCheckDictionaryChanged(); | 150 void OnSpellCheckDictionaryChanged(); |
151 #endif | |
154 | 152 |
155 // Notification handler for changes to prefs::kSpellCheckUseSpellingService. | 153 // Notification handler for changes to prefs::kSpellCheckUseSpellingService. |
156 void OnUseSpellingServiceChanged(); | 154 void OnUseSpellingServiceChanged(); |
157 | 155 |
158 // Enables the feedback sender if spelling server is available and enabled. | 156 // Enables the feedback sender if spelling server is available and enabled. |
159 // Otherwise disables the feedback sender. | 157 // Otherwise disables the feedback sender. |
160 void UpdateFeedbackSenderState(); | 158 void UpdateFeedbackSenderState(); |
161 | 159 |
162 PrefChangeRegistrar pref_change_registrar_; | 160 PrefChangeRegistrar pref_change_registrar_; |
163 content::NotificationRegistrar registrar_; | 161 content::NotificationRegistrar registrar_; |
164 | 162 |
165 // A pointer to the BrowserContext which this service refers to. | 163 // A pointer to the BrowserContext which this service refers to. |
166 content::BrowserContext* context_; | 164 content::BrowserContext* context_; |
167 | 165 |
168 scoped_ptr<SpellCheckHostMetrics> metrics_; | 166 scoped_ptr<SpellCheckHostMetrics> metrics_; |
169 | 167 |
170 scoped_ptr<SpellcheckCustomDictionary> custom_dictionary_; | 168 scoped_ptr<SpellcheckCustomDictionary> custom_dictionary_; |
171 | 169 |
172 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; | 170 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; |
173 | 171 |
174 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; | 172 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; |
175 | 173 |
176 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; | 174 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; |
177 | 175 |
178 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); | 176 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); |
179 }; | 177 }; |
180 | 178 |
181 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ | 179 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ |
OLD | NEW |