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 #include <vector> | |
10 | |
11 #include "chrome/browser/extensions/chrome_extension_function.h" | 8 #include "chrome/browser/extensions/chrome_extension_function.h" |
12 #include "chrome/common/extensions/api/i18n.h" | |
13 #include "extensions/browser/browser_context_keyed_api_factory.h" | 9 #include "extensions/browser/browser_context_keyed_api_factory.h" |
14 #include "extensions/browser/extension_function.h" | |
15 #include "third_party/cld_2/src/public/compact_lang_det.h" | |
16 #include "third_party/cld_2/src/public/encodings.h" | |
17 | 10 |
18 class Profile; | 11 class Profile; |
19 | 12 |
20 namespace extensions { | 13 namespace extensions { |
21 | 14 |
22 class I18nGetAcceptLanguagesFunction : public ChromeSyncExtensionFunction { | 15 class I18nGetAcceptLanguagesFunction : public ChromeSyncExtensionFunction { |
23 ~I18nGetAcceptLanguagesFunction() override {} | 16 ~I18nGetAcceptLanguagesFunction() override {} |
24 bool RunSync() override; | 17 bool RunSync() override; |
25 DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES) | 18 DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES) |
26 }; | 19 }; |
27 | 20 |
28 class I18nDetectLanguageFunction : public UIThreadExtensionFunction { | |
29 private: | |
30 ~I18nDetectLanguageFunction() override{}; | |
31 | |
32 // UIThreadExtensionFunction: | |
33 ResponseAction Run() override; | |
34 | |
35 scoped_ptr<base::ListValue> GetLanguage(const std::string& text); | |
36 void InitDetectedLanguages( | |
37 CLD2::Language* langs, | |
38 int* percent3, | |
39 std::vector<linked_ptr< | |
40 api::i18n::DetectLanguage::Results::Result::LanguagesType>>* | |
41 detected_langs); | |
42 | |
43 DECLARE_EXTENSION_FUNCTION("i18n.detectLanguage", I18N_DETECTLANGUAGE) | |
44 }; | |
45 | |
46 } // namespace extensions | 21 } // namespace extensions |
47 | 22 |
48 #endif // CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ | 23 #endif // CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ |
OLD | NEW |