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_EXTENSIONS_API_I18N_I18N_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ |
7 | 7 |
8 #include <string> | |
9 | |
10 #include "base/strings/string16.h" | |
11 #include "base/strings/utf_string_conversions.h" | |
8 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
9 #include "extensions/browser/browser_context_keyed_api_factory.h" | 13 #include "extensions/browser/browser_context_keyed_api_factory.h" |
14 #include "third_party/cld_2/src/public/compact_lang_det.h" | |
15 #include "third_party/cld_2/src/public/encodings.h" | |
10 | 16 |
11 class Profile; | 17 class Profile; |
12 | 18 |
13 namespace extensions { | 19 namespace extensions { |
14 | 20 |
15 class I18nGetAcceptLanguagesFunction : public ChromeSyncExtensionFunction { | 21 class I18nGetAcceptLanguagesFunction : public ChromeSyncExtensionFunction { |
16 ~I18nGetAcceptLanguagesFunction() override {} | 22 ~I18nGetAcceptLanguagesFunction() override {} |
17 bool RunSync() override; | 23 bool RunSync() override; |
18 DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES) | 24 DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES) |
19 }; | 25 }; |
20 | 26 |
27 typedef struct { | |
28 std::string language; | |
29 int percentage; | |
30 } DetectedLanguage; | |
31 | |
32 class I18nDetectLanguageFunction : public ChromeAsyncExtensionFunction { | |
not at google - send to devlin
2015/07/08 19:34:53
Inherit from UIThreadExtensionFunction not ChromeA
amalika
2015/07/08 21:58:03
Changed to inherit from AsyncExtensionFunction ins
not at google - send to devlin
2015/07/08 22:11:49
The comment right above that says DEPRECATED. Plea
amalika
2015/07/09 23:00:02
Done.
| |
33 private: | |
34 ~I18nDetectLanguageFunction() override {}; | |
35 bool RunAsync() override; | |
36 void GetLanguage(const std::string& text); | |
37 void SendLanguagesResult(DetectedLanguage *detected_langs, | |
38 const bool is_reliable); | |
not at google - send to devlin
2015/07/08 19:34:53
There is no point having const things that aren't
amalika
2015/07/08 21:58:03
Done.
| |
39 void InitDetectedLanguages(CLD2::Language *langs, int *percent3, | |
40 DetectedLanguage detected_langs[3]); | |
41 | |
42 DECLARE_EXTENSION_FUNCTION("i18n.detectLanguage", I18N_DETECTLANGUAGE) | |
43 }; | |
44 | |
21 } // namespace extensions | 45 } // namespace extensions |
22 | 46 |
23 #endif // CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ | 47 #endif // CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ |
OLD | NEW |