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

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: 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..2f85cef41d82408897549e92f4a5c9fd55d6d904 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 user has entered incognito mode.
+ */
+ boolean isIncognito();
+
+ /**
* 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.isIncognito()) {
Changwan Ryu 2017/05/23 18:54:23 This should arguably be assert mUrlBarDelegate !=
Ted C 2017/05/23 19:17:55 I think the null and assert seems safest. I would
+ 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