| 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 #include "extensions/renderer/i18n_custom_bindings.h" | 5 #include "extensions/renderer/i18n_custom_bindings.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // components/translate/core/language_detection/language_detection_util.cc | 116 // components/translate/core/language_detection/language_detection_util.cc |
| 117 if (languages[i] == CLD2::UNKNOWN_LANGUAGE) { | 117 if (languages[i] == CLD2::UNKNOWN_LANGUAGE) { |
| 118 // Break from the loop since there is no need to save | 118 // Break from the loop since there is no need to save |
| 119 // unknown languages | 119 // unknown languages |
| 120 break; | 120 break; |
| 121 } else { | 121 } else { |
| 122 language_code = | 122 language_code = |
| 123 CLD2::LanguageCode(static_cast<CLD2::Language>(languages[i])); | 123 CLD2::LanguageCode(static_cast<CLD2::Language>(languages[i])); |
| 124 } | 124 } |
| 125 detected_languages->push_back( | 125 detected_languages->push_back( |
| 126 base::WrapUnique(new DetectedLanguage(language_code, percents[i]))); | 126 base::MakeUnique<DetectedLanguage>(language_code, percents[i])); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 #elif BUILDFLAG(CLD_VERSION) == 3 | 130 #elif BUILDFLAG(CLD_VERSION) == 3 |
| 131 void InitDetectedLanguages( | 131 void InitDetectedLanguages( |
| 132 const std::vector<chrome_lang_id::NNetLanguageIdentifier::Result>& | 132 const std::vector<chrome_lang_id::NNetLanguageIdentifier::Result>& |
| 133 lang_results, | 133 lang_results, |
| 134 LanguageDetectionResult* result) { | 134 LanguageDetectionResult* result) { |
| 135 std::vector<std::unique_ptr<DetectedLanguage>>* detected_languages = | 135 std::vector<std::unique_ptr<DetectedLanguage>>* detected_languages = |
| 136 &result->languages; | 136 &result->languages; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 148 // Thus, is_reliable is set to "false". | 148 // Thus, is_reliable is set to "false". |
| 149 if (i == 0) { | 149 if (i == 0) { |
| 150 *is_reliable = false; | 150 *is_reliable = false; |
| 151 } | 151 } |
| 152 break; | 152 break; |
| 153 } | 153 } |
| 154 | 154 |
| 155 *is_reliable = *is_reliable && lang_result.is_reliable; | 155 *is_reliable = *is_reliable && lang_result.is_reliable; |
| 156 const int percent = static_cast<int>(100 * lang_result.proportion); | 156 const int percent = static_cast<int>(100 * lang_result.proportion); |
| 157 detected_languages->push_back( | 157 detected_languages->push_back( |
| 158 base::WrapUnique(new DetectedLanguage(language_code, percent))); | 158 base::MakeUnique<DetectedLanguage>(language_code, percent)); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 #else | 161 #else |
| 162 # error "CLD_VERSION must be 2 or 3" | 162 # error "CLD_VERSION must be 2 or 3" |
| 163 #endif | 163 #endif |
| 164 | 164 |
| 165 } // namespace | 165 } // namespace |
| 166 | 166 |
| 167 I18NCustomBindings::I18NCustomBindings(ScriptContext* context) | 167 I18NCustomBindings::I18NCustomBindings(ScriptContext* context) |
| 168 : ObjectBackedNativeHandler(context) { | 168 : ObjectBackedNativeHandler(context) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // Populate LanguageDetectionResult with prediction reliability, languages, | 298 // Populate LanguageDetectionResult with prediction reliability, languages, |
| 299 // and the corresponding percentages. | 299 // and the corresponding percentages. |
| 300 InitDetectedLanguages(lang_results, &result); | 300 InitDetectedLanguages(lang_results, &result); |
| 301 args.GetReturnValue().Set(result.ToValue(context())); | 301 args.GetReturnValue().Set(result.ToValue(context())); |
| 302 #else | 302 #else |
| 303 # error "CLD_VERSION must be 2 or 3" | 303 # error "CLD_VERSION must be 2 or 3" |
| 304 #endif | 304 #endif |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace extensions | 307 } // namespace extensions |
| OLD | NEW |