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

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

Issue 414423002: Removing ContentViewCore dependencies from few functions which acts as direct wrapper to WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed NavigationTransitionDelegate interface from ContentViewCore. Created 6 years, 4 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
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.app.Activity; 8 import android.app.Activity;
9 import android.app.SearchManager; 9 import android.app.SearchManager;
10 import android.content.ClipboardManager; 10 import android.content.ClipboardManager;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 /** 222 /**
223 * An interface that allows the embedder to be notified when the results of 223 * An interface that allows the embedder to be notified when the results of
224 * extractSmartClipData are available. 224 * extractSmartClipData are available.
225 */ 225 */
226 public interface SmartClipDataListener { 226 public interface SmartClipDataListener {
227 public void onSmartClipDataExtracted(String text, String html, Rect clip Rect); 227 public void onSmartClipDataExtracted(String text, String html, Rect clip Rect);
228 } 228 }
229 229
230 /**
231 * An interface that allows the embedder to be notified of navigation transi tion
232 * related events and respond to them.
233 */
234 public interface NavigationTransitionDelegate {
235 /**
236 * Called when the navigation is deferred immediately after the response started.
237 *
238 * @param enteringColor The background color of the entering document, a s a String
239 * representing a legal CSS color value. This is in serted into
240 * the transition layer's markup after the entering stylesheets
241 * have been applied.
242 */
243 public void didDeferAfterResponseStarted(String enteringColor);
244
245 /**
246 * Called when a navigation transition has been detected, and we need to check
247 * if it's supported.
248 */
249 public boolean willHandleDeferAfterResponseStarted();
250
251 /**
252 * Called when the navigation is deferred immediately after the response
253 * started.
254 */
255 public void addEnteringStylesheetToTransition(String stylesheet);
256
257 /**
258 * Notifies that a navigation transition is started for a given frame.
259 * @param frameId A positive, non-zero integer identifying the navigatin g frame.
260 */
261 public void didStartNavigationTransitionForFrame(long frameId);
262 }
263
264 private final Context mContext; 230 private final Context mContext;
265 private ViewGroup mContainerView; 231 private ViewGroup mContainerView;
266 private InternalAccessDelegate mContainerViewInternals; 232 private InternalAccessDelegate mContainerViewInternals;
267 private WebContents mWebContents; 233 private WebContents mWebContents;
268 private WebContentsObserverAndroid mWebContentsObserver; 234 private WebContentsObserverAndroid mWebContentsObserver;
269 235
270 private ContentViewClient mContentViewClient; 236 private ContentViewClient mContentViewClient;
271 237
272 private ContentSettings mContentSettings; 238 private ContentSettings mContentSettings;
273 239
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 private boolean mTouchScrollInProgress; 322 private boolean mTouchScrollInProgress;
357 323
358 // The outstanding fling start events that hasn't got fling end yet. It may be > 1 because 324 // The outstanding fling start events that hasn't got fling end yet. It may be > 1 because
359 // onNativeFlingStopped() is called asynchronously. 325 // onNativeFlingStopped() is called asynchronously.
360 private int mPotentiallyActiveFlingCount; 326 private int mPotentiallyActiveFlingCount;
361 327
362 private ViewAndroid mViewAndroid; 328 private ViewAndroid mViewAndroid;
363 329
364 private SmartClipDataListener mSmartClipDataListener = null; 330 private SmartClipDataListener mSmartClipDataListener = null;
365 331
366 private NavigationTransitionDelegate mNavigationTransitionDelegate = null;
367
368 // This holds the state of editable text (e.g. contents of <input>, contente ditable) of 332 // This holds the state of editable text (e.g. contents of <input>, contente ditable) of
369 // a focused element. 333 // a focused element.
370 // Every time the user, IME, javascript (Blink), autofill etc. modifies the content, the new 334 // Every time the user, IME, javascript (Blink), autofill etc. modifies the content, the new
371 // state must be reflected to this to keep consistency. 335 // state must be reflected to this to keep consistency.
372 private final Editable mEditable; 336 private final Editable mEditable;
373 337
374 /** 338 /**
375 * PID used to indicate an invalid render process. 339 * PID used to indicate an invalid render process.
376 */ 340 */
377 // Keep in sync with the value returned from ContentViewCoreImpl::GetCurrent RendererProcessId() 341 // Keep in sync with the value returned from ContentViewCoreImpl::GetCurrent RendererProcessId()
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 params.mBaseUrlForDataUrl, 863 params.mBaseUrlForDataUrl,
900 params.mVirtualUrlForDataUrl, 864 params.mVirtualUrlForDataUrl,
901 params.mCanLoadLocalResources, 865 params.mCanLoadLocalResources,
902 params.mIsRendererInitiated); 866 params.mIsRendererInitiated);
903 } 867 }
904 868
905 /** 869 /**
906 * Stops loading the current web contents. 870 * Stops loading the current web contents.
907 */ 871 */
908 public void stopLoading() { 872 public void stopLoading() {
909 if (mWebContents != null) mWebContents.stop(); 873 assert mWebContents != null;
874 mWebContents.stop();
910 } 875 }
911 876
912 /** 877 /**
913 * Get the URL of the current page. 878 * Get the URL of the current page.
914 * 879 *
915 * @return The URL of the current page. 880 * @return The URL of the current page.
916 */ 881 */
917 public String getUrl() { 882 public String getUrl() {
918 if (mNativeContentViewCore != 0) return nativeGetURL(mNativeContentViewC ore); 883 assert mWebContents != null;
919 return null; 884 return mWebContents.getUrl();
920 } 885 }
921 886
922 /** 887 /**
923 * Get the title of the current page. 888 * Get the title of the current page.
924 * 889 *
925 * @return The title of the current page. 890 * @return The title of the current page.
926 */ 891 */
927 public String getTitle() { 892 public String getTitle() {
928 return mWebContents == null ? null : mWebContents.getTitle(); 893 assert mWebContents != null;
894 return mWebContents.getTitle();
929 } 895 }
930 896
931 /** 897 /**
932 * Shows an interstitial page driven by the passed in delegate. 898 * Shows an interstitial page driven by the passed in delegate.
933 * 899 *
934 * @param url The URL being blocked by the interstitial. 900 * @param url The URL being blocked by the interstitial.
935 * @param delegate The delegate handling the interstitial. 901 * @param delegate The delegate handling the interstitial.
936 */ 902 */
937 @VisibleForTesting 903 @VisibleForTesting
938 public void showInterstitialPage( 904 public void showInterstitialPage(
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 if (getContentViewClient().doesPerformWebSearch()) return true; 2111 if (getContentViewClient().doesPerformWebSearch()) return true;
2146 Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); 2112 Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
2147 intent.putExtra(SearchManager.EXTRA_NEW_SEARCH, true); 2113 intent.putExtra(SearchManager.EXTRA_NEW_SEARCH, true);
2148 return getContext().getPackageManager().queryIntentActivities(in tent, 2114 return getContext().getPackageManager().queryIntentActivities(in tent,
2149 PackageManager.MATCH_DEFAULT_ONLY).size() > 0; 2115 PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
2150 } 2116 }
2151 }; 2117 };
2152 mActionMode = null; 2118 mActionMode = null;
2153 // On ICS, startActionMode throws an NPE when getParent() is null. 2119 // On ICS, startActionMode throws an NPE when getParent() is null.
2154 if (mContainerView.getParent() != null) { 2120 if (mContainerView.getParent() != null) {
2121 assert mWebContents != null;
2155 mActionMode = mContainerView.startActionMode( 2122 mActionMode = mContainerView.startActionMode(
2156 getContentViewClient().getSelectActionModeCallback(getContex t(), actionHandler, 2123 getContentViewClient().getSelectActionModeCallback(getContex t(), actionHandler,
2157 nativeIsIncognito(mNativeContentViewCore))); 2124 mWebContents.isIncognito()));
2158 } 2125 }
2159 mUnselectAllOnActionModeDismiss = true; 2126 mUnselectAllOnActionModeDismiss = true;
2160 if (mActionMode == null) { 2127 if (mActionMode == null) {
2161 // There is no ActionMode, so remove the selection. 2128 // There is no ActionMode, so remove the selection.
2162 mImeAdapter.unselect(); 2129 mImeAdapter.unselect();
2163 } else { 2130 } else {
2164 getContentViewClient().onContextualActionBarShown(); 2131 getContentViewClient().onContextualActionBarShown();
2165 } 2132 }
2166 } 2133 }
2167 2134
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
3051 public void setSmartClipDataListener(SmartClipDataListener listener) { 3018 public void setSmartClipDataListener(SmartClipDataListener listener) {
3052 mSmartClipDataListener = listener; 3019 mSmartClipDataListener = listener;
3053 } 3020 }
3054 3021
3055 public void setBackgroundOpaque(boolean opaque) { 3022 public void setBackgroundOpaque(boolean opaque) {
3056 if (mNativeContentViewCore != 0) { 3023 if (mNativeContentViewCore != 0) {
3057 nativeSetBackgroundOpaque(mNativeContentViewCore, opaque); 3024 nativeSetBackgroundOpaque(mNativeContentViewCore, opaque);
3058 } 3025 }
3059 } 3026 }
3060 3027
3061 @CalledByNative
3062 private void didDeferAfterResponseStarted(String enteringColor) {
3063 if (mNavigationTransitionDelegate != null ) {
3064 mNavigationTransitionDelegate.didDeferAfterResponseStarted(enteringC olor);
3065 }
3066 }
3067
3068 @CalledByNative
3069 public void didStartNavigationTransitionForFrame(long frameId) {
3070 if (mNavigationTransitionDelegate != null ) {
3071 mNavigationTransitionDelegate.didStartNavigationTransitionForFrame(f rameId);
3072 }
3073 }
3074
3075 @CalledByNative
3076 private boolean willHandleDeferAfterResponseStarted() {
3077 if (mNavigationTransitionDelegate == null) return false;
3078 return mNavigationTransitionDelegate.willHandleDeferAfterResponseStarted ();
3079 }
3080
3081 @VisibleForTesting 3028 @VisibleForTesting
3082 void setHasPendingNavigationTransitionForTesting() { 3029 void setHasPendingNavigationTransitionForTesting() {
3083 if (mNativeContentViewCore == 0) return; 3030 assert mWebContents != null;
3084 nativeSetHasPendingNavigationTransitionForTesting(mNativeContentViewCore ); 3031 mWebContents.setHasPendingNavigationTransitionForTesting();
3085 }
3086
3087 public void setNavigationTransitionDelegate(NavigationTransitionDelegate del egate) {
3088 mNavigationTransitionDelegate = delegate;
3089 }
3090
3091 @CalledByNative
3092 private void addEnteringStylesheetToTransition(String stylesheet) {
3093 if (mNavigationTransitionDelegate != null ) {
3094 mNavigationTransitionDelegate.addEnteringStylesheetToTransition(styl esheet);
3095 }
3096 } 3032 }
3097 3033
3098 /** 3034 /**
3099 * Offer a long press gesture to the embedding View, primarily for WebView c ompatibility. 3035 * Offer a long press gesture to the embedding View, primarily for WebView c ompatibility.
3100 * 3036 *
3101 * @return true if the embedder handled the event. 3037 * @return true if the embedder handled the event.
3102 */ 3038 */
3103 private boolean offerLongPressToEmbedder() { 3039 private boolean offerLongPressToEmbedder() {
3104 return mContainerView.performLongClick(); 3040 return mContainerView.performLongClick();
3105 } 3041 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 mPotentiallyActiveFlingCount--; 3079 mPotentiallyActiveFlingCount--;
3144 updateGestureStateListener(GestureEventType.FLING_END); 3080 updateGestureStateListener(GestureEventType.FLING_END);
3145 } 3081 }
3146 3082
3147 @Override 3083 @Override
3148 public void onScreenOrientationChanged(int orientation) { 3084 public void onScreenOrientationChanged(int orientation) {
3149 sendOrientationChangeEvent(orientation); 3085 sendOrientationChangeEvent(orientation);
3150 } 3086 }
3151 3087
3152 public void resumeResponseDeferredAtStart() { 3088 public void resumeResponseDeferredAtStart() {
3153 if (mNativeContentViewCore == 0) return; 3089 assert mWebContents != null;
3154 nativeResumeResponseDeferredAtStart(mNativeContentViewCore); 3090 mWebContents.resumeResponseDeferredAtStart();
3155 } 3091 }
3156 3092
3157 /** 3093 /**
3158 * Set whether the ContentViewCore requires the WebContents to be fullscreen in order to lock 3094 * Set whether the ContentViewCore requires the WebContents to be fullscreen in order to lock
3159 * the screen orientation. 3095 * the screen orientation.
3160 */ 3096 */
3161 public void setFullscreenRequiredForOrientationLock(boolean value) { 3097 public void setFullscreenRequiredForOrientationLock(boolean value) {
3162 mFullscreenRequiredForOrientationLock = value; 3098 mFullscreenRequiredForOrientationLock = value;
3163 } 3099 }
3164 3100
(...skipping 14 matching lines...) Expand all
3179 String referrerUrl, 3115 String referrerUrl,
3180 int referrerPolicy, 3116 int referrerPolicy,
3181 int uaOverrideOption, 3117 int uaOverrideOption,
3182 String extraHeaders, 3118 String extraHeaders,
3183 byte[] postData, 3119 byte[] postData,
3184 String baseUrlForDataUrl, 3120 String baseUrlForDataUrl,
3185 String virtualUrlForDataUrl, 3121 String virtualUrlForDataUrl,
3186 boolean canLoadLocalResources, 3122 boolean canLoadLocalResources,
3187 boolean isRendererInitiated); 3123 boolean isRendererInitiated);
3188 3124
3189 private native String nativeGetURL(long nativeContentViewCoreImpl);
3190
3191 private native boolean nativeIsIncognito(long nativeContentViewCoreImpl);
3192
3193 private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean f ocused); 3125 private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean f ocused);
3194 3126
3195 private native void nativeSendOrientationChangeEvent( 3127 private native void nativeSendOrientationChangeEvent(
3196 long nativeContentViewCoreImpl, int orientation); 3128 long nativeContentViewCoreImpl, int orientation);
3197 3129
3198 // All touch events (including flings, scrolls etc) accept coordinates in ph ysical pixels. 3130 // All touch events (including flings, scrolls etc) accept coordinates in ph ysical pixels.
3199 private native boolean nativeOnTouchEvent( 3131 private native boolean nativeOnTouchEvent(
3200 long nativeContentViewCoreImpl, MotionEvent event, 3132 long nativeContentViewCoreImpl, MotionEvent event,
3201 long timeMs, int action, int pointerCount, int historySize, int acti onIndex, 3133 long timeMs, int action, int pointerCount, int historySize, int acti onIndex,
3202 float x0, float y0, float x1, float y1, 3134 float x0, float y0, float x1, float y1,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 float anchorX, float anchorY, float deltaScale); 3177 float anchorX, float anchorY, float deltaScale);
3246 3178
3247 private native void nativeSelectBetweenCoordinates( 3179 private native void nativeSelectBetweenCoordinates(
3248 long nativeContentViewCoreImpl, float x1, float y1, float x2, float y2); 3180 long nativeContentViewCoreImpl, float x1, float y1, float x2, float y2);
3249 3181
3250 private native void nativeMoveCaret(long nativeContentViewCoreImpl, float x, float y); 3182 private native void nativeMoveCaret(long nativeContentViewCoreImpl, float x, float y);
3251 3183
3252 private native void nativeHideTextHandles(long nativeContentViewCoreImpl); 3184 private native void nativeHideTextHandles(long nativeContentViewCoreImpl);
3253 3185
3254 private native void nativeResetGestureDetection(long nativeContentViewCoreIm pl); 3186 private native void nativeResetGestureDetection(long nativeContentViewCoreIm pl);
3187
3255 private native void nativeSetDoubleTapSupportEnabled( 3188 private native void nativeSetDoubleTapSupportEnabled(
3256 long nativeContentViewCoreImpl, boolean enabled); 3189 long nativeContentViewCoreImpl, boolean enabled);
3190
3257 private native void nativeSetMultiTouchZoomSupportEnabled( 3191 private native void nativeSetMultiTouchZoomSupportEnabled(
3258 long nativeContentViewCoreImpl, boolean enabled); 3192 long nativeContentViewCoreImpl, boolean enabled);
3259 3193
3260 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp l, int[] indices); 3194 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp l, int[] indices);
3261 3195
3262 private native void nativeClearHistory(long nativeContentViewCoreImpl); 3196 private native void nativeClearHistory(long nativeContentViewCoreImpl);
3263 3197
3264 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl, 3198 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl,
3265 String script, JavaScriptCallback callback, boolean startRenderer); 3199 String script, JavaScriptCallback callback, boolean startRenderer);
3266 3200
3267 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl, String frameId, 3201 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl, String frameId,
3268 String message, String sourceOrigin, String targetOrigin); 3202 String message, String sourceOrigin, String targetOrigin);
3269 3203
3270 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl ); 3204 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl );
3271 3205
3272 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor eImpl); 3206 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor eImpl);
3273 3207
3274 private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreI mpl, 3208 private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreI mpl,
3275 boolean enabled, boolean reloadOnChange); 3209 boolean enabled, boolean reloadOnChange);
3210
3276 private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCo reImpl); 3211 private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCo reImpl);
3277 3212
3278 private native void nativeClearSslPreferences(long nativeContentViewCoreImpl ); 3213 private native void nativeClearSslPreferences(long nativeContentViewCoreImpl );
3279 3214
3280 private native void nativeSetAllowJavascriptInterfacesInspection( 3215 private native void nativeSetAllowJavascriptInterfacesInspection(
3281 long nativeContentViewCoreImpl, boolean allow); 3216 long nativeContentViewCoreImpl, boolean allow);
3282 3217
3283 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI mpl, Object object, 3218 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI mpl, Object object,
3284 String name, Class requiredAnnotation); 3219 String name, Class requiredAnnotation);
3285 3220
3286 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo reImpl, 3221 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo reImpl,
3287 String name); 3222 String name);
3288 3223
3289 private native int nativeGetNavigationHistory(long nativeContentViewCoreImpl , Object context); 3224 private native int nativeGetNavigationHistory(long nativeContentViewCoreImpl , Object context);
3225
3290 private native void nativeGetDirectedNavigationHistory(long nativeContentVie wCoreImpl, 3226 private native void nativeGetDirectedNavigationHistory(long nativeContentVie wCoreImpl,
3291 Object context, boolean isForward, int maxEntries); 3227 Object context, boolean isForward, int maxEntries);
3228
3292 private native String nativeGetOriginalUrlForActiveNavigationEntry( 3229 private native String nativeGetOriginalUrlForActiveNavigationEntry(
3293 long nativeContentViewCoreImpl); 3230 long nativeContentViewCoreImpl);
3294 3231
3295 private native void nativeWasResized(long nativeContentViewCoreImpl); 3232 private native void nativeWasResized(long nativeContentViewCoreImpl);
3296 3233
3297 private native void nativeSetAccessibilityEnabled( 3234 private native void nativeSetAccessibilityEnabled(
3298 long nativeContentViewCoreImpl, boolean enabled); 3235 long nativeContentViewCoreImpl, boolean enabled);
3299 3236
3300 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, 3237 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l,
3301 int x, int y, int w, int h); 3238 int x, int y, int w, int h);
3239
3302 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); 3240 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque);
3303
3304 private native void nativeResumeResponseDeferredAtStart(
3305 long nativeContentViewCoreImpl);
3306 private native void nativeSetHasPendingNavigationTransitionForTesting(
3307 long nativeContentViewCoreImpl);
3308 } 3241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698