Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / translate / ios / browser / js_language_detection_manager.h
blobb7ca49298fb8ade8f0a868b8945f0d2a167b8c42
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_LANGUAGE_DETECTION_MANAGER_H_
6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_JS_LANGUAGE_DETECTION_MANAGER_H_
8 #import <Foundation/Foundation.h>
10 #include "base/callback_forward.h"
11 #include "base/strings/string16.h"
12 #import "ios/web/public/web_state/js/crw_js_injection_manager.h"
14 namespace language_detection {
16 // Maximum length of the extracted text returned by |-extractTextContent|.
17 // Matches desktop implementation.
18 extern const size_t kMaxIndexChars;
20 // Type for the callback called when the buffered text is retrieved.
21 using BufferedTextCallback = base::Callback<void(const base::string16&)>;
23 } // namespace language_detection
25 // JsLanguageDetectionManager manages the scripts related to language detection.
26 @interface JsLanguageDetectionManager : CRWJSInjectionManager
28 // Retrieves the cached text content of the page from the JS side. Calls
29 // |callback| with the page's text contents. The cache is purged on the JS side
30 // after this call. |callback| must be non null.
31 - (void)retrieveBufferedTextContent:
32 (const language_detection::BufferedTextCallback&)callback;
34 // Starts detecting the language of the page.
35 - (void)startLanguageDetection;
37 @end
39 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_JS_LANGUAGE_DETECTION_MANAGER_H_