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

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: 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 27 matching lines...) Expand all
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
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
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 private ContainerViewDelegate getContainerViewDelegate() {
309 public ContainerViewDelegate getContainerViewDelegate() {
310 return new ContainerViewDelegate() { 313 return new ContainerViewDelegate() {
311 @Override 314 @Override
312 public void addViewToContainerView(View view) { 315 public void addViewToContainerView(View view) {
313 mContainerView.addView(view); 316 mContainerView.addView(view);
314 } 317 }
315 318
316 @Override 319 @Override
317 public void removeViewFromContainerView(View view) { 320 public void removeViewFromContainerView(View view) {
318 mContainerView.removeView(view); 321 mContainerView.removeView(view);
319 } 322 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // HW acceleration flag can be set dynamically (Grace is doing this), 476 // HW acceleration flag can be set dynamically (Grace is doing this),
474 // move this check into onAttachedToWindow(), where we can test for 477 // move this check into onAttachedToWindow(), where we can test for
475 // HW support directly. 478 // HW support directly.
476 mHardwareAccelerated = hasHardwareAcceleration(mContext); 479 mHardwareAccelerated = hasHardwareAcceleration(mContext);
477 480
478 // Input events are delivered at vsync time on JB+. 481 // Input events are delivered at vsync time on JB+.
479 boolean inputEventsDeliveredAtVSync = 482 boolean inputEventsDeliveredAtVSync =
480 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); 483 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN);
481 484
482 mContainerView = containerView; 485 mContainerView = containerView;
486 mNativeView = new NativeView(nativeWindow, getContainerViewDelegate());
487
483 mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDel iveredAtVSync, 488 mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDel iveredAtVSync,
484 nativeWebContents, nativeWindow.getNativePointer()); 489 nativeWebContents, mNativeView.getNativePointer(),
490 nativeWindow.getNativePointer());
485 mContentSettings = new ContentSettings( 491 mContentSettings = new ContentSettings(
486 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau lt); 492 this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefau lt);
487 initializeContainerView(internalDispatcher); 493 initializeContainerView(internalDispatcher);
488 if (mPersonality == PERSONALITY_VIEW) { 494 if (mPersonality == PERSONALITY_VIEW) {
489 setAllUserAgentOverridesInHistory(); 495 setAllUserAgentOverridesInHistory();
490 } 496 }
491 497
492 mAccessibilityInjector = AccessibilityInjector.newInstance(this); 498 mAccessibilityInjector = AccessibilityInjector.newInstance(this);
493 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary(); 499 mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary();
494 500
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 631
626 /** 632 /**
627 * Destroy the internal state of the ContentView. This method may only be 633 * 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 634 * 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 635 * other methods may be called on this ContentView after this method has
630 * been called. 636 * been called.
631 */ 637 */
632 public void destroy() { 638 public void destroy() {
633 if (mNativeContentViewCore != 0) { 639 if (mNativeContentViewCore != 0) {
634 nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore); 640 nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore);
635 } 641 }
aruslan 2013/04/12 16:53:35 Here -- destroy/notify the native counterpart.
aurimas (slooooooooow) 2013/04/12 18:00:05 Done.
636 mNativeContentViewCore = 0; 642 mNativeContentViewCore = 0;
637 mContentSettings = null; 643 mContentSettings = null;
638 mJavaScriptInterfaces.clear(); 644 mJavaScriptInterfaces.clear();
639 mRetainedJavaScriptObjects.clear(); 645 mRetainedJavaScriptObjects.clear();
640 } 646 }
641 647
642 /** 648 /**
643 * Returns true initially, false after destroy() has been called. 649 * Returns true initially, false after destroy() has been called.
644 * It is illegal to call any other public method after destroy(). 650 * It is illegal to call any other public method after destroy().
645 */ 651 */
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 nativeDetachExternalVideoSurface(mNativeContentViewCore, playerId); 2645 nativeDetachExternalVideoSurface(mNativeContentViewCore, playerId);
2640 } 2646 }
2641 } 2647 }
2642 2648
2643 @CalledByNative 2649 @CalledByNative
2644 private void requestExternalVideoSurface(int playerId) { 2650 private void requestExternalVideoSurface(int playerId) {
2645 getContentViewClient().onExternalVideoSurfaceRequested(playerId); 2651 getContentViewClient().onExternalVideoSurfaceRequested(playerId);
2646 } 2652 }
2647 2653
2648 private native int nativeInit(boolean hardwareAccelerated, boolean inputEven tsDeliveredAtVSync, 2654 private native int nativeInit(boolean hardwareAccelerated, boolean inputEven tsDeliveredAtVSync,
2649 int webContentsPtr, int windowAndroidPtr); 2655 int webContentsPtr, int viewAndroidPtr, int windowAndroidPtr);
2650 2656
2651 private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentVi ewCoreImpl); 2657 private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentVi ewCoreImpl);
2652 2658
2653 private native void nativeLoadUrl( 2659 private native void nativeLoadUrl(
2654 int nativeContentViewCoreImpl, 2660 int nativeContentViewCoreImpl,
2655 String url, 2661 String url,
2656 int loadUrlType, 2662 int loadUrlType,
2657 int transitionType, 2663 int transitionType,
2658 int uaOverrideOption, 2664 int uaOverrideOption,
2659 String extraHeaders, 2665 String extraHeaders,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 boolean enableHiding, boolean enableShowing, boolean animate); 2814 boolean enableHiding, boolean enableShowing, boolean animate);
2809 2815
2810 private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl); 2816 private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl);
2811 2817
2812 private native void nativeAttachExternalVideoSurface( 2818 private native void nativeAttachExternalVideoSurface(
2813 int nativeContentViewCoreImpl, int playerId, Surface surface); 2819 int nativeContentViewCoreImpl, int playerId, Surface surface);
2814 2820
2815 private native void nativeDetachExternalVideoSurface( 2821 private native void nativeDetachExternalVideoSurface(
2816 int nativeContentViewCoreImpl, int playerId); 2822 int nativeContentViewCoreImpl, int playerId);
2817 } 2823 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698