OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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. |
| 4 |
| 5 #include "components/translate/core/common/language_detection_logging_helper.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" |
| 11 #include "components/sync/protocol/user_event_specifics.pb.h" |
| 12 #include "components/translate/core/common/language_detection_details.h" |
| 13 |
| 14 namespace translate { |
| 15 |
| 16 std::unique_ptr<sync_pb::UserEventSpecifics> ConstructLanguageDetectionEvent( |
| 17 const LanguageDetectionDetails& details) { |
| 18 auto specifics = base::MakeUnique<sync_pb::UserEventSpecifics>(); |
| 19 specifics->set_event_time_usec(base::Time::Now().ToInternalValue()); |
| 20 |
| 21 // TODO(renjieliu): Revisit this field when the best way to identify |
| 22 // navigations is determined. |
| 23 specifics->set_navigation_id(base::Time::Now().ToInternalValue()); |
| 24 |
| 25 sync_pb::LanguageDetection lang_detection; |
| 26 auto* const lang = lang_detection.add_detected_languages(); |
| 27 lang->set_language_code(details.cld_language); |
| 28 lang->set_is_reliable(details.is_cld_reliable); |
| 29 // Only set adopted_language when it's different from cld_language. |
| 30 if (details.adopted_language != details.cld_language) { |
| 31 lang_detection.set_adopted_language_code(details.adopted_language); |
| 32 } |
| 33 *specifics->mutable_language_detection() = lang_detection; |
| 34 return specifics; |
| 35 } |
| 36 } // namespace translate |
OLD | NEW |