Chromium Code Reviews| 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. |
| // -------------------------------------------------------------------------------------------- |