OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 module translate.mojom; |
| 6 |
| 7 import "mojo/common/common_custom_types.mojom"; |
| 8 import "url/mojo/url.mojom"; |
| 9 |
| 10 enum TranslateError { |
| 11 NONE, |
| 12 NETWORK, |
| 13 INITIALIZATION_ERROR, |
| 14 UNKNOWN_LANGUAGE, |
| 15 UNSUPPORTED_LANGUAGE, |
| 16 IDENTICAL_LANGUAGES, |
| 17 TRANSLATION_ERROR, |
| 18 TRANSLATION_TIMEOUT, |
| 19 UNEXPECTED_SCRIPT_ERROR, |
| 20 BAD_ORIGIN, |
| 21 SCRIPT_LOAD_ERROR, |
| 22 TRANSLATE_ERROR_MAX, |
| 23 }; |
| 24 |
| 25 struct LanguageDetectionDetails { |
| 26 mojo.common.mojom.Time time; |
| 27 url.mojom.Url url; |
| 28 string content_language; |
| 29 string cld_language; |
| 30 bool is_cld_reliable; |
| 31 bool has_notranslate; |
| 32 string html_root_language; |
| 33 string adopted_language; |
| 34 string contents; |
| 35 }; |
| 36 |
| 37 interface Page { |
| 38 // Requests that the page be translated from |source_lang| to |
| 39 // |target_lang|. |
| 40 // |
| 41 // If a Translate request is already in progress with a matching |
| 42 // |target_lang|, this request will respond with |cancelled| set |
| 43 // to |true|. |
| 44 // |
| 45 // If a Translate request is already in progress with a different |
| 46 // |target_lang|, that request will respond with |cancelled| set |
| 47 // to |true| and this request will proceed normally. |
| 48 // |
| 49 // If |cancelled| is |true| all other response values should be |
| 50 // ignored. |
| 51 Translate(string translate_script, string source_lang, string target_lang) |
| 52 => (bool cancelled, string original_lang, string translated_lang, |
| 53 TranslateError error); |
| 54 |
| 55 // Requests that the page be reverted to its original language with |
| 56 // no translation applied. |
| 57 RevertTranslation(); |
| 58 }; |
| 59 |
| 60 interface ContentTranslateDriver { |
| 61 // Notification that a new page is ready to translate, |
| 62 // and the language for it has been determined. |
| 63 RegisterPage(Page page, LanguageDetectionDetails details, |
| 64 bool page_needs_translation); |
| 65 }; |
OLD | NEW |