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 |
8 #include "chrome/browser/extensions/chrome_extension_function.h" | 11 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 12 #include "chrome/common/extensions/api/i18n.h" |
9 #include "extensions/browser/browser_context_keyed_api_factory.h" | 13 #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" |
10 | 17 |
11 class Profile; | 18 class Profile; |
12 | 19 |
13 namespace extensions { | 20 namespace extensions { |
14 | 21 |
15 class I18nGetAcceptLanguagesFunction : public ChromeSyncExtensionFunction { | 22 class I18nGetAcceptLanguagesFunction : public ChromeSyncExtensionFunction { |
16 ~I18nGetAcceptLanguagesFunction() override {} | 23 ~I18nGetAcceptLanguagesFunction() override {} |
17 bool RunSync() override; | 24 bool RunSync() override; |
18 DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES) | 25 DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES) |
19 }; | 26 }; |
20 | 27 |
| 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 |
21 } // namespace extensions | 46 } // namespace extensions |
22 | 47 |
23 #endif // CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ | 48 #endif // CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ |
OLD | NEW |