Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Revert "Remove AccessibilityInjector support."
Browse files Browse the repository at this point in the history
This reverts commit eeffed4.
  • Loading branch information
Lin Sun authored and Raphael Kubo da Costa committed Jul 27, 2015
1 parent 98c615b commit ecadc9f
Show file tree
Hide file tree
Showing 18 changed files with 1,094 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public void exitFullscreen() {
}
}

@Override
public boolean isJavascriptEnabled() {
return mAwSettings != null && mAwSettings.getJavaScriptEnabled();
}

@Override
public boolean isExternalFlingActive() {
return mAwContents.isFlingActive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2310,14 +2310,14 @@ public AccessibilityNodeProvider getAccessibilityNodeProvider() {
* @see android.webkit.WebView#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo)
*/
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
// TODO(boliu): remove this method.
if (!isDestroyed()) mContentViewCore.onInitializeAccessibilityNodeInfo(info);
}

/**
* @see android.webkit.WebView#onInitializeAccessibilityEvent(AccessibilityEvent)
*/
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
// TODO(boliu): remove this method.
if (!isDestroyed()) mContentViewCore.onInitializeAccessibilityEvent(event);
}

public boolean supportsAccessibilityAction(int action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
Expand Down Expand Up @@ -409,6 +411,20 @@ public AccessibilityNodeProvider getAccessibilityNodeProvider() {
return provider == null ? super.getAccessibilityNodeProvider() : provider;
}

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setClassName(AwContents.class.getName());
mAwContents.onInitializeAccessibilityNodeInfo(info);
}

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
event.setClassName(AwContents.class.getName());
mAwContents.onInitializeAccessibilityEvent(event);
}

