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

Unified Diff: components/translate/core/browser/translate_manager.h

Issue 2200493002: using ulp to improve TranslateManager GetTargetLanguage() and InitiateTranslation() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix global state problem in unittests Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/translate/core/browser/translate_manager.h
diff --git a/components/translate/core/browser/translate_manager.h b/components/translate/core/browser/translate_manager.h
index 7ba87702ae84dd05797ecc3080dc6f1226fe1771..502474f101c0eb24279b7e0edab45881f8e22f44 100644
--- a/components/translate/core/browser/translate_manager.h
+++ b/components/translate/core/browser/translate_manager.h
@@ -11,6 +11,8 @@
#include <vector>
#include "base/callback_list.h"
+#include "base/feature_list.h"
+#include "base/gtest_prod_util.h"
Lei Zhang 2016/11/17 07:03:28 Not needed, but I imagine it's here because you wa
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/translate/core/browser/language_state.h"
@@ -21,9 +23,16 @@ class PrefService;
namespace translate {
+extern const base::Feature kTranslateLanguageByULP;
+
class TranslateClient;
class TranslateDriver;
class TranslatePrefs;
+
+namespace testing {
+class TranslateManagerTest;
+} // namespace testing
+
struct TranslateErrorDetails;
// The TranslateManager class is responsible for showing an info-bar when a page
@@ -52,6 +61,7 @@ class TranslateManager {
// Returns the language to translate to. The language returned is the
// first language found in the following list that is supported by the
// translation service:
+ // High confidence and high probability reading language in ULP
// the UI language
// the accept-language list
// If no language is found then an empty string is returned.
@@ -103,11 +113,21 @@ class TranslateManager {
static void SetIgnoreMissingKeyForTesting(bool ignore);
private:
+ friend class translate::testing::TranslateManagerTest;
+
// Sends a translation request to the TranslateDriver.
void DoTranslatePage(const std::string& translate_script,
const std::string& source_lang,
const std::string& target_lang);
+ // Returns the language to translate to by looking at ULP. Return empty string
+ // If it cannot conclude from ULP.
+ static std::string GetTargetLanguageFromULP(const TranslatePrefs* prefs);
+
+ // Return true if the language is in the ULP with high confidence and high
+ // probability.
+ bool LanguageInULP(const std::string& language) const;
+
// Notifies all registered callbacks of translate errors.
void NotifyTranslateError(TranslateErrors::Type error_type);

Powered by Google App Engine
This is Rietveld 408576698