| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ | 5 #ifndef COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ |
| 6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ | 6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace web { | 27 namespace web { |
| 28 class NavigationContext; | 28 class NavigationContext; |
| 29 class WebState; | 29 class WebState; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace translate { | 32 namespace translate { |
| 33 | 33 |
| 34 class LanguageDetectionController : public web::WebStateObserver { | 34 class LanguageDetectionController : public web::WebStateObserver { |
| 35 public: | 35 public: |
| 36 // Language detection details, passed to language detection callbacks. | 36 // Language detection details, passed to language detection callbacks. |
| 37 // TODO(crbug.com/715447): Investigate if we can use the existing |
| 38 // detection_details under |
| 39 // components/translate/core/common/language_detection_details.h. |
| 37 struct DetectionDetails { | 40 struct DetectionDetails { |
| 41 DetectionDetails(); |
| 42 DetectionDetails(const DetectionDetails& other); |
| 43 ~DetectionDetails(); |
| 44 |
| 38 // The language detected by the content (Content-Language). | 45 // The language detected by the content (Content-Language). |
| 39 std::string content_language; | 46 std::string content_language; |
| 40 | 47 |
| 41 // The language written in the lang attribute of the html element. | 48 // The language written in the lang attribute of the html element. |
| 42 std::string html_root_language; | 49 std::string html_root_language; |
| 43 | 50 |
| 44 // The adopted language. | 51 // The adopted language. |
| 45 std::string adopted_language; | 52 std::string adopted_language; |
| 53 |
| 54 // The language detected by CLD. |
| 55 std::string cld_language; |
| 56 |
| 57 // Whether the CLD detection is reliable or not. |
| 58 bool is_cld_reliable; |
| 46 }; | 59 }; |
| 47 | 60 |
| 48 LanguageDetectionController(web::WebState* web_state, | 61 LanguageDetectionController(web::WebState* web_state, |
| 49 JsLanguageDetectionManager* manager, | 62 JsLanguageDetectionManager* manager, |
| 50 PrefService* prefs); | 63 PrefService* prefs); |
| 51 ~LanguageDetectionController() override; | 64 ~LanguageDetectionController() override; |
| 52 | 65 |
| 53 // Callback types for language detection events. | 66 // Callback types for language detection events. |
| 54 typedef base::Callback<void(const DetectionDetails&)> Callback; | 67 typedef base::Callback<void(const DetectionDetails&)> Callback; |
| 55 typedef base::CallbackList<void(const DetectionDetails&)> CallbackList; | 68 typedef base::CallbackList<void(const DetectionDetails&)> CallbackList; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 86 JsLanguageDetectionManager* js_manager_; | 99 JsLanguageDetectionManager* js_manager_; |
| 87 BooleanPrefMember translate_enabled_; | 100 BooleanPrefMember translate_enabled_; |
| 88 base::WeakPtrFactory<LanguageDetectionController> weak_method_factory_; | 101 base::WeakPtrFactory<LanguageDetectionController> weak_method_factory_; |
| 89 | 102 |
| 90 DISALLOW_COPY_AND_ASSIGN(LanguageDetectionController); | 103 DISALLOW_COPY_AND_ASSIGN(LanguageDetectionController); |
| 91 }; | 104 }; |
| 92 | 105 |
| 93 } // namespace translate | 106 } // namespace translate |
| 94 | 107 |
| 95 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ | 108 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_LANGUAGE_DETECTION_CONTROLLER_H_ |
| OLD | NEW |