Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: ios/web_view/public/cwv_translation_controller.h

Issue 2839093002: Implemented new Translate API for purely Objective-C clients. (Closed)
Patch Set: merge Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 #ifndef IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H
6 #define IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H
7
8 #import <ChromeWebView/cwv_export.h>
9 #import <Foundation/Foundation.h>
10
11 NS_ASSUME_NONNULL_BEGIN
12
13 @class CWVTranslationLanguage;
14 @protocol CWVTranslationControllerDelegate;
15
16 // The error domain for translation errors.
17 extern NSErrorDomain const CWVTranslationErrorDomain;
18
19 // Possible error codes during translation.
20 // No connectivity.
21 extern const NSInteger CWVTranslationErrorNetwork;
22 // The translation script failed to initialize.
23 extern const NSInteger CWVTranslationErrorInitializationError;
24 // The page's language could not be detected.
25 extern const NSInteger CWVTranslationErrorUnknownLanguage;
26 // The server detected a language that the browser does not know.
27 extern const NSInteger CWVTranslationErrorUnsupportedLanguage;
28 // The original and target languages are the same.
29 extern const NSInteger CWVTranslationErrorIdenticalLanguages;
30 // An error was reported by the translation script during translation.
31 extern const NSInteger CWVTranslationErrorTranslationError;
32 // The library doesn't finish the translation.
33 extern const NSInteger CWVTranslationErrorTranslationTimeout;
34 // The library raises an unexpected exception.
35 extern const NSInteger CWVTranslationErrorUnexpectedScriptError;
36 // The library is blocked because of bad origin.
37 extern const NSInteger CWVTranslationErrorBadOrigin;
38 // Loader fails to load a dependent JavaScript.
39 extern const NSInteger CWVTranslationErrorScriptLoadError;
40
41 // Allows page translation from one language to another.
42 CWV_EXPORT
43 @interface CWVTranslationController : NSObject
44
45 // Delegate to receive translation callbacks.
46 @property(nullable, nonatomic, weak) id<CWVTranslationControllerDelegate>
47 delegate;
48
49 // Begins translation on the current page from |sourceLanguage| to
50 // |targetLanguage|. These language parameters must be chosen from
51 // a CWWLanguageDetectionResult's |supportedLanguages|.
52 // This must not be called before the |delegate| receives
53 // |translationController:didFinishLanguageDetectionWithResult:error:|.
54 // TODO(crbug.com/706289): Document what happens if you call this out of order
55 // or many times.
56 - (void)translatePageFromLanguage:(CWVTranslationLanguage*)sourceLanguage
57 toLanguage:(CWVTranslationLanguage*)targetLanguage;
58
59 // Reverts any translations done back to the original page language.
60 // Note that the original page language may be different from |sourceLanguage|
61 // passed to |translatePageFromLanguage:toLanguage:| above.
62 // This must not be called before the |delegate| receives
63 // |translationController:didFinishLanguageDetectionWithResult:error:|.
64 // TODO(crbug.com/706289): Document what happens if you call this out of order.
65 - (void)revertTranslation;
66
67 @end
68
69 NS_ASSUME_NONNULL_END
70
71 #endif // IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H
OLDNEW
« no previous file with comments | « ios/web_view/public/cwv_translate_manager.h ('k') | ios/web_view/public/cwv_translation_controller_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698