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

Unified Diff: components/translate/ios/browser/language_detection_controller.mm

Issue 2913573002: Updates language model on iOS. (Closed)
Patch Set: Created 3 years, 6 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: components/translate/ios/browser/language_detection_controller.mm
diff --git a/components/translate/ios/browser/language_detection_controller.mm b/components/translate/ios/browser/language_detection_controller.mm
index 4c23553cb54fc275d1e65db8a1a0d6ec3d702883..642377ae4e845d0fa199c918f019019fc9ed096f 100644
--- a/components/translate/ios/browser/language_detection_controller.mm
+++ b/components/translate/ios/browser/language_detection_controller.mm
@@ -52,6 +52,14 @@ LanguageDetectionController::LanguageDetectionController(
LanguageDetectionController::~LanguageDetectionController() {
}
+LanguageDetectionController::DetectionDetails::DetectionDetails()
+ : is_cld_reliable(false) {}
+
+LanguageDetectionController::DetectionDetails::DetectionDetails(
+ const DetectionDetails& other) = default;
+
+LanguageDetectionController::DetectionDetails::~DetectionDetails() = default;
+
std::unique_ptr<LanguageDetectionController::CallbackList::Subscription>
LanguageDetectionController::RegisterLanguageDetectionCallback(
const Callback& callback) {
@@ -115,11 +123,13 @@ void LanguageDetectionController::OnTextRetrieved(
const std::string& http_content_language,
const std::string& html_lang,
const base::string16& text_content) {
+ std::string cld_language;
+ bool is_cld_reliable;
std::string language = translate::DeterminePageLanguage(
http_content_language, html_lang,
GetStringByClippingLastWord(text_content,
language_detection::kMaxIndexChars),
- nullptr /* cld_language */, nullptr /* is_cld_reliable */);
+ &cld_language, &is_cld_reliable);
if (language.empty())
return; // No language detected.
@@ -127,6 +137,8 @@ void LanguageDetectionController::OnTextRetrieved(
details.content_language = http_content_language;
details.html_root_language = html_lang;
details.adopted_language = language;
+ details.cld_language = cld_language;
+ details.is_cld_reliable = is_cld_reliable;
language_detection_callbacks_.Notify(details);
}

Powered by Google App Engine
This is Rietveld 408576698