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

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

Issue 2178973004: DialogSurfaceManager implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed IDialogSurfaceActivityMapper from common.aidl Created 4 years 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.app.assist.AssistStructure.ViewNode; 9 import android.app.assist.AssistStructure.ViewNode;
10 import android.content.ClipData; 10 import android.content.ClipData;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 @JNINamespace("content") 91 @JNINamespace("content")
92 public class ContentViewCore implements AccessibilityStateChangeListener, Displa yAndroidObserver, 92 public class ContentViewCore implements AccessibilityStateChangeListener, Displa yAndroidObserver,
93 SystemCaptioningBridge.SystemCaptioningB ridgeListener, 93 SystemCaptioningBridge.SystemCaptioningB ridgeListener,
94 WindowAndroidProvider { 94 WindowAndroidProvider {
95 private static final String TAG = "cr_ContentViewCore"; 95 private static final String TAG = "cr_ContentViewCore";
96 96
97 // Used to avoid enabling zooming in / out if resulting zooming will 97 // Used to avoid enabling zooming in / out if resulting zooming will
98 // produce little visible difference. 98 // produce little visible difference.
99 private static final float ZOOM_CONTROLS_EPSILON = 0.007f; 99 private static final float ZOOM_CONTROLS_EPSILON = 0.007f;
100 100
101 /**
102 * Observer for changes to WindowAndroid. Mirrors
103 * ContentViewCoreImplObserver in native. Appends 'Android' to (a) match
104 * WindowAndroid, and (b) avoid a name collision with View.
105 */
106 public interface Observer {
107 public void onContentViewCoreDestroyed(ContentViewCore cvc);
108 public void onAttachedToWindowAndroid(ContentViewCore cvc);
109 public void onDetachedFromWindowAndroid(ContentViewCore cvc);
110 }
111
112 // Single observer. We only support one right now, since we have only one
113 // consumer of it.
114 private Observer mObserver;
115
101 // If the embedder adds a JavaScript interface object that contains an indir ect reference to 116 // If the embedder adds a JavaScript interface object that contains an indir ect reference to
102 // the ContentViewCore, then storing a strong ref to the interface object on the native 117 // the ContentViewCore, then storing a strong ref to the interface object on the native
103 // side would prevent garbage collection of the ContentViewCore (as that str ong ref would 118 // side would prevent garbage collection of the ContentViewCore (as that str ong ref would
104 // create a new GC root). 119 // create a new GC root).
105 // For that reason, we store only a weak reference to the interface object o n the 120 // For that reason, we store only a weak reference to the interface object o n the
106 // native side. However we still need a strong reference on the Java side to 121 // native side. However we still need a strong reference on the Java side to
107 // prevent garbage collection if the embedder doesn't maintain their own ref to the 122 // prevent garbage collection if the embedder doesn't maintain their own ref to the
108 // interface object - the Java side ref won't create a new GC root. 123 // interface object - the Java side ref won't create a new GC root.
109 // This map stores those references. We put into the map on addJavaScriptInt erface() 124 // This map stores those references. We put into the map on addJavaScriptInt erface()
110 // and remove from it in removeJavaScriptInterface(). The annotation class i s stored for 125 // and remove from it in removeJavaScriptInterface(). The annotation class i s stored for
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } 712 }
698 } finally { 713 } finally {
699 TraceEvent.end("ContentViewCore.setContainerView"); 714 TraceEvent.end("ContentViewCore.setContainerView");
700 } 715 }
701 } 716 }
702 717
703 @CalledByNative 718 @CalledByNative
704 private void onNativeContentViewCoreDestroyed(long nativeContentViewCore) { 719 private void onNativeContentViewCoreDestroyed(long nativeContentViewCore) {
705 assert nativeContentViewCore == mNativeContentViewCore; 720 assert nativeContentViewCore == mNativeContentViewCore;
706 mNativeContentViewCore = 0; 721 mNativeContentViewCore = 0;
722 if (mObserver != null) mObserver.onContentViewCoreDestroyed(this);
707 } 723 }
708 724
709 /** 725 /**
710 * Set the Container view Internals. 726 * Set the Container view Internals.
711 * @param internalDispatcher Handles dispatching all hidden or super methods to the 727 * @param internalDispatcher Handles dispatching all hidden or super methods to the
712 * containerView. 728 * containerView.
713 */ 729 */
714 public void setContainerViewInternals(InternalAccessDelegate internalDispatc her) { 730 public void setContainerViewInternals(InternalAccessDelegate internalDispatc her) {
715 mContainerViewInternals = internalDispatcher; 731 mContainerViewInternals = internalDispatcher;
716 } 732 }
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 2822
2807 @VisibleForTesting 2823 @VisibleForTesting
2808 public ResultReceiver getNewShowKeyboardReceiver() { 2824 public ResultReceiver getNewShowKeyboardReceiver() {
2809 if (mShowKeyboardResultReceiver == null) { 2825 if (mShowKeyboardResultReceiver == null) {
2810 // Note: the returned object will get leaked by Android framework. 2826 // Note: the returned object will get leaked by Android framework.
2811 mShowKeyboardResultReceiver = new ShowKeyboardResultReceiver(this, n ew Handler()); 2827 mShowKeyboardResultReceiver = new ShowKeyboardResultReceiver(this, n ew Handler());
2812 } 2828 }
2813 return mShowKeyboardResultReceiver; 2829 return mShowKeyboardResultReceiver;
2814 } 2830 }
2815 2831
2832 // Set our observer. We support only a single observer right now. If
2833 // |observer| is already an observer, then do nothing.
2834 public void addObserver(Observer observer) {
2835 assert mObserver == null || mObserver == observer;
2836 mObserver = observer;
2837 }
2838
2839 // Remove our single observer.
2840 public void removeObserver(Observer observer) {
2841 assert mObserver == observer;
2842 // Note that this can be called as part of a callback, so be careful if
2843 // we're iterating over a list of observers when this is called.
2844 mObserver = null;
2845 }
2846
2847 @CalledByNative
2848 private void onAttachedToWindowAndroid() {
2849 if (mObserver != null) mObserver.onAttachedToWindowAndroid(this);
boliu 2017/01/04 23:14:39 sigh.. I should really unify these two different "
liberato (no reviews please) 2017/01/11 22:17:56 i didn't see an obvious way to do this. i'll re-c
2850 }
2851
2852 @CalledByNative
2853 private void onDetachedFromWindowAndroid() {
2854 if (mObserver != null) mObserver.onDetachedFromWindowAndroid(this);
2855 }
2856
2816 private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate, 2857 private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate,
2817 long windowAndroidPtr, float dipScale, HashSet<Object> retainedObjec tSet); 2858 long windowAndroidPtr, float dipScale, HashSet<Object> retainedObjec tSet);
2818 private static native ContentViewCore nativeFromWebContentsAndroid(WebConten ts webContents); 2859 private static native ContentViewCore nativeFromWebContentsAndroid(WebConten ts webContents);
2819 2860
2820 private native void nativeUpdateWindowAndroid( 2861 private native void nativeUpdateWindowAndroid(
2821 long nativeContentViewCoreImpl, long windowAndroidPtr); 2862 long nativeContentViewCoreImpl, long windowAndroidPtr);
2822 private native WebContents nativeGetWebContentsAndroid(long nativeContentVie wCoreImpl); 2863 private native WebContents nativeGetWebContentsAndroid(long nativeContentVie wCoreImpl);
2823 private native WindowAndroid nativeGetJavaWindowAndroid(long nativeContentVi ewCoreImpl); 2864 private native WindowAndroid nativeGetJavaWindowAndroid(long nativeContentVi ewCoreImpl);
2824 2865
2825 private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentV iewCoreImpl); 2866 private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentV iewCoreImpl);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 String textTrackTextShadow, String textTrackTextSize); 2964 String textTrackTextShadow, String textTrackTextSize);
2924 2965
2925 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, 2966 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l,
2926 int x, int y, int w, int h); 2967 int x, int y, int w, int h);
2927 2968
2928 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); 2969 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque);
2929 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo reImpl); 2970 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo reImpl);
2930 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac tion, int x, int y, 2971 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac tion, int x, int y,
2931 int screenX, int screenY, String[] mimeTypes, String content); 2972 int screenX, int screenY, String[] mimeTypes, String content);
2932 } 2973 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698