| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package com.android.webview.chromium; | 5 package com.android.webview.chromium; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; |
| 7 import android.app.Application; | 8 import android.app.Application; |
| 8 import android.content.Context; | 9 import android.content.Context; |
| 9 import android.content.ContextWrapper; | 10 import android.content.ContextWrapper; |
| 10 import android.content.pm.PackageInfo; | 11 import android.content.pm.PackageInfo; |
| 11 import android.content.res.AssetManager; | 12 import android.content.res.AssetManager; |
| 12 import android.content.res.Resources; | 13 import android.content.res.Resources; |
| 13 import android.graphics.Canvas; | 14 import android.graphics.Canvas; |
| 15 import android.os.Build; |
| 14 import android.os.Trace; | 16 import android.os.Trace; |
| 15 import android.util.SparseArray; | 17 import android.util.SparseArray; |
| 16 import android.view.View; | 18 import android.view.View; |
| 17 | 19 |
| 18 import java.lang.reflect.Method; | 20 import java.lang.reflect.Method; |
| 19 | 21 |
| 20 /** | 22 /** |
| 21 * Factory class for {@link WebViewDelegate com.android.webview.chromium.WebView
Delegate}s. | 23 * Factory class for {@link WebViewDelegate com.android.webview.chromium.WebView
Delegate}s. |
| 22 * | 24 * |
| 23 * <p>{@link WebViewDelegate com.android.webview.chromium.WebViewDelegate}s prov
ide the same | 25 * <p>{@link WebViewDelegate com.android.webview.chromium.WebViewDelegate}s prov
ide the same |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 * A {@link WebViewDelegate com.android.webview.chromium.WebViewDelegate} co
mpatible with the | 192 * A {@link WebViewDelegate com.android.webview.chromium.WebViewDelegate} co
mpatible with the |
| 191 * API 21 version of the framework in which | 193 * API 21 version of the framework in which |
| 192 * {@link android.webkit.WebViewDelegate android.webkit.WebViewDelegate} had
not yet been | 194 * {@link android.webkit.WebViewDelegate android.webkit.WebViewDelegate} had
not yet been |
| 193 * introduced. | 195 * introduced. |
| 194 * | 196 * |
| 195 * <p>This class implements the | 197 * <p>This class implements the |
| 196 * {@link WebViewDelegate com.android.webview.chromium.WebViewDelegate} func
tionality by using | 198 * {@link WebViewDelegate com.android.webview.chromium.WebViewDelegate} func
tionality by using |
| 197 * reflection to call into hidden frameworks APIs released in the API-21 ver
sion of the | 199 * reflection to call into hidden frameworks APIs released in the API-21 ver
sion of the |
| 198 * framework. | 200 * framework. |
| 199 */ | 201 */ |
| 202 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 200 private static class Api21CompatibilityDelegate implements WebViewDelegate { | 203 private static class Api21CompatibilityDelegate implements WebViewDelegate { |
| 201 /** Copy of Trace.TRACE_TAG_WEBVIEW */ | 204 /** Copy of Trace.TRACE_TAG_WEBVIEW */ |
| 202 private static final long TRACE_TAG_WEBVIEW = 1L << 4; | 205 private static final long TRACE_TAG_WEBVIEW = 1L << 4; |
| 203 | 206 |
| 204 /** Hidden APIs released in the API 21 version of the framework */ | 207 /** Hidden APIs released in the API 21 version of the framework */ |
| 205 private final Method mIsTagEnabledMethod; | 208 private final Method mIsTagEnabledMethod; |
| 206 private final Method mAddChangeCallbackMethod; | 209 private final Method mAddChangeCallbackMethod; |
| 207 private final Method mGetViewRootImplMethod; | 210 private final Method mGetViewRootImplMethod; |
| 208 private final Method mInvokeFunctorMethod; | 211 private final Method mInvokeFunctorMethod; |
| 209 private final Method mCallDrawGLFunctionMethod; | 212 private final Method mCallDrawGLFunctionMethod; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // Avoid calling the ContextWrapper.getAssets() proxy | 360 // Avoid calling the ContextWrapper.getAssets() proxy |
| 358 // chain, which can return an unexpected AssetManager. | 361 // chain, which can return an unexpected AssetManager. |
| 359 mAddAssetPathMethod.invoke( | 362 mAddAssetPathMethod.invoke( |
| 360 context.getResources().getAssets(), info.applicationInfo
.sourceDir); | 363 context.getResources().getAssets(), info.applicationInfo
.sourceDir); |
| 361 } catch (Exception e) { | 364 } catch (Exception e) { |
| 362 throw new RuntimeException("Invalid reflection", e); | 365 throw new RuntimeException("Invalid reflection", e); |
| 363 } | 366 } |
| 364 } | 367 } |
| 365 } | 368 } |
| 366 } | 369 } |
| OLD | NEW |