Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 14018004: [Android] Refactor NativeView to be able to use it for AutofillDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 289
288 // Used to keep track of whether we should try to undo the last zoom-to-text field operation. 290 // Used to keep track of whether we should try to undo the last zoom-to-text field operation.
289 private boolean mScrolledAndZoomedFocusedEditableNode = false; 291 private boolean mScrolledAndZoomedFocusedEditableNode = false;
290 292
291 // Whether we use hardware-accelerated drawing. 293 // Whether we use hardware-accelerated drawing.
292 private boolean mHardwareAccelerated = false; 294 private boolean mHardwareAccelerated = false;
293 295
294 // Whether we received a new frame since consumePendingRendererFrame() was l ast called. 296 // Whether we received a new frame since consumePendingRendererFrame() was l ast called.
295 private boolean mPendingRendererFrame = false; 297 private boolean mPendingRendererFrame = false;
296 298
299 private ViewAndroid mViewAndroid;
300
297 /** 301 /**
298 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing 302 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing
299 * a ContentViewCore and before using it. 303 * a ContentViewCore and before using it.
300 * 304 *
301 * @param context The context used to create this. 305 * @param context The context used to create this.
302 * @param personality The type of ContentViewCore being created. 306 * @param personality The type of ContentViewCore being created.
303 */ 307 */
304 public ContentViewCore(Context context, int personality) { 308 public ContentViewCore(Context context, int personality) {
305 mContext = context; 309 mContext = context;
306 310
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 352
349 /** 353 /**
350 * Returns a delegate that can be used to add and remove views from the Cont ainerView. 354 * Returns a delegate that can be used to add and remove views from the Cont ainerView.
351 * 355 *
352 * NOTE: Use with care, as not all ContentViewCore users setup their Contain erView in the same 356 * NOTE: Use with care, as not all ContentViewCore users setup their Contain erView in the same
353 * way. In particular, the Android WebView has limitations on what implement ation details can 357 * way. In particular, the Android WebView has limitations on what implement ation details can
354 * be provided via a child view, as they are visible in the API and could in troduce 358 * be provided via a child view, as they are visible in the API and could in troduce
355 * compatibility breaks with existing applications. If in doubt, contact the 359 * compatibility breaks with existing applications. If in doubt, contact the
356 * android_webview/OWNERS 360 * android_webview/OWNERS
357 * 361 *
358 * @return A ContainerViewDelegate that can be used to add and remove views. 362 * @return A ViewAndroidDelegate that can be used to add and remove views.
359 */ 363 */
360 @CalledByNative 364 @VisibleForTesting
361 public ContainerViewDelegate getContainerViewDelegate() { 365 public ViewAndroidDelegate getViewAndroidDelegate() {
362 return new ContainerViewDelegate() { 366 return new ViewAndroidDelegate() {
363 @Override 367 @Override
364 public void addViewToContainerView(View view) { 368 public void addViewToContainerView(View view) {
365 mContainerView.addView(view); 369 mContainerView.addView(view);
366 } 370 }
367 371
368 @Override 372 @Override
369 public void removeViewFromContainerView(View view) { 373 public void removeViewFromContainerView(View view) {
370 mContainerView.removeView(view); 374 mContainerView.removeView(view);
371 } 375 }
372 376
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 mHardwareAccelerated = hasHardwareAcceleration(mContext); 532 mHardwareAccelerated = hasHardwareAcceleration(mContext);
529 533
530 // Input events are delivered at vsync time on JB+. 534 // Input events are delivered at vsync time on JB+.
531 boolean inputEventsDeliveredAtVSync = 535 boolean inputEventsDeliveredAtVSync =
532 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); 536 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN);
533 537
534 mContainerView = containerView; 538 mContainerView = containerView;
535 539
536 int windowNativePointer = windowAndroid != null ? windowAndroid.getNativ ePointer() : 0; 540 int windowNativePointer = windowAndroid != null ? windowAndroid.getNativ ePointer() : 0;
537 541
542 int viewAndroidNativePointer = 0;
543 if (windowNativePointer != 0) {
544 mViewAndroid = new ViewAndroid(windowAndroid, getViewAndroidDelegate ());
545 viewAndroidNativePointer = mViewAndroid.getNativePointer();
546 }
547
538 mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDel iveredAtVSync, 548 mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDel iveredAtVSync,
539 nativeWebContents, windowNativePointer); 549 nativeWebContents, viewAndroidNativePointer, windowNativePointer );
540 mContentSettings = new ContentSettings( 550 mContentSettings = new ContentSettings(
541 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau lt); 551 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau lt);
542 initializeContainerView(internalDispatcher); 552 initializeContainerView(internalDispatcher);
543 if (mPersonality == PERSONALITY_VIEW) { 553 if (mPersonality == PERSONALITY_VIEW) {
544 setAllUserAgentOverridesInHistory(); 554 setAllUserAgentOverridesInHistory();
545 } 555 }
546 556
547 mAccessibilityInjector = AccessibilityInjector.newInstance(this); 557 mAccessibilityInjector = AccessibilityInjector.newInstance(this);
548 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); 558 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary();
549 559
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 * Destroy the internal state of the ContentView. This method may only be 692 * Destroy the internal state of the ContentView. This method may only be
683 * called after the ContentView has been removed from the view system. No 693 * called after the ContentView has been removed from the view system. No
684 * other methods may be called on this ContentView after this method has 694 * other methods may be called on this ContentView after this method has
685 * been called. 695 * been called.
686 */ 696 */
687 public void destroy() { 697 public void destroy() {
688 if (mNativeContentViewCore != 0) { 698 if (mNativeContentViewCore != 0) {
689 nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore); 699 nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore);
690 } 700 }
691 resetVSyncNotification(); 701 resetVSyncNotification();
702 if (mViewAndroid != null) mViewAndroid.destroy();
692 mNativeContentViewCore = 0; 703 mNativeContentViewCore = 0;
693 mContentSettings = null; 704 mContentSettings = null;
694 mJavaScriptInterfaces.clear(); 705 mJavaScriptInterfaces.clear();
695 mRetainedJavaScriptObjects.clear(); 706 mRetainedJavaScriptObjects.clear();
696 } 707 }
697 708
698 /** 709 /**
699 * Returns true initially, false after destroy() has been called. 710 * Returns true initially, false after destroy() has been called.
700 * It is illegal to call any other public method after destroy(). 711 * It is illegal to call any other public method after destroy().
701 */ 712 */
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 2699
2689 getContentViewClient().onGeometryChanged( 2700 getContentViewClient().onGeometryChanged(
2690 playerId, 2701 playerId,
2691 topLeft.getXPix(), 2702 topLeft.getXPix(),
2692 topLeft.getYPix(), 2703 topLeft.getYPix(),
2693 bottomRight.getXPix() - topLeft.getXPix(), 2704 bottomRight.getXPix() - topLeft.getXPix(),
2694 bottomRight.getYPix() - topLeft.getYPix()); 2705 bottomRight.getYPix() - topLeft.getYPix());
2695 } 2706 }
2696 2707
2697 private native int nativeInit(boolean hardwareAccelerated, boolean inputEven tsDeliveredAtVSync, 2708 private native int nativeInit(boolean hardwareAccelerated, boolean inputEven tsDeliveredAtVSync,
2698 int webContentsPtr, int windowAndroidPtr); 2709 int webContentsPtr, int viewAndroidPtr, int windowAndroidPtr);
2699 2710
2700 private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentVi ewCoreImpl); 2711 private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentVi ewCoreImpl);
2701 2712
2702 private native void nativeLoadUrl( 2713 private native void nativeLoadUrl(
2703 int nativeContentViewCoreImpl, 2714 int nativeContentViewCoreImpl,
2704 String url, 2715 String url,
2705 int loadUrlType, 2716 int loadUrlType,
2706 int transitionType, 2717 int transitionType,
2707 int uaOverrideOption, 2718 int uaOverrideOption,
2708 String extraHeaders, 2719 String extraHeaders,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 boolean enableHiding, boolean enableShowing, boolean animate); 2868 boolean enableHiding, boolean enableShowing, boolean animate);
2858 2869
2859 private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl); 2870 private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl);
2860 2871
2861 private native void nativeAttachExternalVideoSurface( 2872 private native void nativeAttachExternalVideoSurface(
2862 int nativeContentViewCoreImpl, int playerId, Surface surface); 2873 int nativeContentViewCoreImpl, int playerId, Surface surface);
2863 2874
2864 private native void nativeDetachExternalVideoSurface( 2875 private native void nativeDetachExternalVideoSurface(
2865 int nativeContentViewCoreImpl, int playerId); 2876 int nativeContentViewCoreImpl, int playerId);
2866 } 2877 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698