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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat e; | 44 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat e; |
45 import org.chromium.content.browser.accessibility.AccessibilityInjector; | 45 import org.chromium.content.browser.accessibility.AccessibilityInjector; |
46 import org.chromium.content.browser.input.AdapterInputConnection; | 46 import org.chromium.content.browser.input.AdapterInputConnection; |
47 import org.chromium.content.browser.input.HandleView; | 47 import org.chromium.content.browser.input.HandleView; |
48 import org.chromium.content.browser.input.ImeAdapter; | 48 import org.chromium.content.browser.input.ImeAdapter; |
49 import org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFacto ry; | 49 import org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFacto ry; |
50 import org.chromium.content.browser.input.InsertionHandleController; | 50 import org.chromium.content.browser.input.InsertionHandleController; |
51 import org.chromium.content.browser.input.SelectPopupDialog; | 51 import org.chromium.content.browser.input.SelectPopupDialog; |
52 import org.chromium.content.browser.input.SelectionHandleController; | 52 import org.chromium.content.browser.input.SelectionHandleController; |
53 import org.chromium.content.common.TraceEvent; | 53 import org.chromium.content.common.TraceEvent; |
54 import org.chromium.ui.ViewAndroid; | |
55 import org.chromium.ui.ViewAndroidDelegate; | |
54 import org.chromium.ui.WindowAndroid; | 56 import org.chromium.ui.WindowAndroid; |
55 | 57 |
56 import java.lang.annotation.Annotation; | 58 import java.lang.annotation.Annotation; |
57 import java.util.HashMap; | 59 import java.util.HashMap; |
58 import java.util.HashSet; | 60 import java.util.HashSet; |
59 import java.util.Map; | 61 import java.util.Map; |
60 | 62 |
61 /** | 63 /** |
62 * Provides a Java-side 'wrapper' around a WebContent (native) instance. | 64 * Provides a Java-side 'wrapper' around a WebContent (native) instance. |
63 * Contains all the major functionality necessary to manage the lifecycle of a C ontentView without | 65 * Contains all the major functionality necessary to manage the lifecycle of a C ontentView without |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 | 250 |
249 // Used to keep track of whether we should try to undo the last zoom-to-text field operation. | 251 // Used to keep track of whether we should try to undo the last zoom-to-text field operation. |
250 private boolean mScrolledAndZoomedFocusedEditableNode = false; | 252 private boolean mScrolledAndZoomedFocusedEditableNode = false; |
251 | 253 |
252 // Whether we use hardware-accelerated drawing. | 254 // Whether we use hardware-accelerated drawing. |
253 private boolean mHardwareAccelerated = false; | 255 private boolean mHardwareAccelerated = false; |
254 | 256 |
255 // Whether we received a new frame since consumePendingRendererFrame() was l ast called. | 257 // Whether we received a new frame since consumePendingRendererFrame() was l ast called. |
256 private boolean mPendingRendererFrame = false; | 258 private boolean mPendingRendererFrame = false; |
257 | 259 |
260 private ViewAndroid mViewAndroid; | |
261 | |
258 /** | 262 /** |
259 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing | 263 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing |
260 * a ContentViewCore and before using it. | 264 * a ContentViewCore and before using it. |
261 * | 265 * |
262 * @param context The context used to create this. | 266 * @param context The context used to create this. |
263 * @param personality The type of ContentViewCore being created. | 267 * @param personality The type of ContentViewCore being created. |
264 */ | 268 */ |
265 public ContentViewCore(Context context, int personality) { | 269 public ContentViewCore(Context context, int personality) { |
266 mContext = context; | 270 mContext = context; |
267 | 271 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 | 313 |
310 /** | 314 /** |
311 * Returns a delegate that can be used to add and remove views from the Cont ainerView. | 315 * Returns a delegate that can be used to add and remove views from the Cont ainerView. |
312 * | 316 * |
313 * NOTE: Use with care, as not all ContentViewCore users setup their Contain erView in the same | 317 * NOTE: Use with care, as not all ContentViewCore users setup their Contain erView in the same |
314 * way. In particular, the Android WebView has limitations on what implement ation details can | 318 * way. In particular, the Android WebView has limitations on what implement ation details can |
315 * be provided via a child view, as they are visible in the API and could in troduce | 319 * be provided via a child view, as they are visible in the API and could in troduce |
316 * compatibility breaks with existing applications. If in doubt, contact the | 320 * compatibility breaks with existing applications. If in doubt, contact the |
317 * android_webview/OWNERS | 321 * android_webview/OWNERS |
318 * | 322 * |
319 * @return A ContainerViewDelegate that can be used to add and remove views. | 323 * @return A ViewAndroidDelegate that can be used to add and remove views. |
320 */ | 324 */ |
321 @CalledByNative | 325 @VisibleForTesting |
322 public ContainerViewDelegate getContainerViewDelegate() { | 326 public ViewAndroidDelegate getViewAndroidDelegate() { |
323 return new ContainerViewDelegate() { | 327 return new ViewAndroidDelegate() { |
324 @Override | 328 @Override |
325 public void addViewToContainerView(View view) { | 329 public void addViewToContainerView(View view) { |
326 mContainerView.addView(view); | 330 mContainerView.addView(view); |
327 } | 331 } |
328 | 332 |
329 @Override | 333 @Override |
330 public void removeViewFromContainerView(View view) { | 334 public void removeViewFromContainerView(View view) { |
331 mContainerView.removeView(view); | 335 mContainerView.removeView(view); |
332 } | 336 } |
333 | 337 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 mHardwareAccelerated = hasHardwareAcceleration(mContext); | 493 mHardwareAccelerated = hasHardwareAcceleration(mContext); |
490 | 494 |
491 // Input events are delivered at vsync time on JB+. | 495 // Input events are delivered at vsync time on JB+. |
492 boolean inputEventsDeliveredAtVSync = | 496 boolean inputEventsDeliveredAtVSync = |
493 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); | 497 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); |
494 | 498 |
495 mContainerView = containerView; | 499 mContainerView = containerView; |
496 | 500 |
497 int windowNativePointer = windowAndroid != null ? windowAndroid.getNativ ePointer() : 0; | 501 int windowNativePointer = windowAndroid != null ? windowAndroid.getNativ ePointer() : 0; |
498 | 502 |
503 int viewAndroidNativePointer = 0; | |
504 if (windowNativePointer != 0) { | |
505 mViewAndroid = new ViewAndroid(windowAndroid, getViewAndroidDelegate ()); | |
506 viewAndroidNativePointer = mViewAndroid.getNativePointer(); | |
507 } | |
508 | |
499 mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDel iveredAtVSync, | 509 mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDel iveredAtVSync, |
500 nativeWebContents, windowNativePointer); | 510 nativeWebContents, viewAndroidNativePointer, windowNativePointer ); |
501 mContentSettings = new ContentSettings( | 511 mContentSettings = new ContentSettings( |
502 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau lt); | 512 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau lt); |
503 initializeContainerView(internalDispatcher); | 513 initializeContainerView(internalDispatcher); |
504 if (mPersonality == PERSONALITY_VIEW) { | 514 if (mPersonality == PERSONALITY_VIEW) { |
505 setAllUserAgentOverridesInHistory(); | 515 setAllUserAgentOverridesInHistory(); |
506 } | 516 } |
507 | 517 |
508 mAccessibilityInjector = AccessibilityInjector.newInstance(this); | 518 mAccessibilityInjector = AccessibilityInjector.newInstance(this); |
509 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); | 519 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); |
510 | 520 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 /** | 652 /** |
643 * Destroy the internal state of the ContentView. This method may only be | 653 * Destroy the internal state of the ContentView. This method may only be |
644 * called after the ContentView has been removed from the view system. No | 654 * called after the ContentView has been removed from the view system. No |
645 * other methods may be called on this ContentView after this method has | 655 * other methods may be called on this ContentView after this method has |
646 * been called. | 656 * been called. |
647 */ | 657 */ |
648 public void destroy() { | 658 public void destroy() { |
649 if (mNativeContentViewCore != 0) { | 659 if (mNativeContentViewCore != 0) { |
650 nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore); | 660 nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore); |
651 } | 661 } |
662 if (mViewAndroid != null) mViewAndroid.destroy(); | |
joth
2013/04/19 20:59:45
I forget - shouldn't there be a similar mWindowAnd
aurimas (slooooooooow)
2013/04/19 21:32:04
It is in Main.java#Destroy().
| |
652 mNativeContentViewCore = 0; | 663 mNativeContentViewCore = 0; |
653 mContentSettings = null; | 664 mContentSettings = null; |
654 mJavaScriptInterfaces.clear(); | 665 mJavaScriptInterfaces.clear(); |
655 mRetainedJavaScriptObjects.clear(); | 666 mRetainedJavaScriptObjects.clear(); |
656 } | 667 } |
657 | 668 |
658 /** | 669 /** |
659 * Returns true initially, false after destroy() has been called. | 670 * Returns true initially, false after destroy() has been called. |
660 * It is illegal to call any other public method after destroy(). | 671 * It is illegal to call any other public method after destroy(). |
661 */ | 672 */ |
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2659 | 2670 |
2660 getContentViewClient().onGeometryChanged( | 2671 getContentViewClient().onGeometryChanged( |
2661 playerId, | 2672 playerId, |
2662 topLeft.getXPix(), | 2673 topLeft.getXPix(), |
2663 topLeft.getYPix(), | 2674 topLeft.getYPix(), |
2664 bottomRight.getXPix() - topLeft.getXPix(), | 2675 bottomRight.getXPix() - topLeft.getXPix(), |
2665 bottomRight.getYPix() - topLeft.getYPix()); | 2676 bottomRight.getYPix() - topLeft.getYPix()); |
2666 } | 2677 } |
2667 | 2678 |
2668 private native int nativeInit(boolean hardwareAccelerated, boolean inputEven tsDeliveredAtVSync, | 2679 private native int nativeInit(boolean hardwareAccelerated, boolean inputEven tsDeliveredAtVSync, |
2669 int webContentsPtr, int windowAndroidPtr); | 2680 int webContentsPtr, int viewAndroidPtr, int windowAndroidPtr); |
2670 | 2681 |
2671 private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentVi ewCoreImpl); | 2682 private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentVi ewCoreImpl); |
2672 | 2683 |
2673 private native void nativeLoadUrl( | 2684 private native void nativeLoadUrl( |
2674 int nativeContentViewCoreImpl, | 2685 int nativeContentViewCoreImpl, |
2675 String url, | 2686 String url, |
2676 int loadUrlType, | 2687 int loadUrlType, |
2677 int transitionType, | 2688 int transitionType, |
2678 int uaOverrideOption, | 2689 int uaOverrideOption, |
2679 String extraHeaders, | 2690 String extraHeaders, |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2826 boolean enableHiding, boolean enableShowing, boolean animate); | 2837 boolean enableHiding, boolean enableShowing, boolean animate); |
2827 | 2838 |
2828 private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl); | 2839 private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl); |
2829 | 2840 |
2830 private native void nativeAttachExternalVideoSurface( | 2841 private native void nativeAttachExternalVideoSurface( |
2831 int nativeContentViewCoreImpl, int playerId, Surface surface); | 2842 int nativeContentViewCoreImpl, int playerId, Surface surface); |
2832 | 2843 |
2833 private native void nativeDetachExternalVideoSurface( | 2844 private native void nativeDetachExternalVideoSurface( |
2834 int nativeContentViewCoreImpl, int playerId); | 2845 int nativeContentViewCoreImpl, int playerId); |
2835 } | 2846 } |
OLD | NEW |