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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java

Issue 1354763003: [Contextual Search] Trigger the translation one-box. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java
index b7c134d46e2a60ac6ac9210c0d1b47f271e78aef..495fe54fb166edfff5ffdcb865a68bb84a8bf894 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.contextualsearch;
import android.content.Context;
+import android.text.TextUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeVersionInfo;
@@ -318,6 +319,19 @@ class ContextualSearchPolicy {
return mPreferenceManager.getContextualSearchTapCount();
}
+ /**
+ * Determines whether translation is needed between the given languages.
+ * @param source The source language code; language we're translating from.
+ * @param target The target language code; language we're translating to.
+ * @return Whether translation is needed or not.
+ */
+ boolean needsTranslation(@Nullable String source, @Nullable String target) {
+ // For now, we just check to see if the major language is the same, ignoring
+ // local variations, so pt-BR will match pt-PT. We do this because it
+ // seems unlikely the user would want translations from different dialects.
+ return !TextUtils.equals(source.substring(0, 2), target.substring(0, 2));
pedro (no code reviews) 2015/09/23 18:33:54 I think we should also take into consideration oth
Donn Denman 2015/10/09 22:08:23 Done.
+ }
+
// --------------------------------------------------------------------------------------------
// Private helpers.
// --------------------------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698