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_COMMON_SPELLCHECK_COMMON_H_ | 5 #ifndef CHROME_COMMON_SPELLCHECK_COMMON_H_ |
6 #define CHROME_COMMON_SPELLCHECK_COMMON_H_ | 6 #define CHROME_COMMON_SPELLCHECK_COMMON_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class FilePath; | 13 class FilePath; |
14 } | 14 } |
15 | 15 |
| 16 class PrefService; |
| 17 |
16 namespace chrome { | 18 namespace chrome { |
17 namespace spellcheck_common { | 19 namespace spellcheck_common { |
18 | 20 |
19 // The number of hours that a session of feedback for spelling service lasts. | 21 // The number of hours that a session of feedback for spelling service lasts. |
20 // After this number of hours passes, all feedback. | 22 // After this number of hours passes, all feedback. |
21 static const int kSessionHours = 6; | 23 static const int kSessionHours = 6; |
22 | 24 |
23 // The number of context words to keep on either side of a misspelling for | 25 // The number of context words to keep on either side of a misspelling for |
24 // spelling service feedback. | 26 // spelling service feedback. |
25 static const int kContextWordCount = 2; | 27 static const int kContextWordCount = 2; |
26 | 28 |
27 // The number of seconds between sending feedback to spelling service. | 29 // The number of seconds between sending feedback to spelling service. |
28 static const int kFeedbackIntervalSeconds = 1800; // 30 minutes | 30 static const int kFeedbackIntervalSeconds = 1800; // 30 minutes |
29 | 31 |
30 // Max number of dictionary suggestions. | 32 // Max number of dictionary suggestions. |
31 static const int kMaxSuggestions = 5; | 33 static const int kMaxSuggestions = 5; |
32 | 34 |
33 static const int kMaxAutoCorrectWordSize = 8; | 35 static const int kMaxAutoCorrectWordSize = 8; |
34 | 36 |
35 // Maximum number of words in the custom spellcheck dictionary that can be | 37 // Maximum number of words in the custom spellcheck dictionary that can be |
36 // synced. | 38 // synced. |
37 static const size_t MAX_SYNCABLE_DICTIONARY_WORDS = 1300; | 39 static const size_t MAX_SYNCABLE_DICTIONARY_WORDS = 1300; |
38 | 40 |
39 // Maximum number of bytes in a word that can be added to the custom spellcheck | 41 // Maximum number of bytes in a word that can be added to the custom spellcheck |
40 // dictionary. | 42 // dictionary. |
41 static const size_t MAX_CUSTOM_DICTIONARY_WORD_BYTES = 99; | 43 static const size_t MAX_CUSTOM_DICTIONARY_WORD_BYTES = 99; |
42 | 44 |
| 45 // Character that separates language codes saved in preferences. |
| 46 static const char kDictionaryLanguagesSeparator = ','; |
| 47 |
43 typedef std::vector<std::string> WordList; | 48 typedef std::vector<std::string> WordList; |
44 typedef std::set<std::string> WordSet; | 49 typedef std::set<std::string> WordSet; |
45 | 50 |
46 base::FilePath GetVersionedFileName(const std::string& input_language, | 51 base::FilePath GetVersionedFileName(const std::string& input_language, |
47 const base::FilePath& dict_dir); | 52 const base::FilePath& dict_dir); |
48 | 53 |
49 std::string GetCorrespondingSpellCheckLanguage(const std::string& language); | 54 std::string GetCorrespondingSpellCheckLanguage(const std::string& language); |
50 | 55 |
51 // Get SpellChecker supported languages. | 56 // Get SpellChecker supported languages. |
52 void SpellCheckLanguages(std::vector<std::string>* languages); | 57 void SpellCheckLanguages(std::vector<std::string>* languages); |
53 | 58 |
54 // Gets the ISO codes for the language and country of this |locale|. The | 59 // Gets the ISO codes for the language and country of this |locale|. The |
55 // |locale| is an ISO locale ID that may not include a country ID, e.g., "fr" or | 60 // |locale| is an ISO locale ID that may not include a country ID, e.g., "fr" or |
56 // "de". This method converts the UI locale to a full locale ID and converts the | 61 // "de". This method converts the UI locale to a full locale ID and converts the |
57 // full locale ID to an ISO language code and an ISO3 country code. | 62 // full locale ID to an ISO language code and an ISO3 country code. |
58 void GetISOLanguageCountryCodeFromLocale(const std::string& locale, | 63 void GetISOLanguageCountryCodeFromLocale(const std::string& locale, |
59 std::string* language_code, | 64 std::string* language_code, |
60 std::string* country_code); | 65 std::string* country_code); |
61 | 66 |
| 67 // Reads the spellcheck.dictionary or spellcheck.dictionaries preference |
| 68 // (depending on whether the enable-multilingual-spellchecker flag is set), and |
| 69 // returns the language codes. |
| 70 std::vector<std::string> GetDictionaryLanguagesPref(PrefService* prefs); |
| 71 |
62 } // namespace spellcheck_common | 72 } // namespace spellcheck_common |
63 } // namespace chrome | 73 } // namespace chrome |
64 | 74 |
65 #endif // CHROME_COMMON_SPELLCHECK_COMMON_H_ | 75 #endif // CHROME_COMMON_SPELLCHECK_COMMON_H_ |
OLD | NEW |