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

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

Issue 2913573002: Updates language model on iOS. (Closed)
Patch Set: 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: 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..68a5f6223ecbbc87cf686a9935e0dd7406fca6fe 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()
martis 2017/06/01 06:49:21 Do constructors/destructors operate in the same ma
ramyasharma 2017/06/02 07:20:24 Yes, this is essentially C++ in objective-C++ file
+ : is_cld_reliable(false) {}
+
+LanguageDetectionController::DetectionDetails::DetectionDetails(
+ const DetectionDetails& other) = default;
+
+LanguageDetectionController::DetectionDetails::~DetectionDetails() {}
+
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;
martis 2017/06/01 06:49:21 If you wanted to avoid the extra variables (and st
ramyasharma 2017/06/02 07:20:24 Thanks. But I think it's clearer this way.
+ 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