diff options
author | mkosiba <mkosiba@chromium.org> | 2014-12-11 08:29:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-11 16:29:59 +0000 |
commit | 93a6f5fe74f827f6d38e83e469863da6d35e7144 (patch) | |
tree | 7657e36419d149f01b3ab7304c8f502a94134bd5 /android_webview | |
parent | 29022c572fbd857e94f9e1d1eb5c19ed285863a2 (diff) | |
download | chromium_src-93a6f5fe74f827f6d38e83e469863da6d35e7144.zip chromium_src-93a6f5fe74f827f6d38e83e469863da6d35e7144.tar.gz chromium_src-93a6f5fe74f827f6d38e83e469863da6d35e7144.tar.bz2 |
Make the android_webview/glue code actually work.
This patch contains a number of fixes to the glue:
- use the actual package name instead of a hardcoded value when referencing
resources (note: this makes android_webview/glue not compatible with the
Android.mk-based build),
- fix unused imports, add missing docs,
- fix up style,
- un-commend some @Override that we forgot to un-comment,
- suppress deprecation warnings (unfortunately the only way to suppress
overriding deprecated methods or importing deprecated classes is to
suppress warnings for the entire class).
This change also drops the AOSP glue layer DEPS entry.
TBR=cpu@chromium.org
BUG=440792
Review URL: https://codereview.chromium.org/792103002
Cr-Commit-Position: refs/heads/master@{#307907}
Diffstat (limited to 'android_webview')
24 files changed, 481 insertions, 321 deletions
diff --git a/android_webview/android_webview.gyp b/android_webview/android_webview.gyp index f0a08af..d0e2063 100644 --- a/android_webview/android_webview.gyp +++ b/android_webview/android_webview.gyp @@ -266,7 +266,7 @@ ['android_webview_build==0', { 'includes': [ 'android_webview_tests.gypi', - '../third_party/android_webview_glue/android_webview_glue.gypi', + 'glue/android_webview_glue.gypi', ], 'targets': [ { diff --git a/android_webview/buildbot/aosp_manifest.xml b/android_webview/buildbot/aosp_manifest.xml index 60744d9..79e42df 100644 --- a/android_webview/buildbot/aosp_manifest.xml +++ b/android_webview/buildbot/aosp_manifest.xml @@ -6,8 +6,6 @@ <default remote="aosp" sync-j="6" /> - <!-- Whenever you roll this please also change frameworks/webview in DEPS to point to the - same revision. --> <project name="platform/frameworks/webview" path="frameworks/webview" revision="a770a09ca3346d8ec7cb4cdff90aaf83c8d2c5ff"/> <project groups="device,flo" name="device/asus/deb" revision="f7bd9fa832e3256aa4eb940d1e844f07d966b7ab"/> diff --git a/android_webview/glue/android_webview_glue.gypi b/android_webview/glue/android_webview_glue.gypi new file mode 100644 index 0000000..f862519 --- /dev/null +++ b/android_webview/glue/android_webview_glue.gypi @@ -0,0 +1,35 @@ +# Copyright 2014 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. +{ + 'targets': [ + { + 'target_name': 'system_webview_apk', + 'variables': { + 'apk_name': 'SystemWebView', + 'shared_resources': 1, + }, + 'includes': [ 'android_webview_glue_common.gypi' ], + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/android_webview_assets', + 'files': [], + 'conditions': [ + ['icu_use_data_file_flag==1', { + 'files': [ + '<(PRODUCT_DIR)/icudtl.dat', + ], + }], + ['v8_use_external_startup_data==1', { + 'files': [ + '<(PRODUCT_DIR)/natives_blob.bin', + '<(PRODUCT_DIR)/snapshot_blob.bin', + ], + }], + ], + }, + ], + }, + ], +} + diff --git a/android_webview/glue/android_webview_glue_common.gypi b/android_webview/glue/android_webview_glue_common.gypi new file mode 100644 index 0000000..1490cab --- /dev/null +++ b/android_webview/glue/android_webview_glue_common.gypi @@ -0,0 +1,43 @@ +# Copyright 2014 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. +{ + 'type': 'none', + 'dependencies': [ + '<(DEPTH)/android_webview/android_webview.gyp:libwebviewchromium', + '<(DEPTH)/android_webview/android_webview.gyp:android_webview_java', + '<(DEPTH)/android_webview/android_webview.gyp:android_webview_pak', + ], + 'variables': { + 'android_sdk_jar': '<(DEPTH)/third_party/android_platform/webview/frameworks_1622219.jar', + 'java_in_dir': 'java', + 'native_lib_target': 'libwebviewchromium', + 'never_lint': 1, + 'resource_dir': 'java/res', + 'R_package': 'com.android.webview.chromium', + 'R_package_relpath': 'com/android/webview/chromium', + 'extensions_to_not_compress': 'pak', + 'asset_location': '<(PRODUCT_DIR)/android_webview_assets', + 'proguard_enabled': 'true', + 'proguard_flags_paths': ['java/proguard.flags'], + # TODO: crbug.com/405035 Find a better solution for WebView .pak files. + 'additional_input_paths': [ + '<(PRODUCT_DIR)/android_webview_assets/webviewchromium.pak', + '<(PRODUCT_DIR)/android_webview_assets/en-US.pak', + ], + 'conditions': [ + ['icu_use_data_file_flag==1', { + 'additional_input_paths': [ + '<(PRODUCT_DIR)/icudtl.dat', + ], + }], + ['v8_use_external_startup_data==1', { + 'additional_input_paths': [ + '<(PRODUCT_DIR)/natives_blob.bin', + '<(PRODUCT_DIR)/snapshot_blob.bin', + ], + }], + ], + }, + 'includes': [ '../../build/java_apk.gypi' ], +} diff --git a/android_webview/glue/java/AndroidManifest.xml b/android_webview/glue/java/AndroidManifest.xml new file mode 100644 index 0000000..175969b --- /dev/null +++ b/android_webview/glue/java/AndroidManifest.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (c) 2012 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. +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.webview"> + <uses-sdk android:minSdkVersion="21" + android:targetSdkVersion="21"> + </uses-sdk> + + <uses-feature android:name="android.hardware.touchscreen" + android:required="false"/> + + <application android:label="Android System WebView" + android:icon="@drawable/icon_webview" + android:multiArch="true"> + </application> +</manifest> diff --git a/android_webview/glue/java/proguard.flags b/android_webview/glue/java/proguard.flags new file mode 100644 index 0000000..b19519f --- /dev/null +++ b/android_webview/glue/java/proguard.flags @@ -0,0 +1,101 @@ +# Most of the flags in this file are duplicated to refer to both the pre- and +# post-jarjar remapping versions of the class names. This enables the same +# config file to be used whether jarjar is enabled or not. + + +# Keep the factory and its public members; it's the main entry point used by the +# framework. +-keep class com.android.webview.chromium.WebViewChromiumFactoryProvider { + public *; +} + +# Keep the native methods bound to plat_support. +-keepclasseswithmembers class com.android.webview.chromium.** { + native <methods>; +} + +# Keep everything related to the org.chromium JNI interface. +-keepclasseswithmembers class com.android.org.chromium.** { + @**.AccessedByNative <fields>; +} +-keepclasseswithmembers class com.android.org.chromium.** { + @**.CalledByNative <methods>; +} +-keepclasseswithmembers class com.android.org.chromium.** { + @**.CalledByNativeUnchecked <methods>; +} +-keepclasseswithmembers class com.android.org.chromium.** { + native <methods>; +} + +# Keep methods which get bound to JS interfaces via reflection. +-keepclasseswithmembers class com.android.org.chromium.** { + @**.JavascriptInterface <methods>; +} + +# Silence notes caused by use of @VisibleForTesting inside guava. This doesn't +# happen when using jarjar because @VisibleForTesting gets renamed as well. +-dontnote com.google.common.annotations.VisibleForTesting + +# MediaPlayerBridge uses reflection to access internal metadata. +-dontnote com.android.org.chromium.media.MediaPlayerBridge + +# AndroidKeyStore uses reflection to access internal OpenSSL state. +-dontnote com.android.org.chromium.net.AndroidKeyStore + +# TraceEvent uses reflection to access internal trace info. +-dontnote com.android.org.chromium.content.common.TraceEvent + +# ProxyChangeListener$ProxyReceiver uses reflection to access internal +# android.net.ProxyProperties. +-dontnote com.android.org.chromium.net.ProxyChangeListener$ProxyReceiver + +# com.android.org.chromium.content.app.Linker dynamically casts to $TestRunner +# when running tests. We don't run these tests in WebView. +-dontnote com.android.org.chromium.content.app.Linker$TestRunner + +# We need to keep these explicitly as they are parameters to methods which +# are entry points via @calledByNative. +-keep class com.android.org.chromium.ui.autofill.AutofillSuggestion +-keep class com.android.org.chromium.content.browser.ContentVideoViewClient +-keep class com.android.org.chromium.ui.ColorSuggestion +-keep class com.android.org.chromium.content.browser.input.DateTimeSuggestion +-keep class com.android.org.chromium.content.browser.ContentViewCore$JavaScriptCallback +-keep class com.android.org.chromium.content_public.browser.NavigationController + +# Keep these classes as they are parameters to methods that are native entry points. +-keep class com.android.org.chromium.android_webview.AwBrowserContext +-keep class com.android.org.chromium.base.library_loader.Linker$LibInfo + +# Keep this class and members as accessed via reflection +-keep class com.android.webview.chromium.Drp { + public *; +} + +# Keep finalizer stuff from google-common used via reflection +-keepclassmembers class com.android.org.chromium.com.google.common.** { + *** finalizeReferent(); +} +-keepclassmembers class com.android.org.chromium.com.google.common.** { + *** startFinalizer(java.lang.Class,java.lang.Object); +} + +# Keep support framework support for SmartClip. +-keep class com.android.webview.chromium.WebViewChromium { + public void extractSmartClipData(int,int,int,int); + public void setSmartClipResultHandler(android.os.Handler); +} + +# We need to explicitly keep classes and constructors referenced only in +# layout resources. +-keep class com.android.org.chromium.ui.ColorPickerAdvanced { + <init>(...); +} + +-keep class com.android.org.chromium.ui.ColorPickerSimple { + <init>(...); +} + +-keep class com.android.org.chromium.ui.ColorPickerMoreButton { + <init>(...); +} diff --git a/android_webview/glue/java/src/com/android/webview/chromium/ContentSettingsAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/ContentSettingsAdapter.java index 88f6551..b777d6a 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/ContentSettingsAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/ContentSettingsAdapter.java @@ -8,13 +8,16 @@ import android.util.Log; import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebSettings.PluginState; import android.webkit.WebSettings.RenderPriority; -import android.webkit.WebSettings.TextSize; import android.webkit.WebSettings.ZoomDensity; import org.chromium.android_webview.AwSettings; +/** + * Type adaptation layer between {@link android.webkit.WebSettings} and + * {@link org.chromium.android_webview.AwSettings}. + */ +@SuppressWarnings("deprecation") public class ContentSettingsAdapter extends android.webkit.WebSettings { - private static final String LOGTAG = ContentSettingsAdapter.class.getSimpleName(); private static final boolean TRACE = false; @@ -239,10 +242,10 @@ public class ContentSettingsAdapter extends android.webkit.WebSettings { public synchronized void setLayoutAlgorithm(LayoutAlgorithm l) { // TODO: Remove the upstream enum and mapping once the new value is in the public API. final AwSettings.LayoutAlgorithm[] chromiumValues = { - AwSettings.LayoutAlgorithm.NORMAL, - AwSettings.LayoutAlgorithm.SINGLE_COLUMN, - AwSettings.LayoutAlgorithm.NARROW_COLUMNS, - AwSettings.LayoutAlgorithm.TEXT_AUTOSIZING + AwSettings.LayoutAlgorithm.NORMAL, + AwSettings.LayoutAlgorithm.SINGLE_COLUMN, + AwSettings.LayoutAlgorithm.NARROW_COLUMNS, + AwSettings.LayoutAlgorithm.TEXT_AUTOSIZING }; mAwSettings.setLayoutAlgorithm(chromiumValues[l.ordinal()]); } @@ -251,10 +254,10 @@ public class ContentSettingsAdapter extends android.webkit.WebSettings { public synchronized LayoutAlgorithm getLayoutAlgorithm() { // TODO: Remove the upstream enum and mapping once the new value is in the public API. final LayoutAlgorithm[] webViewValues = { - LayoutAlgorithm.NORMAL, - LayoutAlgorithm.SINGLE_COLUMN, - LayoutAlgorithm.NARROW_COLUMNS, - LayoutAlgorithm.TEXT_AUTOSIZING + LayoutAlgorithm.NORMAL, + LayoutAlgorithm.SINGLE_COLUMN, + LayoutAlgorithm.NARROW_COLUMNS, + LayoutAlgorithm.TEXT_AUTOSIZING }; return webViewValues[mAwSettings.getLayoutAlgorithm().ordinal()]; } @@ -584,22 +587,22 @@ public class ContentSettingsAdapter extends android.webkit.WebSettings { return mAwSettings.getMediaPlaybackRequiresUserGesture(); } -// @Override + @Override public void setMixedContentMode(int mode) { mAwSettings.setMixedContentMode(mode); } -// @Override + @Override public int getMixedContentMode() { return mAwSettings.getMixedContentMode(); } -// @Override + @Override public void setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean flag) { mAwSettings.setVideoOverlayForEmbeddedVideoEnabled(flag); } -// @Override + @Override public boolean getVideoOverlayForEmbeddedEncryptedVideoEnabled() { return mAwSettings.getVideoOverlayForEmbeddedVideoEnabled(); } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/CookieManagerAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/CookieManagerAdapter.java index 547184a..0520cb1 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/CookieManagerAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/CookieManagerAdapter.java @@ -13,8 +13,12 @@ import android.webkit.WebView; import org.chromium.android_webview.AwCookieManager; +/** + * Chromium implementation of CookieManager -- forwards calls to the + * chromium internal implementation. + */ +@SuppressWarnings("deprecation") public class CookieManagerAdapter extends CookieManager { - private static final String LOGTAG = "CookieManager"; AwCookieManager mChromeCookieManager; @@ -144,5 +148,4 @@ public class CookieManagerAdapter extends CookieManager { // do the same normalisation before entering the chromium stack. return new WebAddress(url).toString(); } - } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java b/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java index c27287d..34348b7 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java @@ -4,21 +4,21 @@ package com.android.webview.chromium; -import android.view.View; import android.graphics.Canvas; -import android.util.Log; +import android.view.View; import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; import org.chromium.content.common.CleanupReference; -// Simple Java abstraction and wrapper for the native DrawGLFunctor flow. -// An instance of this class can be constructed, bound to a single view context (i.e. AwContennts) -// and then drawn and detached from the view tree any number of times (using requestDrawGL and -// detach respectively). Then when finished with, it can be explicitly released by calling -// destroy() or will clean itself up as required via finalizer / CleanupReference. +/** + * Simple Java abstraction and wrapper for the native DrawGLFunctor flow. + * An instance of this class can be constructed, bound to a single view context (i.e. AwContennts) + * and then drawn and detached from the view tree any number of times (using requestDrawGL and + * detach respectively). Then when finished with, it can be explicitly released by calling + * destroy() or will clean itself up as required via finalizer / CleanupReference. + */ class DrawGLFunctor { - private static final String TAG = DrawGLFunctor.class.getSimpleName(); // Pointer to native side instance @@ -46,14 +46,14 @@ class DrawGLFunctor { mDestroyRunnable.detachNativeFunctor(); } - public boolean requestDrawGL(Canvas canvas, View containerView, - boolean waitForCompletion) { + public boolean requestDrawGL(Canvas canvas, View containerView, boolean waitForCompletion) { if (mDestroyRunnable.mNativeDrawGLFunctor == 0) { throw new RuntimeException("requested DrawGL on already destroyed DrawGLFunctor"); } if (canvas != null && waitForCompletion) { - throw new IllegalArgumentException("requested a blocking DrawGL with a not null canvas."); + throw new IllegalArgumentException( + "requested a blocking DrawGL with a not null canvas."); } if (!mWebViewDelegate.canInvokeDrawGlFunctor(containerView)) { @@ -63,8 +63,8 @@ class DrawGLFunctor { mDestroyRunnable.mContainerView = containerView; if (canvas == null) { - mWebViewDelegate.invokeDrawGlFunctor(containerView, - mDestroyRunnable.mNativeDrawGLFunctor, waitForCompletion); + mWebViewDelegate.invokeDrawGlFunctor( + containerView, mDestroyRunnable.mNativeDrawGLFunctor, waitForCompletion); return true; } @@ -97,8 +97,7 @@ class DrawGLFunctor { } void detachNativeFunctor() { - if (mNativeDrawGLFunctor != 0 && mContainerView != null - && mWebViewDelegate != null) { + if (mNativeDrawGLFunctor != 0 && mContainerView != null && mWebViewDelegate != null) { mWebViewDelegate.detachDrawGlFunctor(mContainerView, mNativeDrawGLFunctor); } mContainerView = null; diff --git a/android_webview/glue/java/src/com/android/webview/chromium/FileChooserParamsAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/FileChooserParamsAdapter.java index fe7ed55..5e918b1 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/FileChooserParamsAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/FileChooserParamsAdapter.java @@ -12,6 +12,9 @@ import android.webkit.WebChromeClient.FileChooserParams; import org.chromium.android_webview.AwContentsClient; +/** + * Type adaptation class for FileChooserParams. + */ public class FileChooserParamsAdapter extends FileChooserParams { private AwContentsClient.FileChooserParams mParams; @@ -19,8 +22,7 @@ public class FileChooserParamsAdapter extends FileChooserParams { if (resultCode == Activity.RESULT_CANCELED) { return null; } - Uri result = intent == null || resultCode != Activity.RESULT_OK ? null - : intent.getData(); + Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData(); Uri[] uris = null; if (result != null) { @@ -41,8 +43,9 @@ public class FileChooserParamsAdapter extends FileChooserParams { @Override public String[] getAcceptTypes() { - if (mParams.acceptTypes == null) + if (mParams.acceptTypes == null) { return new String[0]; + } return mParams.acceptTypes.split(";"); } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/GeolocationPermissionsAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/GeolocationPermissionsAdapter.java index 6249906..fcb35400 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/GeolocationPermissionsAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/GeolocationPermissionsAdapter.java @@ -16,7 +16,6 @@ import java.util.Set; * chromium internal implementation. */ final class GeolocationPermissionsAdapter extends GeolocationPermissions { - private AwGeolocationPermissions mChromeGeolocationPermissions; public GeolocationPermissionsAdapter(AwGeolocationPermissions chromeGeolocationPermissions) { diff --git a/android_webview/glue/java/src/com/android/webview/chromium/GraphicsUtils.java b/android_webview/glue/java/src/com/android/webview/chromium/GraphicsUtils.java index 20940db..64ff225 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/GraphicsUtils.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/GraphicsUtils.java @@ -15,5 +15,4 @@ abstract class GraphicsUtils { private static native long nativeGetDrawSWFunctionTable(); private static native long nativeGetDrawGLFunctionTable(); - } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/ResourceRewriter.java b/android_webview/glue/java/src/com/android/webview/chromium/ResourceRewriter.java index bee5020..4183f3a 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/ResourceRewriter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/ResourceRewriter.java @@ -4,8 +4,6 @@ package com.android.webview.chromium; -import android.content.Context; - /** * Helper class used to fix up resource ids. * This is mostly a copy of the code in frameworks/base/core/java/android/app/LoadedApk.java. @@ -13,7 +11,6 @@ import android.content.Context; * this code). */ class ResourceRewriter { - /** * Rewrite the R 'constants' for the WebView library apk. */ diff --git a/android_webview/glue/java/src/com/android/webview/chromium/ResourcesContextWrapperFactory.java b/android_webview/glue/java/src/com/android/webview/chromium/ResourcesContextWrapperFactory.java index 29b5bd9..fb64073 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/ResourcesContextWrapperFactory.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/ResourcesContextWrapperFactory.java @@ -7,8 +7,6 @@ package com.android.webview.chromium; import android.content.ComponentCallbacks; import android.content.Context; import android.content.ContextWrapper; -import android.content.res.AssetManager; -import android.content.res.Resources; import android.view.LayoutInflater; import java.util.WeakHashMap; @@ -20,12 +18,11 @@ import java.util.WeakHashMap; * or doubly wrapping contexts. */ public class ResourcesContextWrapperFactory { - private static WeakHashMap<Context,ContextWrapper> sCtxToWrapper - = new WeakHashMap<Context,ContextWrapper>(); + private static WeakHashMap<Context, ContextWrapper> sCtxToWrapper = + new WeakHashMap<Context, ContextWrapper>(); private static final Object sLock = new Object(); - private ResourcesContextWrapperFactory() { - } + private ResourcesContextWrapperFactory() {} public static Context get(Context ctx) { ContextWrapper wrappedCtx; @@ -41,7 +38,7 @@ public class ResourcesContextWrapperFactory { private static ContextWrapper createWrapper(final Context ctx) { return new ContextWrapper(ctx) { - private Context applicationContext; + private Context mApplicationContext; @Override public ClassLoader getClassLoader() { @@ -54,7 +51,8 @@ public class ResourcesContextWrapperFactory { try { return webViewCl.loadClass(name); } catch (ClassNotFoundException e) { - // Look in the app class loader; allowing it to throw ClassNotFoundException. + // Look in the app class loader; allowing it to throw + // ClassNotFoundException. return appCl.loadClass(name); } } @@ -73,9 +71,9 @@ public class ResourcesContextWrapperFactory { @Override public Context getApplicationContext() { - if (applicationContext == null) - applicationContext = get(ctx.getApplicationContext()); - return applicationContext; + if (mApplicationContext == null) + mApplicationContext = get(ctx.getApplicationContext()); + return mApplicationContext; } @Override diff --git a/android_webview/glue/java/src/com/android/webview/chromium/UnimplementedWebViewApi.java b/android_webview/glue/java/src/com/android/webview/chromium/UnimplementedWebViewApi.java index 39372d3..7d46cb5 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/UnimplementedWebViewApi.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/UnimplementedWebViewApi.java @@ -6,9 +6,12 @@ package com.android.webview.chromium; import android.util.Log; -// TODO: remove this when all WebView APIs have been implemented. +/** + * Used to track unimplemented methods. + * TODO: remove this when all WebView APIs have been implemented. + */ public class UnimplementedWebViewApi { - private static String TAG = "UnimplementedWebViewApi"; + private static final String TAG = "UnimplementedWebViewApi"; private static class UnimplementedWebViewApiException extends UnsupportedOperationException { public UnimplementedWebViewApiException() { @@ -16,27 +19,26 @@ public class UnimplementedWebViewApi { } } - private static boolean THROW = false; + private static final boolean THROW = false; // By default we keep the traces down to one frame to reduce noise, but for debugging it might // be useful to set this to true. - private static boolean FULL_TRACE = false; + private static final boolean FULL_TRACE = false; public static void invoke() throws UnimplementedWebViewApiException { if (THROW) { throw new UnimplementedWebViewApiException(); } else { if (FULL_TRACE) { - Log.w(TAG, "Unimplemented WebView method called in: " + - Log.getStackTraceString(new Throwable())); + Log.w(TAG, "Unimplemented WebView method called in: " + + Log.getStackTraceString(new Throwable())); } else { StackTraceElement[] trace = new Throwable().getStackTrace(); // The stack trace [0] index is this method (invoke()). StackTraceElement unimplementedMethod = trace[1]; StackTraceElement caller = trace[2]; - Log.w(TAG, "Unimplemented WebView method " + unimplementedMethod.getMethodName() + - " called from: " + caller.toString()); + Log.w(TAG, "Unimplemented WebView method " + unimplementedMethod.getMethodName() + + " called from: " + caller.toString()); } } } - } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebBackForwardListChromium.java b/android_webview/glue/java/src/com/android/webview/chromium/WebBackForwardListChromium.java index 5e29773..0a49a49 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebBackForwardListChromium.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebBackForwardListChromium.java @@ -4,11 +4,11 @@ package com.android.webview.chromium; -import org.chromium.content_public.browser.NavigationHistory; - import android.webkit.WebBackForwardList; import android.webkit.WebHistoryItem; +import org.chromium.content_public.browser.NavigationHistory; + import java.util.ArrayList; import java.util.List; @@ -20,12 +20,11 @@ public class WebBackForwardListChromium extends WebBackForwardList { private final List<WebHistoryItemChromium> mHistroryItemList; private final int mCurrentIndex; - /* package */ WebBackForwardListChromium(NavigationHistory nav_history) { - mCurrentIndex = nav_history.getCurrentEntryIndex(); - mHistroryItemList = new ArrayList<WebHistoryItemChromium>(nav_history.getEntryCount()); - for (int i = 0; i < nav_history.getEntryCount(); ++i) { - mHistroryItemList.add( - new WebHistoryItemChromium(nav_history.getEntryAtIndex(i))); + /* package */ WebBackForwardListChromium(NavigationHistory navHistory) { + mCurrentIndex = navHistory.getCurrentEntryIndex(); + mHistroryItemList = new ArrayList<WebHistoryItemChromium>(navHistory.getEntryCount()); + for (int i = 0; i < navHistory.getEntryCount(); ++i) { + mHistroryItemList.add(new WebHistoryItemChromium(navHistory.getEntryAtIndex(i))); } } @@ -70,8 +69,7 @@ public class WebBackForwardListChromium extends WebBackForwardList { } // Clone constructor. - private WebBackForwardListChromium(List<WebHistoryItemChromium> list, - int currentIndex) { + private WebBackForwardListChromium(List<WebHistoryItemChromium> list, int currentIndex) { mHistroryItemList = list; mCurrentIndex = currentIndex; } @@ -81,8 +79,7 @@ public class WebBackForwardListChromium extends WebBackForwardList { */ @Override protected synchronized WebBackForwardListChromium clone() { - List<WebHistoryItemChromium> list = - new ArrayList<WebHistoryItemChromium>(getSize()); + List<WebHistoryItemChromium> list = new ArrayList<WebHistoryItemChromium>(getSize()); for (int i = 0; i < getSize(); ++i) { list.add(mHistroryItemList.get(i).clone()); } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebHistoryItemChromium.java b/android_webview/glue/java/src/com/android/webview/chromium/WebHistoryItemChromium.java index b499414..44853da 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebHistoryItemChromium.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebHistoryItemChromium.java @@ -4,15 +4,16 @@ package com.android.webview.chromium; -import org.chromium.content_public.browser.NavigationEntry; - import android.graphics.Bitmap; import android.webkit.WebHistoryItem; +import org.chromium.content_public.browser.NavigationEntry; + /** * WebView Chromium implementation of WebHistoryItem. Simple immutable wrapper * around NavigationEntry */ +@SuppressWarnings("deprecation") public class WebHistoryItemChromium extends WebHistoryItem { private final String mUrl; private final String mOriginalUrl; @@ -68,8 +69,7 @@ public class WebHistoryItemChromium extends WebHistoryItem { } // Clone constructor. - private WebHistoryItemChromium( - String url, String originalUrl, String title, Bitmap favicon) { + private WebHistoryItemChromium(String url, String originalUrl, String title, Bitmap favicon) { mUrl = url; mOriginalUrl = originalUrl; mTitle = title; diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebIconDatabaseAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebIconDatabaseAdapter.java index 1c970d1..e382b74 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebIconDatabaseAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebIconDatabaseAdapter.java @@ -13,6 +13,7 @@ import org.chromium.android_webview.AwContents; /** * Chromium implementation of WebIconDatabase -- big old no-op (base class is deprecated). */ +@SuppressWarnings("deprecation") final class WebIconDatabaseAdapter extends WebIconDatabase { @Override public void open(String path) { @@ -35,8 +36,7 @@ final class WebIconDatabaseAdapter extends WebIconDatabase { } @Override - public void bulkRequestIconForPageUrl(ContentResolver cr, String where, - IconListener listener) { + public void bulkRequestIconForPageUrl(ContentResolver cr, String where, IconListener listener) { // Intentional no-op: hidden in base class. } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebStorageAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebStorageAdapter.java index 9d36fb4..4ead616 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebStorageAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebStorageAdapter.java @@ -7,15 +7,16 @@ package com.android.webview.chromium; import android.webkit.ValueCallback; import android.webkit.WebStorage; +import org.chromium.android_webview.AwQuotaManagerBridge; + import java.util.HashMap; import java.util.Map; -import org.chromium.android_webview.AwQuotaManagerBridge; - /** * Chromium implementation of WebStorage -- forwards calls to the * chromium internal implementation. */ +@SuppressWarnings("deprecation") final class WebStorageAdapter extends WebStorage { private final AwQuotaManagerBridge mQuotaManagerBridge; WebStorageAdapter(AwQuotaManagerBridge quotaManagerBridge) { diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java index 55fe5c8..1a1c640 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java @@ -5,7 +5,6 @@ package com.android.webview.chromium; import android.content.Context; -import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Canvas; @@ -13,12 +12,11 @@ import android.graphics.Paint; import android.graphics.Picture; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.net.Uri; import android.net.http.SslCertificate; import android.os.Build; import android.os.Bundle; -import android.os.Looper; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.print.PrintDocumentAdapter; import android.text.TextUtils; @@ -27,7 +25,6 @@ import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -40,35 +37,31 @@ import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebBackForwardList; import android.webkit.WebChromeClient; +import android.webkit.WebChromeClient.CustomViewCallback; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; -import android.webkit.WebViewFactory; import android.webkit.WebViewProvider; -import android.webkit.WebChromeClient.CustomViewCallback; import android.widget.TextView; -import org.chromium.android_webview.AwBrowserContext; import org.chromium.android_webview.AwContents; import org.chromium.android_webview.AwContentsStatics; -import org.chromium.android_webview.AwLayoutSizer; -import org.chromium.android_webview.AwSettings; import org.chromium.android_webview.AwPrintDocumentAdapter; +import org.chromium.android_webview.AwSettings; import org.chromium.base.ThreadUtils; import org.chromium.content.browser.SmartClipProvider; import org.chromium.content_public.browser.LoadUrlParams; -import org.chromium.net.NetworkChangeNotifier; import java.io.BufferedWriter; import java.io.File; import java.lang.annotation.Annotation; +import java.util.HashMap; +import java.util.Map; +import java.util.Queue; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.FutureTask; import java.util.concurrent.TimeUnit; -import java.util.HashMap; -import java.util.Map; -import java.util.Queue; /** * This class is the delegate to which WebViewProxy forwards all API calls. @@ -78,9 +71,9 @@ import java.util.Queue; * adapters (otherwise org.chromium.content would depend on the webview.chromium package) * and a small set of no-op deprecated APIs. */ -class WebViewChromium implements WebViewProvider, - WebViewProvider.ScrollDelegate, WebViewProvider.ViewDelegate, SmartClipProvider { - +@SuppressWarnings("deprecation") +class WebViewChromium implements WebViewProvider, WebViewProvider.ScrollDelegate, + WebViewProvider.ViewDelegate, SmartClipProvider { private class WebViewChromiumRunQueue { public WebViewChromiumRunQueue() { mQueue = new ConcurrentLinkedQueue<Runnable>(); @@ -104,7 +97,7 @@ class WebViewChromium implements WebViewProvider, } Runnable task = mQueue.poll(); - while(task != null) { + while (task != null) { task.run(); task = mQueue.poll(); } @@ -175,7 +168,7 @@ class WebViewChromium implements WebViewProvider, return task.get(4, TimeUnit.SECONDS); } catch (java.util.concurrent.TimeoutException e) { throw new RuntimeException("Probable deadlock detected due to WebView API being called " - + "on incorrect thread while the UI thread is blocked.", e); + + "on incorrect thread while the UI thread is blocked.", e); } catch (Exception e) { throw new RuntimeException(e); } @@ -208,8 +201,7 @@ class WebViewChromium implements WebViewProvider, } else { Log.w(TAG, msg); TextView warningLabel = new TextView(mContext); - warningLabel.setText(mContext.getString( - R.string.webviewchromium_private_browsing_warning)); + warningLabel.setText(mContext.getString(R.string.private_browsing_warning)); mWebView.addView(warningLabel); } } @@ -229,14 +221,12 @@ class WebViewChromium implements WebViewProvider, final boolean isAccessFromFileURLsGrantedByDefault = mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN; - final boolean areLegacyQuirksEnabled = - mAppTargetSdkVersion < Build.VERSION_CODES.KITKAT; + final boolean areLegacyQuirksEnabled = mAppTargetSdkVersion < Build.VERSION_CODES.KITKAT; - mContentsClientAdapter = new WebViewContentsClientAdapter( - mWebView, mContext, mFactory.getWebViewDelegate()); + mContentsClientAdapter = + new WebViewContentsClientAdapter(mWebView, mContext, mFactory.getWebViewDelegate()); mWebSettings = new ContentSettingsAdapter(new AwSettings( - mContext, isAccessFromFileURLsGrantedByDefault, - areLegacyQuirksEnabled)); + mContext, isAccessFromFileURLsGrantedByDefault, areLegacyQuirksEnabled)); if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { // Prior to Lollipop we always allowed third party cookies and mixed content. @@ -246,24 +236,24 @@ class WebViewChromium implements WebViewProvider, } mRunQueue.addTask(new Runnable() { - @Override - public void run() { - initForReal(); - if (privateBrowsing) { - // Intentionally irreversibly disable the webview instance, so that private - // user data cannot leak through misuse of a non-privateBrowing WebView - // instance. Can't just null out mAwContents as we never null-check it - // before use. - destroy(); - } + @Override + public void run() { + initForReal(); + if (privateBrowsing) { + // Intentionally irreversibly disable the webview instance, so that private + // user data cannot leak through misuse of a non-privateBrowing WebView + // instance. Can't just null out mAwContents as we never null-check it + // before use. + destroy(); } + } }); } private void initForReal() { mAwContents = new AwContents(mFactory.getBrowserContext(), mWebView, mContext, - new InternalAccessAdapter(), new WebViewNativeGLDelegate(), - mContentsClientAdapter, mWebSettings.getAwSettings()); + new InternalAccessAdapter(), new WebViewNativeGLDelegate(), mContentsClientAdapter, + mWebSettings.getAwSettings()); if (mAppTargetSdkVersion >= Build.VERSION_CODES.KITKAT) { // On KK and above, favicons are automatically downloaded as the method @@ -271,8 +261,8 @@ class WebViewChromium implements WebViewProvider, AwContents.setShouldDownloadFavicons(); } - AwContentsStatics.setRecordFullDocument(sRecordWholeDocumentEnabledByApi || - mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP); + AwContentsStatics.setRecordFullDocument(sRecordWholeDocumentEnabledByApi + || mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP); if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { // Prior to Lollipop, JavaScript objects injected via addJavascriptInterface @@ -296,8 +286,7 @@ class WebViewChromium implements WebViewProvider, private boolean checkNeedsPost() { boolean needsPost = !mFactory.hasStarted() || !ThreadUtils.runningOnUiThread(); if (!needsPost && mAwContents == null) { - throw new IllegalStateException( - "AwContents must be created if we are not posting!"); + throw new IllegalStateException("AwContents must be created if we are not posting!"); } return needsPost; } @@ -406,8 +395,8 @@ class WebViewChromium implements WebViewProvider, } @Override - public void setHttpAuthUsernamePassword(final String host, final String realm, - final String username, final String password) { + public void setHttpAuthUsernamePassword( + final String host, final String realm, final String username, final String password) { if (checkNeedsPost()) { mRunQueue.addTask(new Runnable() { @Override @@ -524,21 +513,21 @@ class WebViewChromium implements WebViewProvider, // directly and any result of the evaluation will not replace the current page content. // Matching Chrome behavior more closely; apps targetting >= K that load a JS URL will // have the result of that URL replace the content of the current page. - final String JAVASCRIPT_SCHEME = "javascript:"; - if (mAppTargetSdkVersion < Build.VERSION_CODES.KITKAT && - url != null && url.startsWith(JAVASCRIPT_SCHEME)) { + final String javaScriptScheme = "javascript:"; + if (mAppTargetSdkVersion < Build.VERSION_CODES.KITKAT && url != null + && url.startsWith(javaScriptScheme)) { mFactory.startYourEngines(true); if (checkNeedsPost()) { mRunQueue.addTask(new Runnable() { @Override public void run() { mAwContents.evaluateJavaScriptEvenIfNotYetNavigated( - url.substring(JAVASCRIPT_SCHEME.length())); + url.substring(javaScriptScheme.length())); } }); } else { mAwContents.evaluateJavaScriptEvenIfNotYetNavigated( - url.substring(JAVASCRIPT_SCHEME.length())); + url.substring(javaScriptScheme.length())); } return; } @@ -560,7 +549,7 @@ class WebViewChromium implements WebViewProvider, @Override public void postUrl(String url, byte[] postData) { LoadUrlParams params = LoadUrlParams.createLoadHttpPostParams(url, postData); - Map<String,String> headers = new HashMap<String,String>(); + Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/x-www-form-urlencoded"); params.setExtraHeaders(headers); loadUrlOnUiThread(params); @@ -880,13 +869,13 @@ class WebViewChromium implements WebViewProvider, public WebView.HitTestResult getHitTestResult() { mFactory.startYourEngines(true); if (checkNeedsPost()) { - WebView.HitTestResult ret = runOnUiThreadBlocking( - new Callable<WebView.HitTestResult>() { - @Override - public WebView.HitTestResult call() { - return getHitTestResult(); - } - }); + WebView.HitTestResult ret = + runOnUiThreadBlocking(new Callable<WebView.HitTestResult>() { + @Override + public WebView.HitTestResult call() { + return getHitTestResult(); + } + }); return ret; } AwContents.HitTestData data = mAwContents.getLastHitTestResult(); @@ -935,7 +924,7 @@ class WebViewChromium implements WebViewProvider, }); return ret; } - String url = mAwContents.getUrl(); + String url = mAwContents.getUrl(); if (url == null || url.trim().isEmpty()) return null; return url; } @@ -952,7 +941,7 @@ class WebViewChromium implements WebViewProvider, }); return ret; } - String url = mAwContents.getOriginalUrl(); + String url = mAwContents.getOriginalUrl(); if (url == null || url.trim().isEmpty()) return null; return url; } @@ -1161,8 +1150,7 @@ class WebViewChromium implements WebViewProvider, }); return ret; } - return new WebBackForwardListChromium( - mAwContents.getNavigationHistory()); + return new WebBackForwardListChromium(mAwContents.getNavigationHistory()); } @Override @@ -1307,17 +1295,21 @@ class WebViewChromium implements WebViewProvider, while (clientClass != WebChromeClient.class && (!foundShowMethod || !foundHideMethod)) { if (!foundShowMethod) { try { - clientClass.getDeclaredMethod("onShowCustomView", View.class, - CustomViewCallback.class); + clientClass.getDeclaredMethod( + "onShowCustomView", View.class, CustomViewCallback.class); foundShowMethod = true; - } catch (NoSuchMethodException e) { } + } catch (NoSuchMethodException e) { + // Intentionally empty. + } } if (!foundHideMethod) { try { clientClass.getDeclaredMethod("onHideCustomView"); foundHideMethod = true; - } catch (NoSuchMethodException e) { } + } catch (NoSuchMethodException e) { + // Intentionally empty. + } } clientClass = clientClass.getSuperclass(); } @@ -1325,6 +1317,7 @@ class WebViewChromium implements WebViewProvider, } @Override + @SuppressWarnings("deprecation") public void setPictureListener(final WebView.PictureListener listener) { if (checkNeedsPost()) { mRunQueue.addTask(new Runnable() { @@ -1336,8 +1329,8 @@ class WebViewChromium implements WebViewProvider, return; } mContentsClientAdapter.setPictureListener(listener); - mAwContents.enableOnNewPicture(listener != null, - mAppTargetSdkVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2); + mAwContents.enableOnNewPicture( + listener != null, mAppTargetSdkVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2); } @Override @@ -1353,7 +1346,7 @@ class WebViewChromium implements WebViewProvider, } Class<? extends Annotation> requiredAnnotation = null; if (mAppTargetSdkVersion >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - requiredAnnotation = JavascriptInterface.class; + requiredAnnotation = JavascriptInterface.class; } mAwContents.addPossiblyUnsafeJavascriptInterface(obj, interfaceName, requiredAnnotation); } @@ -1488,12 +1481,11 @@ class WebViewChromium implements WebViewProvider, return this; } - // WebViewProvider.ViewDelegate implementation ------------------------------------------------ // TODO: remove from WebViewProvider and use default implementation from // ViewGroup. - // @Override + @Override public boolean shouldDelayChildPressedState() { mFactory.startYourEngines(false); if (checkNeedsPost()) { @@ -1508,17 +1500,17 @@ class WebViewChromium implements WebViewProvider, return true; } -// @Override + @Override public AccessibilityNodeProvider getAccessibilityNodeProvider() { mFactory.startYourEngines(false); if (checkNeedsPost()) { - AccessibilityNodeProvider ret = runOnUiThreadBlocking( - new Callable<AccessibilityNodeProvider>() { - @Override - public AccessibilityNodeProvider call() { - return getAccessibilityNodeProvider(); - } - }); + AccessibilityNodeProvider ret = + runOnUiThreadBlocking(new Callable<AccessibilityNodeProvider>() { + @Override + public AccessibilityNodeProvider call() { + return getAccessibilityNodeProvider(); + } + }); return ret; } return mAwContents.getAccessibilityNodeProvider(); @@ -1616,8 +1608,8 @@ class WebViewChromium implements WebViewProvider, } @Override - public void onOverScrolled(final int scrollX, final int scrollY, final boolean clampedX, - final boolean clampedY) { + public void onOverScrolled(final int scrollX, final int scrollY, + final boolean clampedX, final boolean clampedY) { if (checkNeedsPost()) { mRunQueue.addTask(new Runnable() { @Override @@ -1693,7 +1685,7 @@ class WebViewChromium implements WebViewProvider, public InputConnection onCreateInputConnection(final EditorInfo outAttrs) { mFactory.startYourEngines(false); if (checkNeedsPost()) { - return null; + return null; } return mAwContents.onCreateInputConnection(outAttrs); } @@ -1803,8 +1795,8 @@ class WebViewChromium implements WebViewProvider, } @Override - public void onFocusChanged(final boolean focused, final int direction, - final Rect previouslyFocusedRect) { + public void onFocusChanged( + final boolean focused, final int direction, final Rect previouslyFocusedRect) { if (checkNeedsPost()) { mRunQueue.addTask(new Runnable() { @Override @@ -1948,8 +1940,8 @@ class WebViewChromium implements WebViewProvider, } @Override - public boolean requestChildRectangleOnScreen(final View child, final Rect rect, - final boolean immediate) { + public boolean requestChildRectangleOnScreen( + final View child, final Rect rect, final boolean immediate) { mFactory.startYourEngines(false); if (checkNeedsPost()) { boolean ret = runOnUiThreadBlocking(new Callable<Boolean>() { @@ -2101,12 +2093,7 @@ class WebViewChromium implements WebViewProvider, mAwContents.computeScroll(); } - // TODO(sgurun) this is only to have master-gpl compiling. - public PrintDocumentAdapter createPrintDocumentAdapter() { - return createPrintDocumentAdapter("default"); - } - - //@Override TODO(sgurun) commenting this out to have master-gpl compiling. + @Override public PrintDocumentAdapter createPrintDocumentAdapter(String documentName) { checkThread(); return new AwPrintDocumentAdapter(mAwContents.getPdfExporter(), documentName); @@ -2115,11 +2102,10 @@ class WebViewChromium implements WebViewProvider, // AwContents.NativeGLDelegate implementation -------------------------------------- private class WebViewNativeGLDelegate implements AwContents.NativeGLDelegate { @Override - public boolean requestDrawGL(Canvas canvas, boolean waitForCompletion, - View containerView) { + public boolean requestDrawGL(Canvas canvas, boolean waitForCompletion, View containerView) { if (mGLfunctor == null) { - mGLfunctor = new DrawGLFunctor(mAwContents.getAwDrawGLViewContext(), - mFactory.getWebViewDelegate()); + mGLfunctor = new DrawGLFunctor( + mAwContents.getAwDrawGLViewContext(), mFactory.getWebViewDelegate()); } return mGLfunctor.requestDrawGL(canvas, containerView, waitForCompletion); } @@ -2194,13 +2180,10 @@ class WebViewChromium implements WebViewProvider, } @Override - public void overScrollBy(int deltaX, int deltaY, - int scrollX, int scrollY, - int scrollRangeX, int scrollRangeY, - int maxOverScrollX, int maxOverScrollY, - boolean isTouchEvent) { - mWebViewPrivate.overScrollBy(deltaX, deltaY, scrollX, scrollY, - scrollRangeX, scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); + public void overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, + int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { + mWebViewPrivate.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, + scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); } @Override @@ -2232,5 +2215,4 @@ class WebViewChromium implements WebViewProvider, checkThread(); mAwContents.setSmartClipResultHandler(resultHandler); } - } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java index 60c7966..caebb6e 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java @@ -4,14 +4,12 @@ package com.android.webview.chromium; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.res.Resources; import android.app.ActivityManager; import android.content.ComponentCallbacks2; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageInfo; import android.net.Uri; import android.os.Build; import android.os.Looper; @@ -19,7 +17,6 @@ import android.os.StrictMode; import android.util.Log; import android.webkit.CookieManager; import android.webkit.GeolocationPermissions; -import android.webkit.WebIconDatabase; import android.webkit.WebStorage; import android.webkit.WebView; import android.webkit.WebViewDatabase; @@ -35,8 +32,6 @@ import org.chromium.android_webview.AwContents; import org.chromium.android_webview.AwContentsStatics; import org.chromium.android_webview.AwCookieManager; import org.chromium.android_webview.AwDevToolsServer; -import org.chromium.android_webview.AwFormDatabase; -import org.chromium.android_webview.AwGeolocationPermissions; import org.chromium.android_webview.AwQuotaManagerBridge; import org.chromium.android_webview.AwResource; import org.chromium.android_webview.AwSettings; @@ -56,8 +51,12 @@ import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; +/** + * Entry point to the WebView. The system framework talks to this class to get instances of the + * implementation classes. + */ +@SuppressWarnings("deprecation") public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { - private static final String TAG = "WebViewChromiumFactoryProvider"; private static final String CHROMIUM_PREFS_NAME = "WebViewChromiumPrefs"; @@ -79,7 +78,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { private AwDevToolsServer mDevToolsServer; private ArrayList<WeakReference<WebViewChromium>> mWebViewsToStart = - new ArrayList<WeakReference<WebViewChromium>>(); + new ArrayList<WeakReference<WebViewChromium>>(); // Read/write protected by mLock. private boolean mStarted; @@ -134,15 +133,15 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { // Use shared preference to check for package downgrade. mWebViewPrefs = mWebViewDelegate.getApplication().getSharedPreferences( - CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); + CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0); int currentVersion = packageInfo.versionCode; if (lastVersion > currentVersion) { // The WebView package has been downgraded since we last ran in this application. // Delete the WebView data directory's contents. String dataDir = PathUtils.getDataDirectory(mWebViewDelegate.getApplication()); - Log.i(TAG, "WebView package downgraded from " + lastVersion + " to " + currentVersion + - "; deleting contents of " + dataDir); + Log.i(TAG, "WebView package downgraded from " + lastVersion + " to " + currentVersion + + "; deleting contents of " + dataDir); deleteContents(new File(dataDir)); } if (lastVersion != currentVersion) { @@ -178,14 +177,14 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { private void ensureChromiumStartedLocked(boolean onMainThread) { assert Thread.holdsLock(mLock); - if (mStarted) { // Early-out for the common case. + if (mStarted) { // Early-out for the common case. return; } Looper looper = !onMainThread ? Looper.myLooper() : Looper.getMainLooper(); - Log.v(TAG, "Binding Chromium to " + - (Looper.getMainLooper().equals(looper) ? "main":"background") + - " looper " + looper); + Log.v(TAG, "Binding Chromium to " + + (Looper.getMainLooper().equals(looper) ? "main" : "background") + + " looper " + looper); ThreadUtils.setUiThread(looper); if (ThreadUtils.runningOnUiThread()) { @@ -213,6 +212,12 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { } } + // TODO: DIR_RESOURCE_PAKS_ANDROID needs to live somewhere sensible, + // inlined here for simplicity setting up the HTMLViewer demo. Unfortunately + // it can't go into base.PathService, as the native constant it refers to + // lives in the ui/ layer. See ui/base/ui_base_paths.h + private static final int DIR_RESOURCE_PAKS_ANDROID = 3003; + private void startChromiumLocked() { assert Thread.holdsLock(mLock) && ThreadUtils.runningOnUiThread(); @@ -230,18 +235,12 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { try { LibraryLoader.ensureInitialized(); - } catch(ProcessInitException e) { + } catch (ProcessInitException e) { throw new RuntimeException("Error initializing WebView library", e); } PathService.override(PathService.DIR_MODULE, "/system/lib/"); - // TODO: DIR_RESOURCE_PAKS_ANDROID needs to live somewhere sensible, - // inlined here for simplicity setting up the HTMLViewer demo. Unfortunately - // it can't go into base.PathService, as the native constant it refers to - // lives in the ui/ layer. See ui/base/ui_base_paths.h - final int DIR_RESOURCE_PAKS_ANDROID = 3003; - PathService.override(DIR_RESOURCE_PAKS_ANDROID, - "/system/framework/webview/paks"); + PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webview/paks"); // Make sure that ResourceProvider is initialized before starting the browser process. Context context = getWrappedCurrentApplicationContext(); @@ -280,7 +279,6 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { void startYourEngines(boolean onMainThread) { synchronized (mLock) { ensureChromiumStartedLocked(onMainThread); - } } @@ -318,14 +316,13 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { private void setUpResources(Context context) { // The resources are always called com.android.webview even if the manifest has had the // package renamed. + final String packageName = WebViewFactory.getLoadedPackageInfo().packageName; ResourceRewriter.rewriteRValues( - mWebViewDelegate.getPackageId(context.getResources(), "com.android.webview")); + mWebViewDelegate.getPackageId(context.getResources(), packageName)); AwResource.setResources(context.getResources()); - AwResource.setErrorPageResources(android.R.raw.loaderror, - android.R.raw.nodomain); - AwResource.setConfigKeySystemUuidMapping( - android.R.array.config_keySystemUuidMapping); + AwResource.setErrorPageResources(android.R.raw.loaderror, android.R.raw.nodomain); + AwResource.setConfigKeySystemUuidMapping(android.R.array.config_keySystemUuidMapping); } @Override @@ -351,8 +348,8 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { public void setWebContentsDebuggingEnabled(boolean enable) { // Web Contents debugging is always enabled on debug builds. if (!isBuildDebuggable()) { - WebViewChromiumFactoryProvider.this. - setWebContentsDebuggingEnabled(enable); + WebViewChromiumFactoryProvider.this.setWebContentsDebuggingEnabled( + enable); } } @@ -428,7 +425,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { } @Override - public WebIconDatabase getWebIconDatabase() { + public android.webkit.WebIconDatabase getWebIconDatabase() { synchronized (mLock) { if (mWebIconDatabase == null) { ensureChromiumStartedLocked(true); @@ -455,8 +452,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { if (mWebViewDatabase == null) { ensureChromiumStartedLocked(true); AwBrowserContext browserContext = getBrowserContextLocked(); - mWebViewDatabase = new WebViewDatabaseAdapter( - browserContext.getFormDatabase(), + mWebViewDatabase = new WebViewDatabaseAdapter(browserContext.getFormDatabase(), browserContext.getHttpAuthDatabase(context)); } } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java index c6b0c82..0c97d69 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java @@ -13,11 +13,10 @@ import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Picture; -import android.net.http.SslError; import android.net.Uri; +import android.net.http.SslError; import android.os.Build; import android.os.Handler; -import android.os.Looper; import android.os.Message; import android.provider.Browser; import android.util.Log; @@ -35,8 +34,8 @@ import android.webkit.SslErrorHandler; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebChromeClient.CustomViewCallback; -import android.webkit.WebResourceResponse; import android.webkit.WebResourceRequest; +import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -81,6 +80,7 @@ import java.util.WeakHashMap; * allow the source WebView to be injected by ContentViewClientAdapter. We * choose the latter, because it makes for a cleaner design. */ +@SuppressWarnings("deprecation") public class WebViewContentsClientAdapter extends AwContentsClient { // TAG is chosen for consistency with classic webview tracing. private static final String TAG = "WebViewCallback"; @@ -130,23 +130,22 @@ public class WebViewContentsClientAdapter extends AwContentsClient { setWebViewClient(null); mUiThreadHandler = new Handler() { - @Override public void handleMessage(Message msg) { - switch(msg.what) { + switch (msg.what) { case NEW_WEBVIEW_CREATED: WebView.WebViewTransport t = (WebView.WebViewTransport) msg.obj; WebView newWebView = t.getWebView(); if (newWebView == mWebView) { throw new IllegalArgumentException( - "Parent WebView cannot host it's own popup window. Please " + - "use WebSettings.setSupportMultipleWindows(false)"); + "Parent WebView cannot host it's own popup window. Please " + + "use WebSettings.setSupportMultipleWindows(false)"); } if (newWebView != null && newWebView.copyBackForwardList().getSize() != 0) { throw new IllegalArgumentException( - "New WebView for popup window must not have been previously " + - "navigated."); + "New WebView for popup window must not have been previously " + + "navigated."); } WebViewChromium.completeWindowCreation(mWebView, newWebView); @@ -156,7 +155,6 @@ public class WebViewContentsClientAdapter extends AwContentsClient { } } }; - } // WebViewClassic is coded in such a way that even if a null WebViewClient is set, @@ -194,8 +192,7 @@ public class WebViewContentsClientAdapter extends AwContentsClient { } // Pass the package name as application ID so that the intent from the // same application can be opened in the same tab. - intent.putExtra(Browser.EXTRA_APPLICATION_ID, - view.getContext().getPackageName()); + intent.putExtra(Browser.EXTRA_APPLICATION_ID, view.getContext().getPackageName()); Context context = view.getContext(); if (!(context instanceof Activity)) { @@ -317,15 +314,14 @@ public class WebViewContentsClientAdapter extends AwContentsClient { public AwWebResourceResponse shouldInterceptRequest(ShouldInterceptRequestParams params) { TraceEvent.begin(); if (TRACE) Log.d(TAG, "shouldInterceptRequest=" + params.url); - WebResourceResponse response = mWebViewClient.shouldInterceptRequest(mWebView, - new WebResourceRequestImpl(params)); + WebResourceResponse response = + mWebViewClient.shouldInterceptRequest(mWebView, new WebResourceRequestImpl(params)); TraceEvent.end(); if (response == null) return null; // AwWebResourceResponse should support null headers. b/16332774. Map<String, String> responseHeaders = response.getResponseHeaders(); - if (responseHeaders == null) - responseHeaders = new HashMap<String, String>(); + if (responseHeaders == null) responseHeaders = new HashMap<String, String>(); return new AwWebResourceResponse( response.getMimeType(), @@ -559,7 +555,6 @@ public class WebViewContentsClientAdapter extends AwContentsClient { TraceEvent.end(); } - /** * @see ContentViewClient#shouldOverrideKeyEvent(KeyEvent) */ @@ -578,7 +573,6 @@ public class WebViewContentsClientAdapter extends AwContentsClient { return result; } - /** * @see ContentViewClient#onStartContentIntent(Context, String) * Callback when detecting a click on a content link. @@ -618,8 +612,8 @@ public class WebViewContentsClientAdapter extends AwContentsClient { if (mWebChromeClient != null) { if (TRACE) Log.d(TAG, "onPermissionRequest"); if (mOngoingPermissionRequests == null) { - mOngoingPermissionRequests = - new WeakHashMap<AwPermissionRequest, WeakReference<PermissionRequestAdapter>>(); + mOngoingPermissionRequests = new WeakHashMap<AwPermissionRequest, + WeakReference<PermissionRequestAdapter>>(); } PermissionRequestAdapter adapter = new PermissionRequestAdapter(permissionRequest); mOngoingPermissionRequests.put( @@ -760,8 +754,8 @@ public class WebViewContentsClientAdapter extends AwContentsClient { public void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String host, String realm) { TraceEvent.begin(); if (TRACE) Log.d(TAG, "onReceivedHttpAuthRequest=" + host); - mWebViewClient.onReceivedHttpAuthRequest(mWebView, - new AwHttpAuthHandlerAdapter(handler), host, realm); + mWebViewClient.onReceivedHttpAuthRequest( + mWebView, new AwHttpAuthHandlerAdapter(handler), host, realm); TraceEvent.end(); } @@ -784,16 +778,15 @@ public class WebViewContentsClientAdapter extends AwContentsClient { } private static class ClientCertRequestImpl extends ClientCertRequest { - - final private AwContentsClientBridge.ClientCertificateRequestCallback mCallback; - final private String[] mKeyTypes; - final private Principal[] mPrincipals; - final private String mHost; - final private int mPort; + private final AwContentsClientBridge.ClientCertificateRequestCallback mCallback; + private final String[] mKeyTypes; + private final Principal[] mPrincipals; + private final String mHost; + private final int mPort; public ClientCertRequestImpl( - AwContentsClientBridge.ClientCertificateRequestCallback callback, - String[] keyTypes, Principal[] principals, String host, int port) { + AwContentsClientBridge.ClientCertificateRequestCallback callback, String[] keyTypes, + Principal[] principals, String host, int port) { mCallback = callback; mKeyTypes = keyTypes; mPrincipals = principals; @@ -841,12 +834,12 @@ public class WebViewContentsClientAdapter extends AwContentsClient { @Override public void onReceivedClientCertRequest( - AwContentsClientBridge.ClientCertificateRequestCallback callback, - String[] keyTypes, Principal[] principals, String host, int port) { + AwContentsClientBridge.ClientCertificateRequestCallback callback, String[] keyTypes, + Principal[] principals, String host, int port) { if (TRACE) Log.d(TAG, "onReceivedClientCertRequest"); TraceEvent.begin(); - final ClientCertRequestImpl request = new ClientCertRequestImpl(callback, - keyTypes, principals, host, port); + final ClientCertRequestImpl request = + new ClientCertRequestImpl(callback, keyTypes, principals, host, port); mWebViewClient.onReceivedClientCertRequest(mWebView, request); TraceEvent.end(); } @@ -868,19 +861,17 @@ public class WebViewContentsClientAdapter extends AwContentsClient { } @Override - public void onDownloadStart(String url, - String userAgent, - String contentDisposition, - String mimeType, - long contentLength) { + public void onDownloadStart( + String url, + String userAgent, + String contentDisposition, + String mimeType, + long contentLength) { if (mDownloadListener != null) { TraceEvent.begin(); if (TRACE) Log.d(TAG, "onDownloadStart"); - mDownloadListener.onDownloadStart(url, - userAgent, - contentDisposition, - mimeType, - contentLength); + mDownloadListener.onDownloadStart( + url, userAgent, contentDisposition, mimeType, contentLength); TraceEvent.end(); } } @@ -893,8 +884,8 @@ public class WebViewContentsClientAdapter extends AwContentsClient { return; } TraceEvent.begin(); - FileChooserParamsAdapter adapter = new FileChooserParamsAdapter( - fileChooserParams, mContext); + FileChooserParamsAdapter adapter = + new FileChooserParamsAdapter(fileChooserParams, mContext); if (TRACE) Log.d(TAG, "showFileChooser"); ValueCallback<Uri[]> callbackAdapter = new ValueCallback<Uri[]>() { private boolean mCompleted; @@ -907,7 +898,7 @@ public class WebViewContentsClientAdapter extends AwContentsClient { String s[] = null; if (uriList != null) { s = new String[uriList.length]; - for(int i = 0; i < uriList.length; i++) { + for (int i = 0; i < uriList.length; i++) { s[i] = uriList[i].toString(); } } @@ -923,8 +914,7 @@ public class WebViewContentsClientAdapter extends AwContentsClient { // If the app did not handle it and we are running on Lollipop or newer, then // abort. - if (mContext.getApplicationInfo().targetSdkVersion >= - Build.VERSION_CODES.LOLLIPOP) { + if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) { uploadFileCallback.onReceiveValue(null); return; } @@ -940,12 +930,12 @@ public class WebViewContentsClientAdapter extends AwContentsClient { } mCompleted = true; uploadFileCallback.onReceiveValue( - uri == null ? null : new String[] { uri.toString() }); + uri == null ? null : new String[] {uri.toString()}); } }; if (TRACE) Log.d(TAG, "openFileChooser"); - mWebChromeClient.openFileChooser(innerCallback, fileChooserParams.acceptTypes, - fileChooserParams.capture ? "*" : ""); + mWebChromeClient.openFileChooser( + innerCallback, fileChooserParams.acceptTypes, fileChooserParams.capture ? "*" : ""); TraceEvent.end(); } @@ -1003,8 +993,7 @@ public class WebViewContentsClientAdapter extends AwContentsClient { // The ic_media_video_poster icon is transparent so we need to draw it on a gray // background. Bitmap poster = BitmapFactory.decodeResource( - mContext.getResources(), - R.drawable.ic_media_video_poster); + mContext.getResources(), R.drawable.ic_media_video_poster); result = Bitmap.createBitmap(poster.getWidth(), poster.getHeight(), poster.getConfig()); result.eraseColor(Color.GRAY); Canvas canvas = new Canvas(result); @@ -1045,12 +1034,15 @@ public class WebViewContentsClientAdapter extends AwContentsClient { } } - // TODO: Move to the upstream once the PermissionRequest is part of SDK. + /** + * Type adaptation class for PermissionRequest. + * TODO: Move to the upstream once the PermissionRequest is part of SDK. + */ public static class PermissionRequestAdapter extends PermissionRequest { // TODO: Move the below definitions to AwPermissionRequest. - private static long BITMASK_RESOURCE_VIDEO_CAPTURE = 1 << 1; - private static long BITMASK_RESOURCE_AUDIO_CAPTURE = 1 << 2; - private static long BITMASK_RESOURCE_PROTECTED_MEDIA_ID = 1 << 3; + private static final long BITMASK_RESOURCE_VIDEO_CAPTURE = 1 << 1; + private static final long BITMASK_RESOURCE_AUDIO_CAPTURE = 1 << 2; + private static final long BITMASK_RESOURCE_PROTECTED_MEDIA_ID = 1 << 3; public static long toAwPermissionResources(String[] resources) { long result = 0; @@ -1113,6 +1105,5 @@ public class WebViewContentsClientAdapter extends AwContentsClient { public void deny() { mAwPermissionRequest.deny(); } - } } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java index b7afa7c..e003ea5 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java @@ -4,7 +4,6 @@ package com.android.webview.chromium; -import android.content.Context; import android.webkit.WebViewDatabase; import org.chromium.android_webview.AwFormDatabase; @@ -14,8 +13,8 @@ import org.chromium.android_webview.HttpAuthDatabase; * Chromium implementation of WebViewDatabase -- forwards calls to the * chromium internal implementation. */ +@SuppressWarnings("deprecation") final class WebViewDatabaseAdapter extends WebViewDatabase { - private AwFormDatabase mFormDatabase; private HttpAuthDatabase mHttpAuthDatabase; diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewDelegateFactory.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewDelegateFactory.java index 8f713dc..27155fa 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewDelegateFactory.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewDelegateFactory.java @@ -11,12 +11,9 @@ import android.content.res.AssetManager; import android.content.res.Resources; import android.graphics.Canvas; import android.os.Trace; -import android.util.Log; import android.util.SparseArray; import android.view.View; -import android.webkit.WebViewFactory; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** @@ -36,7 +33,6 @@ import java.lang.reflect.Method; * {@link android.webkit.WebViewDelegate android.webkit.WebViewDelegate} directly instead. */ class WebViewDelegateFactory { - /** * Copy of {@link android.webkit.WebViewDelegate android.webkit.WebViewDelegate}'s interface. * See {@link WebViewDelegateFactory} for the reasons why this copy is needed. @@ -57,8 +53,8 @@ class WebViewDelegateFactory { boolean canInvokeDrawGlFunctor(View containerView); /** @see android.webkit.WebViewDelegate#invokeDrawGlFunctor */ - void invokeDrawGlFunctor(View containerView, long nativeDrawGLFunctor, - boolean waitForCompletion); + void invokeDrawGlFunctor( + View containerView, long nativeDrawGLFunctor, boolean waitForCompletion); /** @see android.webkit.WebViewDelegate#callDrawGlFunction */ void callDrawGlFunction(Canvas canvas, long nativeDrawGLFunctor); @@ -106,69 +102,67 @@ class WebViewDelegateFactory { * to a {@link android.webkit.WebViewDelegate android.webkit.WebViewDelegate}. */ private static class ProxyDelegate implements WebViewDelegate { - - android.webkit.WebViewDelegate delegate; + android.webkit.WebViewDelegate mDelegate; ProxyDelegate(android.webkit.WebViewDelegate delegate) { - this.delegate = delegate; + mDelegate = delegate; } @Override public void setOnTraceEnabledChangeListener(final OnTraceEnabledChangeListener listener) { - delegate.setOnTraceEnabledChangeListener( + mDelegate.setOnTraceEnabledChangeListener( new android.webkit.WebViewDelegate.OnTraceEnabledChangeListener() { @Override public void onTraceEnabledChange(boolean enabled) { listener.onTraceEnabledChange(enabled); - ; } }); } @Override public boolean isTraceTagEnabled() { - return delegate.isTraceTagEnabled(); + return mDelegate.isTraceTagEnabled(); } @Override public boolean canInvokeDrawGlFunctor(View containerView) { - return delegate.canInvokeDrawGlFunctor(containerView); + return mDelegate.canInvokeDrawGlFunctor(containerView); } @Override - public void invokeDrawGlFunctor(View containerView, long nativeDrawGLFunctor, - boolean waitForCompletion) { - delegate.invokeDrawGlFunctor(containerView, nativeDrawGLFunctor, waitForCompletion); + public void invokeDrawGlFunctor( + View containerView, long nativeDrawGLFunctor, boolean waitForCompletion) { + mDelegate.invokeDrawGlFunctor(containerView, nativeDrawGLFunctor, waitForCompletion); } @Override public void callDrawGlFunction(Canvas canvas, long nativeDrawGLFunctor) { - delegate.callDrawGlFunction(canvas, nativeDrawGLFunctor); + mDelegate.callDrawGlFunction(canvas, nativeDrawGLFunctor); } @Override public void detachDrawGlFunctor(View containerView, long nativeDrawGLFunctor) { - delegate.detachDrawGlFunctor(containerView, nativeDrawGLFunctor); + mDelegate.detachDrawGlFunctor(containerView, nativeDrawGLFunctor); } @Override public int getPackageId(Resources resources, String packageName) { - return delegate.getPackageId(resources, packageName); + return mDelegate.getPackageId(resources, packageName); } @Override public Application getApplication() { - return delegate.getApplication(); + return mDelegate.getApplication(); } @Override public String getErrorString(Context context, int errorCode) { - return delegate.getErrorString(context, errorCode); + return mDelegate.getErrorString(context, errorCode); } @Override public void addWebViewAssetPath(Context context) { - delegate.addWebViewAssetPath(context); + mDelegate.addWebViewAssetPath(context); } } @@ -185,7 +179,7 @@ class WebViewDelegateFactory { */ private static class Api21CompatibilityDelegate implements WebViewDelegate { /** Copy of Trace.TRACE_TAG_WEBVIEW */ - private final static long TRACE_TAG_WEBVIEW = 1L << 4; + private static final long TRACE_TAG_WEBVIEW = 1L << 4; /** Hidden APIs released in the API 21 version of the framework */ private final Method mIsTagEnabledMethod; @@ -207,24 +201,24 @@ class WebViewDelegateFactory { // should not be changed even if those hidden APIs change in future releases. mIsTagEnabledMethod = Trace.class.getMethod("isTagEnabled", long.class); mAddChangeCallbackMethod = Class.forName("android.os.SystemProperties") - .getMethod("addChangeCallback", Runnable.class); + .getMethod("addChangeCallback", Runnable.class); mGetViewRootImplMethod = View.class.getMethod("getViewRootImpl"); - mInvokeFunctorMethod = Class.forName("android.view.ViewRootImpl") - .getMethod("invokeFunctor", long.class, boolean.class); + mInvokeFunctorMethod = + Class.forName("android.view.ViewRootImpl") + .getMethod("invokeFunctor", long.class, boolean.class); mDetachFunctorMethod = Class.forName("android.view.ViewRootImpl") - .getMethod("detachFunctor", long.class); + .getMethod("detachFunctor", long.class); mCallDrawGLFunctionMethod = Class.forName("android.view.HardwareCanvas") - .getMethod("callDrawGLFunction", long.class); - mGetAssignedPackageIdentifiersMethod = AssetManager.class.getMethod( - "getAssignedPackageIdentifiers"); - mAddAssetPathMethod = AssetManager.class.getMethod( - "addAssetPath", String.class); - mCurrentApplicationMethod = Class.forName("android.app.ActivityThread") - .getMethod("currentApplication"); + .getMethod("callDrawGLFunction", long.class); + mGetAssignedPackageIdentifiersMethod = + AssetManager.class.getMethod("getAssignedPackageIdentifiers"); + mAddAssetPathMethod = AssetManager.class.getMethod("addAssetPath", String.class); + mCurrentApplicationMethod = + Class.forName("android.app.ActivityThread").getMethod("currentApplication"); mGetStringMethod = Class.forName("android.net.http.ErrorStrings") - .getMethod("getString", int.class, Context.class); + .getMethod("getString", int.class, Context.class); mGetLoadedPackageInfoMethod = Class.forName("android.webkit.WebViewFactory") - .getMethod("getLoadedPackageInfo"); + .getMethod("getLoadedPackageInfo"); } catch (Exception e) { throw new RuntimeException("Invalid reflection", e); } @@ -257,7 +251,7 @@ class WebViewDelegateFactory { public boolean canInvokeDrawGlFunctor(View containerView) { try { Object viewRootImpl = mGetViewRootImplMethod.invoke(containerView); - // viewRootImpl can be null during teardown when window is leaked. + // viewRootImpl can be null during teardown when window is leaked. return viewRootImpl != null; } catch (Exception e) { throw new RuntimeException("Invalid reflection", e); @@ -265,12 +259,13 @@ class WebViewDelegateFactory { } @Override - public void invokeDrawGlFunctor(View containerView, long nativeDrawGLFunctor, - boolean waitForCompletion) { + public void invokeDrawGlFunctor( + View containerView, long nativeDrawGLFunctor, boolean waitForCompletion) { try { Object viewRootImpl = mGetViewRootImplMethod.invoke(containerView); if (viewRootImpl != null) { - mInvokeFunctorMethod.invoke(viewRootImpl, nativeDrawGLFunctor, waitForCompletion); + mInvokeFunctorMethod.invoke( + viewRootImpl, nativeDrawGLFunctor, waitForCompletion); } } catch (Exception e) { throw new RuntimeException("Invalid reflection", e); @@ -346,4 +341,3 @@ class WebViewDelegateFactory { } } } - |