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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/web_view/public/cwv_translation_controller.h
diff --git a/ios/web_view/public/cwv_translation_controller.h b/ios/web_view/public/cwv_translation_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..322965268cc4147208f1e96c33744d19d431d8fd
--- /dev/null
+++ b/ios/web_view/public/cwv_translation_controller.h
@@ -0,0 +1,71 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H
+#define IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H
+
+#import <ChromeWebView/cwv_export.h>
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class CWVTranslationLanguage;
+@protocol CWVTranslationControllerDelegate;
+
+// The error domain for translation errors.
+extern NSErrorDomain const CWVTranslationErrorDomain;
+
+// Possible error codes during translation.
+// No connectivity.
+extern const NSInteger CWVTranslationErrorNetwork;
+// The translation script failed to initialize.
+extern const NSInteger CWVTranslationErrorInitializationError;
+// The page's language could not be detected.
+extern const NSInteger CWVTranslationErrorUnknownLanguage;
+// The server detected a language that the browser does not know.
+extern const NSInteger CWVTranslationErrorUnsupportedLanguage;
+// The original and target languages are the same.
+extern const NSInteger CWVTranslationErrorIdenticalLanguages;
+// An error was reported by the translation script during translation.
+extern const NSInteger CWVTranslationErrorTranslationError;
+// The library doesn't finish the translation.
+extern const NSInteger CWVTranslationErrorTranslationTimeout;
+// The library raises an unexpected exception.
+extern const NSInteger CWVTranslationErrorUnexpectedScriptError;
+// The library is blocked because of bad origin.
+extern const NSInteger CWVTranslationErrorBadOrigin;
+// Loader fails to load a dependent JavaScript.
+extern const NSInteger CWVTranslationErrorScriptLoadError;
+
+// Allows page translation from one language to another.
+CWV_EXPORT
+@interface CWVTranslationController : NSObject
+
+// Delegate to receive translation callbacks.
+@property(nullable, nonatomic, weak) id<CWVTranslationControllerDelegate>
+ delegate;
+
+// Begins translation on the current page from |sourceLanguage| to
+// |targetLanguage|. These language parameters must be chosen from
+// a CWWLanguageDetectionResult's |supportedLanguages|.
+// This must not be called before the |delegate| receives
+// |translationController:didFinishLanguageDetectionWithResult:error:|.
+// TODO(crbug.com/706289): Document what happens if you call this out of order
+// or many times.
+- (void)translatePageFromLanguage:(CWVTranslationLanguage*)sourceLanguage
+ toLanguage:(CWVTranslationLanguage*)targetLanguage;
+
+// Reverts any translations done back to the original page language.
+// Note that the original page language may be different from |sourceLanguage|
+// passed to |translatePageFromLanguage:toLanguage:| above.
+// This must not be called before the |delegate| receives
+// |translationController:didFinishLanguageDetectionWithResult:error:|.
+// TODO(crbug.com/706289): Document what happens if you call this out of order.
+- (void)revertTranslation;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H
« 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