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 // Computes |languages| to display in the context menu over a text area for |
67 // the context menu over a text area for changing spell check languages. It | 68 // changing spellcheck languages. Returns the number of languages that are |
68 // returns the index of the current spell check language in the vector. | 69 // enabled, which are always at the beginning of |languages|. |
69 // TODO(port): this should take a vector of base::string16, but the | 70 // TODO(port): this should take a vector of base::string16, but the |
70 // implementation has some dependencies in l10n util that need porting first. | 71 // implementation has some dependencies in l10n util that need porting first. |
71 static int GetSpellCheckLanguages(content::BrowserContext* context, | 72 static size_t GetSpellCheckLanguages(base::SupportsUserData* context, |
72 std::vector<std::string>* languages); | 73 std::vector<std::string>* languages); |
73 | |
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 | 74 |
81 // Signals the event attached by AttachTestEvent() to report the specified | 75 // Signals the event attached by AttachTestEvent() to report the specified |
82 // event to browser tests. This function is called by this class and its | 76 // 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 | 77 // derived classes to report their status. This function does not do anything |
84 // when we do not set an event to |status_event_|. | 78 // when we do not set an event to |status_event_|. |
85 static bool SignalStatusEvent(EventType type); | 79 static bool SignalStatusEvent(EventType type); |
86 | 80 |
87 // Instantiates SpellCheckHostMetrics object and makes it ready for recording | 81 // Instantiates SpellCheckHostMetrics object and makes it ready for recording |
88 // metrics. This should be called only if the metrics recording is active. | 82 // metrics. This should be called only if the metrics recording is active. |
89 void StartRecordingMetrics(bool spellcheck_enabled); | 83 void StartRecordingMetrics(bool spellcheck_enabled); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; | 166 scoped_ptr<SpellcheckHunspellDictionary> hunspell_dictionary_; |
173 | 167 |
174 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; | 168 scoped_ptr<spellcheck::FeedbackSender> feedback_sender_; |
175 | 169 |
176 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; | 170 base::WeakPtrFactory<SpellcheckService> weak_ptr_factory_; |
177 | 171 |
178 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); | 172 DISALLOW_COPY_AND_ASSIGN(SpellcheckService); |
179 }; | 173 }; |
180 | 174 |
181 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ | 175 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_SERVICE_H_ |
OLD | NEW |