| 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 "components/translate/core/browser/translate_manager.h" | 5 #include "components/translate/core/browser/translate_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 // Don't translate similar languages (ex: en-US to en). | 214 // Don't translate similar languages (ex: en-US to en). |
| 215 if (language_code == target_lang) { | 215 if (language_code == target_lang) { |
| 216 TranslateBrowserMetrics::ReportInitiationStatus( | 216 TranslateBrowserMetrics::ReportInitiationStatus( |
| 217 TranslateBrowserMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES); | 217 TranslateBrowserMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES); |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 | 220 |
| 221 // Querying the ranker now, but not exiting immediately so that we may log | 221 // Querying the ranker now, but not exiting immediately so that we may log |
| 222 // other potential suppression reasons. | 222 // other potential suppression reasons. |
| 223 bool should_offer_translation = translate_ranker_->ShouldOfferTranslation( | 223 bool should_offer_translation = |
| 224 *translate_prefs, language_code, target_lang, translate_event_.get()); | 224 translate_ranker_->ShouldOfferTranslation(translate_event_.get()); |
| 225 | 225 |
| 226 // Nothing to do if either the language Chrome is in or the language of | 226 // Nothing to do if either the language Chrome is in or the language of |
| 227 // the page is not supported by the translation server. | 227 // the page is not supported by the translation server. |
| 228 if (target_lang.empty() || | 228 if (target_lang.empty() || |
| 229 !TranslateDownloadManager::IsSupportedLanguage(language_code)) { | 229 !TranslateDownloadManager::IsSupportedLanguage(language_code)) { |
| 230 TranslateBrowserMetrics::ReportInitiationStatus( | 230 TranslateBrowserMetrics::ReportInitiationStatus( |
| 231 TranslateBrowserMetrics::INITIATION_STATUS_LANGUAGE_IS_NOT_SUPPORTED); | 231 TranslateBrowserMetrics::INITIATION_STATUS_LANGUAGE_IS_NOT_SUPPORTED); |
| 232 TranslateBrowserMetrics::ReportUnsupportedLanguageAtInitiation( | 232 TranslateBrowserMetrics::ReportUnsupportedLanguageAtInitiation( |
| 233 language_code); | 233 language_code); |
| 234 RecordTranslateEvent(metrics::TranslateEventProto::UNSUPPORTED_LANGUAGE); | 234 RecordTranslateEvent(metrics::TranslateEventProto::UNSUPPORTED_LANGUAGE); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 source_language) && | 608 source_language) && |
| 609 !ShouldOverrideDecision( | 609 !ShouldOverrideDecision( |
| 610 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST)) { | 610 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST)) { |
| 611 return true; | 611 return true; |
| 612 } | 612 } |
| 613 | 613 |
| 614 return false; | 614 return false; |
| 615 } | 615 } |
| 616 | 616 |
| 617 } // namespace translate | 617 } // namespace translate |
| OLD | NEW |