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

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: Restructured WillHandleDeferAfterResponseStarted and DidDeferAfterResponseStarted APIs. 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 /** 230 /**
231 * An interface that allows the embedder to be notified of navigation transi tion 231 * An interface that allows the embedder to be notified of navigation transi tion
232 * related events and respond to them. 232 * related events and respond to them.
233 */ 233 */
234 public interface NavigationTransitionDelegate { 234 public interface NavigationTransitionDelegate {
shatch 2014/08/05 14:54:24 If you're going to move didDeferAfterResponseStart
AKVT 2014/08/05 16:07:23 I already moved the interface in WebContents, but
Yaron 2014/08/06 00:35:45 I don't see any references to it in chrome/ direct
235 /** 235 /**
236 * Called when the navigation is deferred immediately after the response started. 236 * Called when the navigation is deferred immediately after the response started.
237 * 237 *
238 * @param enteringColor The background color of the entering document, a s a String 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 239 * representing a legal CSS color value. This is in serted into
240 * the transition layer's markup after the entering stylesheets 240 * the transition layer's markup after the entering stylesheets
241 * have been applied. 241 * have been applied.
242 */ 242 */
243 public void didDeferAfterResponseStarted(String enteringColor); 243 public void didDeferAfterResponseStarted(String enteringColor);
244 244
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 private boolean mTouchScrollInProgress; 356 private boolean mTouchScrollInProgress;
357 357
358 // The outstanding fling start events that hasn't got fling end yet. It may be > 1 because 358 // The outstanding fling start events that hasn't got fling end yet. It may be > 1 because
359 // onNativeFlingStopped() is called asynchronously. 359 // onNativeFlingStopped() is called asynchronously.
360 private int mPotentiallyActiveFlingCount; 360 private int mPotentiallyActiveFlingCount;
361 361
362 private ViewAndroid mViewAndroid; 362 private ViewAndroid mViewAndroid;
363 363
364 private SmartClipDataListener mSmartClipDataListener = null; 364 private SmartClipDataListener mSmartClipDataListener = null;
365 365
366 private NavigationTransitionDelegate mNavigationTransitionDelegate = null; 366 private NavigationTransitionDelegate mNavigationTransitionDelegate = null;
shatch 2014/08/05 14:54:24 Move this as well?
AKVT 2014/08/05 16:07:23 Currently I have duplicated by fearing build failu
Yaron 2014/08/06 00:35:45 Which build breaks are you referring to? If everyt
367 367
368 // This holds the state of editable text (e.g. contents of <input>, contente ditable) of 368 // This holds the state of editable text (e.g. contents of <input>, contente ditable) of
369 // a focused element. 369 // a focused element.
370 // Every time the user, IME, javascript (Blink), autofill etc. modifies the content, the new 370 // Every time the user, IME, javascript (Blink), autofill etc. modifies the content, the new
371 // state must be reflected to this to keep consistency. 371 // state must be reflected to this to keep consistency.
372 private final Editable mEditable; 372 private final Editable mEditable;
373 373
374 /** 374 /**
375 * PID used to indicate an invalid render process. 375 * PID used to indicate an invalid render process.
376 */ 376 */
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 params.mBaseUrlForDataUrl, 899 params.mBaseUrlForDataUrl,
900 params.mVirtualUrlForDataUrl, 900 params.mVirtualUrlForDataUrl,
901 params.mCanLoadLocalResources, 901 params.mCanLoadLocalResources,
902 params.mIsRendererInitiated); 902 params.mIsRendererInitiated);
903 } 903 }
904 904
905 /** 905 /**
906 * Stops loading the current web contents. 906 * Stops loading the current web contents.
907 */ 907 */
908 public void stopLoading() { 908 public void stopLoading() {
909 if (mWebContents != null) mWebContents.stop(); 909 assert mWebContents != null;
910 mWebContents.stop();
910 } 911 }
911 912
912 /** 913 /**
913 * Get the URL of the current page. 914 * Get the URL of the current page.
914 * 915 *
915 * @return The URL of the current page. 916 * @return The URL of the current page.
916 */ 917 */
917 public String getUrl() { 918 public String getUrl() {
918 if (mNativeContentViewCore != 0) return nativeGetURL(mNativeContentViewC ore); 919 assert mWebContents != null;
919 return null; 920 return mWebContents.getUrl();
920 } 921 }
921 922
922 /** 923 /**
923 * Get the title of the current page. 924 * Get the title of the current page.
924 * 925 *
925 * @return The title of the current page. 926 * @return The title of the current page.
926 */ 927 */
927 public String getTitle() { 928 public String getTitle() {
928 return mWebContents == null ? null : mWebContents.getTitle(); 929 assert mWebContents != null;
930 return mWebContents.getTitle();
929 } 931 }
930 932
931 /** 933 /**
932 * Shows an interstitial page driven by the passed in delegate. 934 * Shows an interstitial page driven by the passed in delegate.
933 * 935 *
934 * @param url The URL being blocked by the interstitial. 936 * @param url The URL being blocked by the interstitial.
935 * @param delegate The delegate handling the interstitial. 937 * @param delegate The delegate handling the interstitial.
936 */ 938 */
937 @VisibleForTesting 939 @VisibleForTesting
938 public void showInterstitialPage( 940 public void showInterstitialPage(
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 if (getContentViewClient().doesPerformWebSearch()) return true; 2147 if (getContentViewClient().doesPerformWebSearch()) return true;
2146 Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); 2148 Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
2147 intent.putExtra(SearchManager.EXTRA_NEW_SEARCH, true); 2149 intent.putExtra(SearchManager.EXTRA_NEW_SEARCH, true);
2148 return getContext().getPackageManager().queryIntentActivities(in tent, 2150 return getContext().getPackageManager().queryIntentActivities(in tent,
2149 PackageManager.MATCH_DEFAULT_ONLY).size() > 0; 2151 PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
2150 } 2152 }
2151 }; 2153 };
2152 mActionMode = null; 2154 mActionMode = null;
2153 // On ICS, startActionMode throws an NPE when getParent() is null. 2155 // On ICS, startActionMode throws an NPE when getParent() is null.
2154 if (mContainerView.getParent() != null) { 2156 if (mContainerView.getParent() != null) {
2157 assert mWebContents != null;
2155 mActionMode = mContainerView.startActionMode( 2158 mActionMode = mContainerView.startActionMode(
2156 getContentViewClient().getSelectActionModeCallback(getContex t(), actionHandler, 2159 getContentViewClient().getSelectActionModeCallback(getContex t(), actionHandler,
2157 nativeIsIncognito(mNativeContentViewCore))); 2160 mWebContents.isIncognito()));
2158 } 2161 }
2159 mUnselectAllOnActionModeDismiss = true; 2162 mUnselectAllOnActionModeDismiss = true;
2160 if (mActionMode == null) { 2163 if (mActionMode == null) {
2161 // There is no ActionMode, so remove the selection. 2164 // There is no ActionMode, so remove the selection.
2162 mImeAdapter.unselect(); 2165 mImeAdapter.unselect();
2163 } else { 2166 } else {
2164 getContentViewClient().onContextualActionBarShown(); 2167 getContentViewClient().onContextualActionBarShown();
2165 } 2168 }
2166 } 2169 }
2167 2170
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 mSmartClipDataListener = listener; 3055 mSmartClipDataListener = listener;
3053 } 3056 }
3054 3057
3055 public void setBackgroundOpaque(boolean opaque) { 3058 public void setBackgroundOpaque(boolean opaque) {
3056 if (mNativeContentViewCore != 0) { 3059 if (mNativeContentViewCore != 0) {
3057 nativeSetBackgroundOpaque(mNativeContentViewCore, opaque); 3060 nativeSetBackgroundOpaque(mNativeContentViewCore, opaque);
3058 } 3061 }
3059 } 3062 }
3060 3063
3061 @CalledByNative 3064 @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) { 3065 public void didStartNavigationTransitionForFrame(long frameId) {
shatch 2014/08/05 14:54:24 Seems like this would need to move as well?
AKVT 2014/08/05 16:07:24 Earlier Yaron suggested to move 2 functions which
Yaron 2014/08/06 00:35:45 Well logically it doesn't make sense to split thes
3070 if (mNavigationTransitionDelegate != null ) { 3066 if (mNavigationTransitionDelegate != null ) {
3071 mNavigationTransitionDelegate.didStartNavigationTransitionForFrame(f rameId); 3067 mNavigationTransitionDelegate.didStartNavigationTransitionForFrame(f rameId);
3072 } 3068 }
3073 } 3069 }
3074 3070
3075 @CalledByNative
3076 private boolean willHandleDeferAfterResponseStarted() {
3077 if (mNavigationTransitionDelegate == null) return false;
3078 return mNavigationTransitionDelegate.willHandleDeferAfterResponseStarted ();
3079 }
3080
3081 @VisibleForTesting 3071 @VisibleForTesting
3082 void setHasPendingNavigationTransitionForTesting() { 3072 void setHasPendingNavigationTransitionForTesting() {
3083 if (mNativeContentViewCore == 0) return; 3073 assert mWebContents != null;
3084 nativeSetHasPendingNavigationTransitionForTesting(mNativeContentViewCore ); 3074 mWebContents.setHasPendingNavigationTransitionForTesting();
3085 } 3075 }
3086 3076
3087 public void setNavigationTransitionDelegate(NavigationTransitionDelegate del egate) { 3077 public void setNavigationTransitionDelegate(NavigationTransitionDelegate del egate) {
3088 mNavigationTransitionDelegate = delegate; 3078 mNavigationTransitionDelegate = delegate;
shatch 2014/08/05 14:54:24 And this?
AKVT 2014/08/05 16:07:23 This too I duplicated as I mentioned on top. Pleas
Yaron 2014/08/06 00:35:45 I don't see the benefit of duplicating this. Pleas
3089 } 3079 }
3090 3080
3091 @CalledByNative
3092 private void addEnteringStylesheetToTransition(String stylesheet) {
3093 if (mNavigationTransitionDelegate != null ) {
3094 mNavigationTransitionDelegate.addEnteringStylesheetToTransition(styl esheet);
3095 }
3096 }
3097
3098 /** 3081 /**
3099 * Offer a long press gesture to the embedding View, primarily for WebView c ompatibility. 3082 * Offer a long press gesture to the embedding View, primarily for WebView c ompatibility.
3100 * 3083 *
3101 * @return true if the embedder handled the event. 3084 * @return true if the embedder handled the event.
3102 */ 3085 */
3103 private boolean offerLongPressToEmbedder() { 3086 private boolean offerLongPressToEmbedder() {
3104 return mContainerView.performLongClick(); 3087 return mContainerView.performLongClick();
3105 } 3088 }
3106 3089
3107 /** 3090 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 mPotentiallyActiveFlingCount--; 3126 mPotentiallyActiveFlingCount--;
3144 updateGestureStateListener(GestureEventType.FLING_END); 3127 updateGestureStateListener(GestureEventType.FLING_END);
3145 } 3128 }
3146 3129
3147 @Override 3130 @Override
3148 public void onScreenOrientationChanged(int orientation) { 3131 public void onScreenOrientationChanged(int orientation) {
3149 sendOrientationChangeEvent(orientation); 3132 sendOrientationChangeEvent(orientation);
3150 } 3133 }
3151 3134
3152 public void resumeResponseDeferredAtStart() { 3135 public void resumeResponseDeferredAtStart() {
3153 if (mNativeContentViewCore == 0) return; 3136 assert mWebContents != null;
3154 nativeResumeResponseDeferredAtStart(mNativeContentViewCore); 3137 mWebContents.resumeResponseDeferredAtStart();
3155 } 3138 }
3156 3139
3157 /** 3140 /**
3158 * Set whether the ContentViewCore requires the WebContents to be fullscreen in order to lock 3141 * Set whether the ContentViewCore requires the WebContents to be fullscreen in order to lock
3159 * the screen orientation. 3142 * the screen orientation.
3160 */ 3143 */
3161 public void setFullscreenRequiredForOrientationLock(boolean value) { 3144 public void setFullscreenRequiredForOrientationLock(boolean value) {
3162 mFullscreenRequiredForOrientationLock = value; 3145 mFullscreenRequiredForOrientationLock = value;
3163 } 3146 }
3164 3147
(...skipping 14 matching lines...) Expand all
3179 String referrerUrl, 3162 String referrerUrl,
3180 int referrerPolicy, 3163 int referrerPolicy,
3181 int uaOverrideOption, 3164 int uaOverrideOption,
3182 String extraHeaders, 3165 String extraHeaders,
3183 byte[] postData, 3166 byte[] postData,
3184 String baseUrlForDataUrl, 3167 String baseUrlForDataUrl,
3185 String virtualUrlForDataUrl, 3168 String virtualUrlForDataUrl,
3186 boolean canLoadLocalResources, 3169 boolean canLoadLocalResources,
3187 boolean isRendererInitiated); 3170 boolean isRendererInitiated);
3188 3171
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); 3172 private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean f ocused);
3194 3173
3195 private native void nativeSendOrientationChangeEvent( 3174 private native void nativeSendOrientationChangeEvent(
3196 long nativeContentViewCoreImpl, int orientation); 3175 long nativeContentViewCoreImpl, int orientation);
3197 3176
3198 // All touch events (including flings, scrolls etc) accept coordinates in ph ysical pixels. 3177 // All touch events (including flings, scrolls etc) accept coordinates in ph ysical pixels.
3199 private native boolean nativeOnTouchEvent( 3178 private native boolean nativeOnTouchEvent(
3200 long nativeContentViewCoreImpl, MotionEvent event, 3179 long nativeContentViewCoreImpl, MotionEvent event,
3201 long timeMs, int action, int pointerCount, int historySize, int acti onIndex, 3180 long timeMs, int action, int pointerCount, int historySize, int acti onIndex,
3202 float x0, float y0, float x1, float y1, 3181 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); 3224 float anchorX, float anchorY, float deltaScale);
3246 3225
3247 private native void nativeSelectBetweenCoordinates( 3226 private native void nativeSelectBetweenCoordinates(
3248 long nativeContentViewCoreImpl, float x1, float y1, float x2, float y2); 3227 long nativeContentViewCoreImpl, float x1, float y1, float x2, float y2);
3249 3228
3250 private native void nativeMoveCaret(long nativeContentViewCoreImpl, float x, float y); 3229 private native void nativeMoveCaret(long nativeContentViewCoreImpl, float x, float y);
3251 3230
3252 private native void nativeHideTextHandles(long nativeContentViewCoreImpl); 3231 private native void nativeHideTextHandles(long nativeContentViewCoreImpl);
3253 3232
3254 private native void nativeResetGestureDetection(long nativeContentViewCoreIm pl); 3233 private native void nativeResetGestureDetection(long nativeContentViewCoreIm pl);
3234
3255 private native void nativeSetDoubleTapSupportEnabled( 3235 private native void nativeSetDoubleTapSupportEnabled(
3256 long nativeContentViewCoreImpl, boolean enabled); 3236 long nativeContentViewCoreImpl, boolean enabled);
3237
3257 private native void nativeSetMultiTouchZoomSupportEnabled( 3238 private native void nativeSetMultiTouchZoomSupportEnabled(
3258 long nativeContentViewCoreImpl, boolean enabled); 3239 long nativeContentViewCoreImpl, boolean enabled);
3259 3240
3260 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp l, int[] indices); 3241 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp l, int[] indices);
3261 3242
3262 private native void nativeClearHistory(long nativeContentViewCoreImpl); 3243 private native void nativeClearHistory(long nativeContentViewCoreImpl);
3263 3244
3264 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl, 3245 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl,
3265 String script, JavaScriptCallback callback, boolean startRenderer); 3246 String script, JavaScriptCallback callback, boolean startRenderer);
3266 3247
3267 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl, String frameId, 3248 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl, String frameId,
3268 String message, String sourceOrigin, String targetOrigin); 3249 String message, String sourceOrigin, String targetOrigin);
3269 3250
3270 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl ); 3251 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl );
3271 3252
3272 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor eImpl); 3253 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor eImpl);
3273 3254
3274 private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreI mpl, 3255 private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreI mpl,
3275 boolean enabled, boolean reloadOnChange); 3256 boolean enabled, boolean reloadOnChange);
3257
3276 private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCo reImpl); 3258 private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCo reImpl);
3277 3259
3278 private native void nativeClearSslPreferences(long nativeContentViewCoreImpl ); 3260 private native void nativeClearSslPreferences(long nativeContentViewCoreImpl );
3279 3261
3280 private native void nativeSetAllowJavascriptInterfacesInspection( 3262 private native void nativeSetAllowJavascriptInterfacesInspection(
3281 long nativeContentViewCoreImpl, boolean allow); 3263 long nativeContentViewCoreImpl, boolean allow);
3282 3264
3283 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI mpl, Object object, 3265 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI mpl, Object object,
3284 String name, Class requiredAnnotation); 3266 String name, Class requiredAnnotation);
3285 3267
3286 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo reImpl, 3268 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo reImpl,
3287 String name); 3269 String name);
3288 3270
3289 private native int nativeGetNavigationHistory(long nativeContentViewCoreImpl , Object context); 3271 private native int nativeGetNavigationHistory(long nativeContentViewCoreImpl , Object context);
3272
3290 private native void nativeGetDirectedNavigationHistory(long nativeContentVie wCoreImpl, 3273 private native void nativeGetDirectedNavigationHistory(long nativeContentVie wCoreImpl,
3291 Object context, boolean isForward, int maxEntries); 3274 Object context, boolean isForward, int maxEntries);
3275
3292 private native String nativeGetOriginalUrlForActiveNavigationEntry( 3276 private native String nativeGetOriginalUrlForActiveNavigationEntry(
3293 long nativeContentViewCoreImpl); 3277 long nativeContentViewCoreImpl);
3294 3278
3295 private native void nativeWasResized(long nativeContentViewCoreImpl); 3279 private native void nativeWasResized(long nativeContentViewCoreImpl);
3296 3280
3297 private native void nativeSetAccessibilityEnabled( 3281 private native void nativeSetAccessibilityEnabled(
3298 long nativeContentViewCoreImpl, boolean enabled); 3282 long nativeContentViewCoreImpl, boolean enabled);
3299 3283
3300 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, 3284 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l,
3301 int x, int y, int w, int h); 3285 int x, int y, int w, int h);
3286
3302 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); 3287 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 } 3288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698