@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
return mAwContents.performAccessibilityAction(action, arguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2015 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;

import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.content.browser.ContentViewClient;

/**
* The default {@link ContentViewClient} implementation for the chrome layer embedders.
*/
public class ChromeContentViewClient extends ContentViewClient {

@Override
public boolean isJavascriptEnabled() {
return PrefServiceBridge.getInstance().javaScriptEnabled();
}

}
10 changes: 7 additions & 3 deletions chrome/android/java/src/org/chromium/chrome/browser/Tab.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public void openNewTab(String url, String extraHeaders, byte[] postData, int dis
* ContentViewClient that provides basic tab functionality and is meant to be extended
* by child classes.
*/
protected class TabContentViewClient extends ContentViewClient {
protected class TabContentViewClient extends ChromeContentViewClient {
@Override
public void onUpdateTitle(String title) {
updateTitle(title);
Expand Down Expand Up @@ -1506,6 +1506,10 @@ protected void didStartPageLoad(String validatedUrl, boolean showingErrorPage) {
updateTitle();
removeSadTabIfPresent();

if (getContentViewCore() != null) {
getContentViewCore().stopCurrentAccessibilityNotifications();
}

clearHungRendererState();

for (TabObserver observer : mObservers) observer.onPageLoadStarted(this);
Expand Down Expand Up @@ -1561,7 +1565,7 @@ public void initializeNative() {
*/
protected void initContentViewCore(WebContents webContents) {
ContentViewCore cvc = new ContentViewCore(mContext);
ContentView cv = new ContentView(mContext, cvc);
ContentView cv = ContentView.newInstance(mContext, cvc);
cv.setContentDescription(mContext.getResources().getString(
R.string.accessibility_content_view));
cvc.initialize(cv, cv, webContents, getWindowAndroid());
Expand Down Expand Up @@ -2175,7 +2179,7 @@ private long getNativePtr() {
public void swapWebContents(
WebContents webContents, boolean didStartLoad, boolean didFinishLoad) {
ContentViewCore cvc = new ContentViewCore(mContext);
ContentView cv = new ContentView(mContext, cvc);
ContentView cv = ContentView.newInstance(mContext, cvc);
cv.setContentDescription(mContext.getResources().getString(
R.string.accessibility_content_view));
cvc.initialize(cv, cv, webContents, getWindowAndroid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import org.chromium.base.ApplicationStatus.ActivityStateListener;
import org.chromium.base.CalledByNative;
import org.chromium.base.FieldTrialList;
import org.chromium.chrome.browser.ChromeContentViewClient;
import org.chromium.chrome.browser.ContentViewUtil;
import org.chromium.chrome.browser.EmptyTabObserver;
import org.chromium.chrome.browser.Tab;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_public.browser.JavaScriptCallback;
import org.chromium.content_public.browser.LoadUrlParams;
Expand Down Expand Up @@ -600,7 +600,7 @@ private void buildContentView() {
if (mNativeTransitionPageHelperPtr == 0) return;

mTransitionContentViewCore = new ContentViewCore(mContext);
ContentView cv = new ContentView(mContext, mTransitionContentViewCore);
ContentView cv = ContentView.newInstance(mContext, mTransitionContentViewCore);
mTransitionContentViewCore.initialize(cv, cv,
ContentViewUtil.createWebContentsWithSharedSiteInstance(mSourceContentViewCore),
mWindowAndroid);
Expand All @@ -617,7 +617,7 @@ private void buildContentView() {
nativeSetWebContents(mNativeTransitionPageHelperPtr, mTransitionContentViewCore);
setTransitionOpacity(0.0f);

mTransitionContentViewCore.setContentViewClient(new ContentViewClient() {
mTransitionContentViewCore.setContentViewClient(new ChromeContentViewClient() {
@Override
public void onOffsetsForFullscreenChanged(
float topControlsOffsetYPix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void run() {
WindowAndroid windowAndroid = new ActivityWindowAndroid(getActivity());

ContentViewCore contentViewCore = new ContentViewCore(getActivity());
ContentView cv = new ContentView(getActivity(), contentViewCore);
ContentView cv = ContentView.newInstance(getActivity(), contentViewCore);
contentViewCore.initialize(cv, cv, webContents, windowAndroid);
contentViewCore.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import android.content.Context;

import org.chromium.chrome.browser.ChromeContentViewClient;
import org.chromium.chrome.browser.Tab;
import org.chromium.chrome.browser.tabmodel.EmptyTabModel;
import org.chromium.chrome.browser.tabmodel.TabModel;
Expand Down Expand Up @@ -85,7 +86,7 @@ public boolean closeAllTabsRequest(boolean incognito) {
public Tab openNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent,
boolean incognito) {
assert !incognito;
ContentViewClient client = new ContentViewClient() {
ContentViewClient client = new ChromeContentViewClient() {
@Override
public ContentVideoViewClient getContentVideoViewClient() {
return mContentVideoViewClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static String normalizeUrl(String uriString) {
private void initFromNativeWebContents(WebContents webContents, int renderProcessId) {
Context context = getContext();
mContentViewCore = new ContentViewCore(context);
ContentView view = new ContentView(context, mContentViewCore);
ContentView view = ContentView.newInstance(context, mContentViewCore);
mContentViewCore.initialize(view, view, webContents, mWindow);
mWebContents = mContentViewCore.getWebContents();
mNavigationController = mWebContents.getNavigationController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.FrameLayout;
Expand All @@ -38,8 +40,17 @@ public class ContentView extends FrameLayout
* @param context The Context the view is running in, through which it can
* access the current theme, resources, etc.
* @param cvc A pointer to the content view core managing this content view.
* @return A ContentView instance.
*/
public ContentView(Context context, ContentViewCore cvc) {
public static ContentView newInstance(Context context, ContentViewCore cvc) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
return new ContentView(context, cvc);
} else {
return new JellyBeanContentView(context, cvc);
}
}

protected ContentView(Context context, ContentViewCore cvc) {
super(context, null, android.R.attr.webViewStyle);

if (getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY) {
Expand All @@ -53,25 +64,6 @@ public ContentView(Context context, ContentViewCore cvc) {
mContentViewCore = cvc;
}

@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
if (mContentViewCore.supportsAccessibilityAction(action)) {
return mContentViewCore.performAccessibilityAction(action, arguments);
}

return super.performAccessibilityAction(action, arguments);
}

@Override
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
AccessibilityNodeProvider provider = mContentViewCore.getAccessibilityNodeProvider();
if (provider != null) {
return provider;
} else {
return super.getAccessibilityNodeProvider();
}
}

// Needed by ContentViewCore.InternalAccessDelegate
@Override
public boolean drawChild(Canvas canvas, View child, long drawingTime) {
Expand Down Expand Up @@ -233,6 +225,22 @@ public boolean awakenScrollBars() {
return super.awakenScrollBars();
}

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
mContentViewCore.onInitializeAccessibilityNodeInfo(info);
}

/**
* Fills in scrolling values for AccessibilityEvents.
* @param event Event being fired.
*/
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
mContentViewCore.onInitializeAccessibilityEvent(event);
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
Expand Down Expand Up @@ -265,7 +273,6 @@ public void setSmartClipResultHandler(final Handler resultHandler) {
return;
}
mContentViewCore.setSmartClipDataListener(new ContentViewCore.SmartClipDataListener() {
@Override
public void onSmartClipDataExtracted(String text, String html, Rect clipRect) {
Bundle bundle = new Bundle();
bundle.putString("url", mContentViewCore.getWebContents().getVisibleUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ public boolean shouldBlockMediaRequest(String url) {
return false;
}

/**
* @return Whether javascript is enabled by the embedder.
*/
// TODO(tedchoc): Only used for ICS accessibility injection, so remove this method when
// that is no longer needed.
public boolean isJavascriptEnabled() {
return true;
}

/**
* @return Whether an externally managed (i.e., not compositor-driven) fling
* of this ContentView is active.
Expand Down
Loading

0 comments on commit ecadc9f

Please sign in to comment.