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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java

Issue 2901023002: Disable learning text suggestions if in incognito. (Closed)
Patch Set: Switched to explicit method 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java
index f0c4e28f50f1ebc13f130246176aec3253084c3e..815276216ebe433877f0434b5b1faab0543eb56b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java
@@ -27,6 +27,8 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputConnection;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
@@ -55,6 +57,11 @@ public class UrlBar extends AutocompleteEditText {
private static final boolean DEBUG = false;
+ // TODO(tedchoc): Replace with EditorInfoCompat#IME_FLAG_NO_PERSONALIZED_LEARNING or
+ // EditorInfo#IME_FLAG_NO_PERSONALIZED_LEARNING as soon as either is available in
+ // all build config types.
+ private static final int IME_FLAG_NO_PERSONALIZED_LEARNING = 0x1000000;
+
// TextView becomes very slow on long strings, so we limit maximum length
// of what is displayed to the user, see limitDisplayableLength().
private static final int MAX_DISPLAYABLE_LENGTH = 4000;
@@ -141,6 +148,11 @@ public class UrlBar extends AutocompleteEditText {
Tab getCurrentTab();
/**
+ * @return Whether the keyboard should be allowed to learn from the user input.
+ */
+ boolean allowKeyboardLearning();
+
+ /**
* Called when the text state has changed and the autocomplete suggestions should be
* refreshed.
*
@@ -640,6 +652,15 @@ public class UrlBar extends AutocompleteEditText {
}
@Override
+ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
+ InputConnection connection = super.onCreateInputConnection(outAttrs);
+ if (mUrlBarDelegate == null || !mUrlBarDelegate.allowKeyboardLearning()) {
+ outAttrs.imeOptions |= IME_FLAG_NO_PERSONALIZED_LEARNING;
+ }
+ return connection;
+ }
+
+ @Override
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
super.onTextChanged(text, start, lengthBefore, lengthAfter);
mIsPastedText = false;

Powered by Google App Engine
This is Rietveld 408576698