Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.pm.ActivityInfo; | 9 import android.content.pm.ActivityInfo; |
| 10 import android.content.pm.PackageManager; | 10 import android.content.pm.PackageManager; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 import com.google.common.annotations.VisibleForTesting; | 38 import com.google.common.annotations.VisibleForTesting; |
| 39 | 39 |
| 40 import org.chromium.base.CalledByNative; | 40 import org.chromium.base.CalledByNative; |
| 41 import org.chromium.base.JNINamespace; | 41 import org.chromium.base.JNINamespace; |
| 42 import org.chromium.base.WeakContext; | 42 import org.chromium.base.WeakContext; |
| 43 import org.chromium.content.R; | 43 import org.chromium.content.R; |
| 44 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat e; | 44 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat e; |
| 45 import org.chromium.content.browser.ImeAdapter.AdapterInputConnectionFactory; | 45 import org.chromium.content.browser.ImeAdapter.AdapterInputConnectionFactory; |
| 46 import org.chromium.content.browser.accessibility.AccessibilityInjector; | 46 import org.chromium.content.browser.accessibility.AccessibilityInjector; |
| 47 import org.chromium.content.common.TraceEvent; | 47 import org.chromium.content.common.TraceEvent; |
| 48 import org.chromium.ui.ContainerViewDelegate; | |
| 49 import org.chromium.ui.NativeView; | |
| 48 import org.chromium.ui.gfx.NativeWindow; | 50 import org.chromium.ui.gfx.NativeWindow; |
| 49 | 51 |
| 50 import java.lang.annotation.Annotation; | 52 import java.lang.annotation.Annotation; |
| 51 import java.util.HashMap; | 53 import java.util.HashMap; |
| 52 import java.util.HashSet; | 54 import java.util.HashSet; |
| 53 import java.util.Map; | 55 import java.util.Map; |
| 54 | 56 |
| 55 /** | 57 /** |
| 56 * Provides a Java-side 'wrapper' around a WebContent (native) instance. | 58 * Provides a Java-side 'wrapper' around a WebContent (native) instance. |
| 57 * Contains all the major functionality necessary to manage the lifecycle of a C ontentView without | 59 * Contains all the major functionality necessary to manage the lifecycle of a C ontentView without |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 private final Rect mFocusPreOSKViewportRect = new Rect(); | 237 private final Rect mFocusPreOSKViewportRect = new Rect(); |
| 236 | 238 |
| 237 private boolean mNeedUpdateOrientationChanged; | 239 private boolean mNeedUpdateOrientationChanged; |
| 238 | 240 |
| 239 // Used to keep track of whether we should try to undo the last zoom-to-text field operation. | 241 // Used to keep track of whether we should try to undo the last zoom-to-text field operation. |
| 240 private boolean mScrolledAndZoomedFocusedEditableNode = false; | 242 private boolean mScrolledAndZoomedFocusedEditableNode = false; |
| 241 | 243 |
| 242 // Whether we use hardware-accelerated drawing. | 244 // Whether we use hardware-accelerated drawing. |
| 243 private boolean mHardwareAccelerated = false; | 245 private boolean mHardwareAccelerated = false; |
| 244 | 246 |
| 247 private NativeView mNativeView; | |
| 248 | |
| 245 /** | 249 /** |
| 246 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing | 250 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing |
| 247 * a ContentViewCore and before using it. | 251 * a ContentViewCore and before using it. |
| 248 * | 252 * |
| 249 * @param context The context used to create this. | 253 * @param context The context used to create this. |
| 250 * @param personality The type of ContentViewCore being created. | 254 * @param personality The type of ContentViewCore being created. |
| 251 */ | 255 */ |
| 252 public ContentViewCore(Context context, int personality) { | 256 public ContentViewCore(Context context, int personality) { |
| 253 mContext = context; | 257 mContext = context; |
| 254 | 258 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 * Returns a delegate that can be used to add and remove views from the Cont ainerView. | 302 * Returns a delegate that can be used to add and remove views from the Cont ainerView. |
| 299 * | 303 * |
| 300 * NOTE: Use with care, as not all ContentViewCore users setup their Contain erView in the same | 304 * NOTE: Use with care, as not all ContentViewCore users setup their Contain erView in the same |
| 301 * way. In particular, the Android WebView has limitations on what implement ation details can | 305 * way. In particular, the Android WebView has limitations on what implement ation details can |
| 302 * be provided via a child view, as they are visible in the API and could in troduce | 306 * be provided via a child view, as they are visible in the API and could in troduce |
| 303 * compatibility breaks with existing applications. If in doubt, contact the | 307 * compatibility breaks with existing applications. If in doubt, contact the |
| 304 * android_webview/OWNERS | 308 * android_webview/OWNERS |
| 305 * | 309 * |
| 306 * @return A ContainerViewDelegate that can be used to add and remove views. | 310 * @return A ContainerViewDelegate that can be used to add and remove views. |
| 307 */ | 311 */ |
| 308 @CalledByNative | 312 @VisibleForTesting |
| 309 public ContainerViewDelegate getContainerViewDelegate() { | 313 public ContainerViewDelegate getContainerViewDelegate() { |
| 310 return new ContainerViewDelegate() { | 314 return new ContainerViewDelegate() { |
| 311 @Override | 315 @Override |
| 312 public void addViewToContainerView(View view) { | 316 public void addViewToContainerView(View view) { |
| 313 mContainerView.addView(view); | 317 mContainerView.addView(view); |
| 314 } | 318 } |
| 315 | 319 |
| 316 @Override | 320 @Override |
| 317 public void removeViewFromContainerView(View view) { | 321 public void removeViewFromContainerView(View view) { |
| 318 mContainerView.removeView(view); | 322 mContainerView.removeView(view); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 // HW acceleration flag can be set dynamically (Grace is doing this), | 477 // HW acceleration flag can be set dynamically (Grace is doing this), |
| 474 // move this check into onAttachedToWindow(), where we can test for | 478 // move this check into onAttachedToWindow(), where we can test for |
| 475 // HW support directly. | 479 // HW support directly. |
| 476 mHardwareAccelerated = hasHardwareAcceleration(mContext); | 480 mHardwareAccelerated = hasHardwareAcceleration(mContext); |
| 477 | 481 |
| 478 // Input events are delivered at vsync time on JB+. | 482 // Input events are delivered at vsync time on JB+. |
| 479 boolean inputEventsDeliveredAtVSync = | 483 boolean inputEventsDeliveredAtVSync = |
| 480 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); | 484 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); |
| 481 | 485 |
| 482 mContainerView = containerView; | 486 mContainerView = containerView; |
| 487 mNativeView = new NativeView(nativeWindow, getContainerViewDelegate()); | |
|
joth
2013/04/12 19:00:48
not sure we can doing anything about it, but the w
nilesh
2013/04/12 19:07:10
+1
aurimas (slooooooooow)
2013/04/12 22:00:41
Done.
| |
| 488 | |
| 483 mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDel iveredAtVSync, | 489 mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDel iveredAtVSync, |
| 484 nativeWebContents, nativeWindow.getNativePointer()); | 490 nativeWebContents, mNativeView.getNativePointer(), |
| 491 nativeWindow.getNativePointer()); | |
| 485 mContentSettings = new ContentSettings( | 492 mContentSettings = new ContentSettings( |
| 486 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau lt); | 493 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau lt); |
| 487 initializeContainerView(internalDispatcher); | 494 initializeContainerView(internalDispatcher); |
| 488 if (mPersonality == PERSONALITY_VIEW) { | 495 if (mPersonality == PERSONALITY_VIEW) { |
| 489 setAllUserAgentOverridesInHistory(); | 496 setAllUserAgentOverridesInHistory(); |
| 490 } | 497 } |
| 491 | 498 |
| 492 mAccessibilityInjector = AccessibilityInjector.newInstance(this); | 499 mAccessibilityInjector = AccessibilityInjector.newInstance(this); |
| 493 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); | 500 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); |
| 494 | 501 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 /** | 633 /** |
| 627 * Destroy the internal state of the ContentView. This method may only be | 634 * Destroy the internal state of the ContentView. This method may only be |
| 628 * called after the ContentView has been removed from the view system. No | 635 * called after the ContentView has been removed from the view system. No |
| 629 * other methods may be called on this ContentView after this method has | 636 * other methods may be called on this ContentView after this method has |
| 630 * been called. | 637 * been called. |
| 631 */ | 638 */ |
| 632 public void destroy() { | 639 public void destroy() { |
| 633 if (mNativeContentViewCore != 0) { | 640 if (mNativeContentViewCore != 0) { |
| 634 nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore); | 641 nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore); |
| 635 } | 642 } |
| 643 mNativeView.destroy(); | |
| 636 mNativeContentViewCore = 0; | 644 mNativeContentViewCore = 0; |
| 637 mContentSettings = null; | 645 mContentSettings = null; |
| 638 mJavaScriptInterfaces.clear(); | 646 mJavaScriptInterfaces.clear(); |
| 639 mRetainedJavaScriptObjects.clear(); | 647 mRetainedJavaScriptObjects.clear(); |
| 640 } | 648 } |
| 641 | 649 |
| 642 /** | 650 /** |
| 643 * Returns true initially, false after destroy() has been called. | 651 * Returns true initially, false after destroy() has been called. |
| 644 * It is illegal to call any other public method after destroy(). | 652 * It is illegal to call any other public method after destroy(). |
| 645 */ | 653 */ |
| (...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2639 nativeDetachExternalVideoSurface(mNativeContentViewCore, playerId); | 2647 nativeDetachExternalVideoSurface(mNativeContentViewCore, playerId); |
| 2640 } | 2648 } |
| 2641 } | 2649 } |
| 2642 | 2650 |
| 2643 @CalledByNative | 2651 @CalledByNative |
| 2644 private void requestExternalVideoSurface(int playerId) { | 2652 private void requestExternalVideoSurface(int playerId) { |
| 2645 getContentViewClient().onExternalVideoSurfaceRequested(playerId); | 2653 getContentViewClient().onExternalVideoSurfaceRequested(playerId); |
| 2646 } | 2654 } |
| 2647 | 2655 |
| 2648 private native int nativeInit(boolean hardwareAccelerated, boolean inputEven tsDeliveredAtVSync, | 2656 private native int nativeInit(boolean hardwareAccelerated, boolean inputEven tsDeliveredAtVSync, |
| 2649 int webContentsPtr, int windowAndroidPtr); | 2657 int webContentsPtr, int viewAndroidPtr, int windowAndroidPtr); |
| 2650 | 2658 |
| 2651 private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentVi ewCoreImpl); | 2659 private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentVi ewCoreImpl); |
| 2652 | 2660 |
| 2653 private native void nativeLoadUrl( | 2661 private native void nativeLoadUrl( |
| 2654 int nativeContentViewCoreImpl, | 2662 int nativeContentViewCoreImpl, |
| 2655 String url, | 2663 String url, |
| 2656 int loadUrlType, | 2664 int loadUrlType, |
| 2657 int transitionType, | 2665 int transitionType, |
| 2658 int uaOverrideOption, | 2666 int uaOverrideOption, |
| 2659 String extraHeaders, | 2667 String extraHeaders, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2808 boolean enableHiding, boolean enableShowing, boolean animate); | 2816 boolean enableHiding, boolean enableShowing, boolean animate); |
| 2809 | 2817 |
| 2810 private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl); | 2818 private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl); |
| 2811 | 2819 |
| 2812 private native void nativeAttachExternalVideoSurface( | 2820 private native void nativeAttachExternalVideoSurface( |
| 2813 int nativeContentViewCoreImpl, int playerId, Surface surface); | 2821 int nativeContentViewCoreImpl, int playerId, Surface surface); |
| 2814 | 2822 |
| 2815 private native void nativeDetachExternalVideoSurface( | 2823 private native void nativeDetachExternalVideoSurface( |
| 2816 int nativeContentViewCoreImpl, int playerId); | 2824 int nativeContentViewCoreImpl, int playerId); |
| 2817 } | 2825 } |
| OLD | NEW |