Commit 43cfe748 authored by Sam Maier's avatar Sam Maier Committed by Commit Bot

Mitigating UrlBar class verification failures

We are minimizing the impact of class verification failures for UrlBar by
putting all the failures into their own subclass. Thus, only the subclass
will fail.

No-Presubmit: true
Bug: 999165
Change-Id: I12ea5e29cdfac7973dbec26b44a1f0b7adf21e3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1803730
Commit-Queue: Sam Maier <smaier@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698618}
parent 92389f75
...@@ -1114,6 +1114,7 @@ chrome_java_sources = [ ...@@ -1114,6 +1114,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/omnibox/SearchEngineLogoUtils.java", "java/src/org/chromium/chrome/browser/omnibox/SearchEngineLogoUtils.java",
"java/src/org/chromium/chrome/browser/omnibox/SpannableAutocompleteEditTextModel.java", "java/src/org/chromium/chrome/browser/omnibox/SpannableAutocompleteEditTextModel.java",
"java/src/org/chromium/chrome/browser/omnibox/UrlBar.java", "java/src/org/chromium/chrome/browser/omnibox/UrlBar.java",
"java/src/org/chromium/chrome/browser/omnibox/UrlBarApi26.java",
"java/src/org/chromium/chrome/browser/omnibox/UrlBarCoordinator.java", "java/src/org/chromium/chrome/browser/omnibox/UrlBarCoordinator.java",
"java/src/org/chromium/chrome/browser/omnibox/UrlBarData.java", "java/src/org/chromium/chrome/browser/omnibox/UrlBarData.java",
"java/src/org/chromium/chrome/browser/omnibox/UrlBarEditingTextStateProvider.java", "java/src/org/chromium/chrome/browser/omnibox/UrlBarEditingTextStateProvider.java",
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
style="@style/VerticalDivider" style="@style/VerticalDivider"
android:visibility="gone" /> android:visibility="gone" />
<org.chromium.chrome.browser.omnibox.UrlBar <org.chromium.chrome.browser.omnibox.UrlBarApi26
android:id="@+id/url_bar" android:id="@+id/url_bar"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<org.chromium.chrome.browser.omnibox.UrlBar <org.chromium.chrome.browser.omnibox.UrlBarApi26
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/url_bar" android:id="@+id/url_bar"
android:background="@null" android:background="@null"
......
...@@ -25,7 +25,6 @@ import android.view.GestureDetector; ...@@ -25,7 +25,6 @@ import android.view.GestureDetector;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewStructure;
import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
...@@ -50,7 +49,7 @@ import java.lang.annotation.RetentionPolicy; ...@@ -50,7 +49,7 @@ import java.lang.annotation.RetentionPolicy;
/** /**
* The URL text entry view for the Omnibox. * The URL text entry view for the Omnibox.
*/ */
public class UrlBar extends AutocompleteEditText { public abstract class UrlBar extends AutocompleteEditText {
private static final String TAG = "cr_UrlBar"; private static final String TAG = "cr_UrlBar";
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
...@@ -162,7 +161,7 @@ public class UrlBar extends AutocompleteEditText { ...@@ -162,7 +161,7 @@ public class UrlBar extends AutocompleteEditText {
* rely on AccessibilityNodeInfo data to apply related form-fill data. * rely on AccessibilityNodeInfo data to apply related form-fill data.
*/ */
private CharSequence mTextForAutofillServices; private CharSequence mTextForAutofillServices;
private boolean mRequestingAutofillStructure; protected boolean mRequestingAutofillStructure;
/** /**
* Implement this to get updates when the direction of the text in the URL bar changes. * Implement this to get updates when the direction of the text in the URL bar changes.
...@@ -484,14 +483,6 @@ public class UrlBar extends AutocompleteEditText { ...@@ -484,14 +483,6 @@ public class UrlBar extends AutocompleteEditText {
} }
} }
@Override
public boolean performLongClick(float x, float y) {
if (!shouldPerformLongClick()) return false;
releaseSuppressedTouchDownEvent();
return super.performLongClick(x, y);
}
@Override @Override
public boolean performLongClick() { public boolean performLongClick() {
if (!shouldPerformLongClick()) return false; if (!shouldPerformLongClick()) return false;
...@@ -888,8 +879,8 @@ public class UrlBar extends AutocompleteEditText { ...@@ -888,8 +879,8 @@ public class UrlBar extends AutocompleteEditText {
// To limit displayable length we replace middle portion of the string with ellipsis. // To limit displayable length we replace middle portion of the string with ellipsis.
// That affects only presentation of the text, and doesn't affect other aspects like // That affects only presentation of the text, and doesn't affect other aspects like
// copying to the clipboard, getting text with getText(), etc. // copying to the clipboard, getting text with getText(), etc.
final int maxLength = SysUtils.isLowEndDevice() final int maxLength =
? MAX_DISPLAYABLE_LENGTH_LOW_END : MAX_DISPLAYABLE_LENGTH; SysUtils.isLowEndDevice() ? MAX_DISPLAYABLE_LENGTH_LOW_END : MAX_DISPLAYABLE_LENGTH;
Editable text = getText(); Editable text = getText();
int textLength = text.length(); int textLength = text.length();
...@@ -929,15 +920,6 @@ public class UrlBar extends AutocompleteEditText { ...@@ -929,15 +920,6 @@ public class UrlBar extends AutocompleteEditText {
} }
} }
@Override
public void onProvideAutofillStructure(ViewStructure structure, int autofillFlags) {
// https://crbug.com/996402: Prevent breaking autofill services on newer versions of
// Android.
mRequestingAutofillStructure = true;
super.onProvideAutofillStructure(structure, autofillFlags);
mRequestingAutofillStructure = false;
}
@Override @Override
public Editable getText() { public Editable getText() {
return mRequestingAutofillStructure ? new SpannableStringBuilder(mTextForAutofillServices) return mRequestingAutofillStructure ? new SpannableStringBuilder(mTextForAutofillServices)
...@@ -984,14 +966,14 @@ public class UrlBar extends AutocompleteEditText { ...@@ -984,14 +966,14 @@ public class UrlBar extends AutocompleteEditText {
public static final EllipsisSpan INSTANCE = new EllipsisSpan(); public static final EllipsisSpan INSTANCE = new EllipsisSpan();
@Override @Override
public int getSize(Paint paint, CharSequence text, public int getSize(
int start, int end, Paint.FontMetricsInt fm) { Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
return (int) paint.measureText(ELLIPSIS); return (int) paint.measureText(ELLIPSIS);
} }
@Override @Override
public void draw(Canvas canvas, CharSequence text, int start, int end, public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top,
float x, int top, int y, int bottom, Paint paint) { int y, int bottom, Paint paint) {
canvas.drawText(ELLIPSIS, x, y, paint); canvas.drawText(ELLIPSIS, x, y, paint);
} }
} }
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.omnibox;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewStructure;
import org.chromium.base.annotations.VerifiesOnO;
/**
* Sub-class of UrlBar that contains newer Android APIs to avoid verification errors.
*
* Only super calls to new Android APIs belong here - if it is a normal call to a new Android API,
* use ApiHelperForX. See crbug.com/999165 for more description of what verification errors are and
* why they are expensive.
*/
@VerifiesOnO
public class UrlBarApi26 extends UrlBar {
public UrlBarApi26(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void onProvideAutofillStructure(ViewStructure structure, int autofillFlags) {
// https://crbug.com/996402: Prevent breaking autofill services on newer versions of
// Android.
mRequestingAutofillStructure = true;
super.onProvideAutofillStructure(structure, autofillFlags);
mRequestingAutofillStructure = false;
}
}
...@@ -43,7 +43,7 @@ public class UrlBarUnitTest { ...@@ -43,7 +43,7 @@ public class UrlBarUnitTest {
Activity activity = Robolectric.buildActivity(Activity.class).setup().get(); Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
mUrlBar = new UrlBar(activity, null); mUrlBar = new UrlBarApi26(activity, null);
mUrlBar.setDelegate(mUrlBarDelegate); mUrlBar.setDelegate(mUrlBarDelegate);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment