1 // Copyright 2013 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.
5 #ifndef COMPONENTS_TRANSLATE_IOS_BROWSER_JS_TRANSLATE_MANAGER_H_
6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_JS_TRANSLATE_MANAGER_H_
8 #import "ios/web/public/web_state/js/crw_js_injection_manager.h"
12 #include "base/time/time.h"
16 // Manager for the injection of the Translate JavaScript.
17 // Replicates functionality from TranslateHelper in
18 // chrome/renderer/translate/translate_helper.cc.
19 // JsTranslateManager injects the script in the page and calls it, but is not
20 // responsible for loading it or caching it.
21 @interface JsTranslateManager
: CRWJSInjectionManager
23 // The translation script. Must be set before |-inject| is called, and is reset
24 // after the injection.
25 @
property(nonatomic
, copy
) NSString
* script
;
27 // Injects JS to constantly check if the translate script is ready and informs
28 // the Obj-C side when it is.
29 - (void)injectWaitUntilTranslateReadyScript
;
31 // After a translation has been initiated, injects JS to check if the
32 // translation has finished/failed and informs the Obj-C when it is.
33 - (void)injectTranslateStatusScript
;
35 // Starts translation of the page from |source| language to |target| language.
36 // Equivalent to TranslateHelper::StartTranslation().
37 - (void)startTranslationFrom
:(const std::string
&)source
38 to
:(const std::string
&)target
;
40 // Reverts the translation. Assumes that no navigation happened since the page
41 // has been translated.
42 - (void)revertTranslation
;
46 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_JS_TRANSLATE_MANAGER_H_