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" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 }; | 53 }; |
54 | 54 |
55 explicit SpellcheckService(content::BrowserContext* context); | 55 explicit SpellcheckService(content::BrowserContext* context); |
56 virtual ~SpellcheckService(); | 56 virtual ~SpellcheckService(); |
57 | 57 |
58 // This function computes a vector of strings which are to be displayed in | 58 // This function computes a vector of strings which are to be displayed in |
59 // the context menu over a text area for changing spell check languages. It | 59 // the context menu over a text area for changing spell check languages. It |
60 // returns the index of the current spell check language in the vector. | 60 // returns the index of the current spell check language in the vector. |
61 // TODO(port): this should take a vector of base::string16, but the | 61 // TODO(port): this should take a vector of base::string16, but the |
62 // implementation has some dependencies in l10n util that need porting first. | 62 // implementation has some dependencies in l10n util that need porting first. |
63 static int GetSpellCheckLanguages(content::BrowserContext* context, | 63 static std::set<int> GetSpellCheckLanguages( |
64 std::vector<std::string>* languages); | 64 content::BrowserContext* context, |
| 65 std::vector<std::string>* languages); |
65 | 66 |
66 // Computes a vector of strings which are to be displayed in the context | 67 // Computes a vector of strings which are to be displayed in the context |
67 // menu from |accept_languages| and |dictionary_language|. | 68 // menu from |accept_languages| and |dictionary_language|. |
68 static void GetSpellCheckLanguagesFromAcceptLanguages( | 69 static void GetSpellCheckLanguagesFromAcceptLanguages( |
69 const std::vector<std::string>& accept_languages, | 70 const std::vector<std::string>& accept_languages, |
70 const std::string& dictionary_language, | |
71 std::vector<std::string>* languages); | 71 std::vector<std::string>* languages); |
72 | 72 |
73 // Signals the event attached by AttachTestEvent() to report the specified | 73 // Signals the event attached by AttachTestEvent() to report the specified |
74 // event to browser tests. This function is called by this class and its | 74 // event to browser tests. This function is called by this class and its |
75 // derived classes to report their status. This function does not do anything | 75 // derived classes to report their status. This function does not do anything |
76 // when we do not set an event to |status_event_|. | 76 // when we do not set an event to |status_event_|. |
77 static bool SignalStatusEvent(EventType type); | 77 static bool SignalStatusEvent(EventType type); |
78 | 78 |
79 // Instantiates SpellCheckHostMetrics object and makes it ready for recording | 79 // Instantiates SpellCheckHostMetrics object and makes it ready for recording |
80 // metrics. This should be called only if the metrics recording is active. | 80 // metrics. This should be called only if the metrics recording is active. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 // SpellcheckHunspellDictionary::Observer implementation. | 121 // SpellcheckHunspellDictionary::Observer implementation. |
122 virtual void OnHunspellDictionaryInitialized() override; | 122 virtual void OnHunspellDictionaryInitialized() override; |
123 virtual void OnHunspellDictionaryDownloadBegin() override; | 123 virtual void OnHunspellDictionaryDownloadBegin() override; |
124 virtual void OnHunspellDictionaryDownloadSuccess() override; | 124 virtual void OnHunspellDictionaryDownloadSuccess() override; |
125 virtual void OnHunspellDictionaryDownloadFailure() override; | 125 virtual void OnHunspellDictionaryDownloadFailure() override; |
126 | 126 |
127 private: | 127 private: |
128 FRIEND_TEST_ALL_PREFIXES(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT); | 128 FRIEND_TEST_ALL_PREFIXES(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT); |
129 | 129 |
| 130 static std::vector<std::string> GetAcceptLanguages(PrefService* prefs); |
| 131 static std::vector<std::string> GetSpellCheckDictionaryLanguages( |
| 132 PrefService* prefs); |
| 133 |
130 // Attaches an event so browser tests can listen the status events. | 134 // Attaches an event so browser tests can listen the status events. |
131 static void AttachStatusEvent(base::WaitableEvent* status_event); | 135 static void AttachStatusEvent(base::WaitableEvent* status_event); |
132 | 136 |
133 // Returns the status event type. | 137 // Returns the status event type. |
134 static EventType GetStatusEvent(); | 138 static EventType GetStatusEvent(); |
135 | 139 |
136 // Pass all renderers some basic initialization information. | 140 // Pass all renderers some basic initialization information. |
137 void InitForAllRenderers(); | 141 void InitForAllRenderers(); |
138 | 142 |
139 // 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 |
(...skipping 24 matching lines...) Expand all Loading... |
164 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; | 168 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; |
165 | 169 |
166 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; | 170 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; |
167 | 171 |
168 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; | 172 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; |
169 | 173 |
170 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); | 174 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); |
171 }; | 175 }; |
172 | 176 |
173 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ | 177 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ |
OLD | NEW |