Commit b070a09c authored by Mark Schillaci's avatar Mark Schillaci Committed by Commit Bot

Setting AccessibilityNodeInfo.paneTitle on Android Pie or higher when in a pane

This CL will enable setting paneTitle for AccessibilityNodeInfo on
Android versions Pie/P/10 or higher. We create a new WebContents-
Accessibility subclass specifically for Android P and higher.

Original Buganizer bug can be found:

https://b.corp.google.com/issues/111502315

Bug: 1048694
Change-Id: Icc6aa00210f1aabe513bedf87f9407bef27faac9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037840
Commit-Queue: Mark Schillaci <mschillaci@google.com>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738997}
parent 02f4a8fb
...@@ -798,6 +798,12 @@ jboolean WebContentsAccessibilityAndroid::PopulateAccessibilityNodeInfo( ...@@ -798,6 +798,12 @@ jboolean WebContentsAccessibilityAndroid::PopulateAccessibilityNodeInfo(
node->RangeMax(), node->RangeCurrentValue()); node->RangeMax(), node->RangeCurrentValue());
} }
if (ui::IsDialog(node->GetRole())) {
Java_WebContentsAccessibilityImpl_setAccessibilityNodeInfoPaneTitle(
env, obj, info,
base::android::ConvertUTF16ToJavaString(env, node->GetInnerText()));
}
return true; return true;
} }
......
...@@ -164,6 +164,7 @@ android_library("content_java") { ...@@ -164,6 +164,7 @@ android_library("content_java") {
"java/src/org/chromium/content/browser/accessibility/KitKatWebContentsAccessibility.java", "java/src/org/chromium/content/browser/accessibility/KitKatWebContentsAccessibility.java",
"java/src/org/chromium/content/browser/accessibility/LollipopWebContentsAccessibility.java", "java/src/org/chromium/content/browser/accessibility/LollipopWebContentsAccessibility.java",
"java/src/org/chromium/content/browser/accessibility/OWebContentsAccessibility.java", "java/src/org/chromium/content/browser/accessibility/OWebContentsAccessibility.java",
"java/src/org/chromium/content/browser/accessibility/PieWebContentsAccessibility.java",
"java/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityImpl.java", "java/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityImpl.java",
"java/src/org/chromium/content/browser/accessibility/captioning/CaptioningBridgeFactory.java", "java/src/org/chromium/content/browser/accessibility/captioning/CaptioningBridgeFactory.java",
"java/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegate.java", "java/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegate.java",
......
// Copyright 2020 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.content.browser.accessibility;
import android.annotation.TargetApi;
import android.os.Build;
import android.view.accessibility.AccessibilityNodeInfo;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.content_public.browser.WebContents;
/**
* Subclass of WebContentsAccessibility for P
*/
@JNINamespace("content")
@TargetApi(Build.VERSION_CODES.P)
public class PieWebContentsAccessibility extends OWebContentsAccessibility {
PieWebContentsAccessibility(WebContents webContents) {
super(webContents);
}
@Override
protected void setAccessibilityNodeInfoPaneTitle(AccessibilityNodeInfo node, String title) {
node.setPaneTitle(title);
}
}
...@@ -132,7 +132,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -132,7 +132,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
private static class Factory implements UserDataFactory<WebContentsAccessibilityImpl> { private static class Factory implements UserDataFactory<WebContentsAccessibilityImpl> {
@Override @Override
public WebContentsAccessibilityImpl create(WebContents webContents) { public WebContentsAccessibilityImpl create(WebContents webContents) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return new PieWebContentsAccessibility(webContents);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return new OWebContentsAccessibility(webContents); return new OWebContentsAccessibility(webContents);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return new LollipopWebContentsAccessibility(webContents); return new LollipopWebContentsAccessibility(webContents);
...@@ -1445,6 +1447,11 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -1445,6 +1447,11 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
// Requires O or higher. // Requires O or higher.
} }
@CalledByNative
protected void setAccessibilityNodeInfoPaneTitle(AccessibilityNodeInfo node, String title) {
// Requires P or higher.
}
@CalledByNative @CalledByNative
private void setAccessibilityEventBooleanAttributes(AccessibilityEvent event, boolean checked, private void setAccessibilityEventBooleanAttributes(AccessibilityEvent event, boolean checked,
boolean enabled, boolean password, boolean scrollable) { boolean enabled, boolean password, boolean scrollable) {
......
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