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

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: Change based on 8/3 design review and simplified the use of ULP 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..80105f7518c529435d2f38e881b4a063e9e82220 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"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/translate/core/browser/language_state.h"
@@ -21,6 +23,9 @@ class PrefService;
namespace translate {
+// Feature flag for "Translate Language by ULP" project.
groby-ooo-7-16 2016/08/04 02:33:42 You can probably skip this comment - it says nothi
ftang 2016/08/05 04:45:27 Done.
+extern const base::Feature kTranslateLanguageByULP;
+
class TranslateClient;
class TranslateDriver;
class TranslatePrefs;
@@ -52,6 +57,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 +109,23 @@ class TranslateManager {
static void SetIgnoreMissingKeyForTesting(bool ignore);
private:
+ FRIEND_TEST_ALL_PREFIXES(TranslateManagerTest, TestGetTargetLanguageFromULP);
+ FRIEND_TEST_ALL_PREFIXES(TranslateManagerTest, TestLanguageInULP);
+
// 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 TranslatePrefs* prefs,
+ 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