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

Side by Side Diff: components/translate/core/browser/translate_manager.cc

Issue 2890843003: Simplify TranslateRanker API. (Closed)
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
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
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 source_language) && 601 source_language) &&
602 !ShouldOverrideDecision( 602 !ShouldOverrideDecision(
603 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST)) { 603 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST)) {
604 return true; 604 return true;
605 } 605 }
606 606
607 return false; 607 return false;
608 } 608 }
609 609
610 } // namespace translate 610 } // namespace translate
OLDNEW
« no previous file with comments | « components/translate/core/browser/mock_translate_ranker.cc ('k') | components/translate/core/browser/translate_ranker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698