| Index: components/translate/core/common/language_detection_logging_helper.cc
|
| diff --git a/components/translate/core/common/language_detection_logging_helper.cc b/components/translate/core/common/language_detection_logging_helper.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e632bdfb84da281ae84b92a39e4d778177fb5305
|
| --- /dev/null
|
| +++ b/components/translate/core/common/language_detection_logging_helper.cc
|
| @@ -0,0 +1,36 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/translate/core/common/language_detection_logging_helper.h"
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/memory/ptr_util.h"
|
| +#include "components/sync/protocol/user_event_specifics.pb.h"
|
| +#include "components/translate/core/common/language_detection_details.h"
|
| +
|
| +namespace translate {
|
| +
|
| +std::unique_ptr<sync_pb::UserEventSpecifics> ConstructLanguageDetectionEvent(
|
| + const LanguageDetectionDetails& details) {
|
| + auto specifics = base::MakeUnique<sync_pb::UserEventSpecifics>();
|
| + specifics->set_event_time_usec(base::Time::Now().ToInternalValue());
|
| +
|
| + // TODO(renjieliu): Revisit this field when the best way to identify
|
| + // navigations is determined.
|
| + specifics->set_navigation_id(base::Time::Now().ToInternalValue());
|
| +
|
| + sync_pb::LanguageDetection lang_detection;
|
| + auto* const lang = lang_detection.add_detected_languages();
|
| + lang->set_language_code(details.cld_language);
|
| + lang->set_is_reliable(details.is_cld_reliable);
|
| + // Only set adopted_language when it's different from cld_language.
|
| + if (details.adopted_language != details.cld_language) {
|
| + lang_detection.set_adopted_language_code(details.adopted_language);
|
| + }
|
| + *specifics->mutable_language_detection() = lang_detection;
|
| + return specifics;
|
| +}
|
| +} // namespace translate
|
|
|