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

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

Issue 406023002: Restructuring NavigationController functionalities from ContentViewCore to NavigationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unwanted headers Created 6 years, 5 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.ContentResolver; 10 import android.content.ContentResolver;
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 } 869 }
870 870
871 /** 871 /**
872 * Load url without fixing up the url string. Consumers of ContentView are r esponsible for 872 * Load url without fixing up the url string. Consumers of ContentView are r esponsible for
873 * ensuring the URL passed in is properly formatted (i.e. the scheme has bee n added if left 873 * ensuring the URL passed in is properly formatted (i.e. the scheme has bee n added if left
874 * off during user input). 874 * off during user input).
875 * 875 *
876 * @param params Parameters for this load. 876 * @param params Parameters for this load.
877 */ 877 */
878 public void loadUrl(LoadUrlParams params) { 878 public void loadUrl(LoadUrlParams params) {
879 if (mNativeContentViewCore == 0) return; 879 assert mWebContents != null;
880 880 mWebContents.getNavigationController().loadUrl(params);
881 nativeLoadUrl(mNativeContentViewCore,
882 params.mUrl,
883 params.mLoadUrlType,
884 params.mTransitionType,
885 params.getReferrer() != null ? params.getReferrer().getUrl() : n ull,
886 params.getReferrer() != null ? params.getReferrer().getPolicy() : 0,
887 params.mUaOverrideOption,
888 params.getExtraHeadersString(),
889 params.mPostData,
890 params.mBaseUrlForDataUrl,
891 params.mVirtualUrlForDataUrl,
892 params.mCanLoadLocalResources,
893 params.mIsRendererInitiated);
894 } 881 }
895 882
896 /** 883 /**
897 * Stops loading the current web contents. 884 * Stops loading the current web contents.
898 */ 885 */
899 public void stopLoading() { 886 public void stopLoading() {
900 if (mWebContents != null) mWebContents.stop(); 887 if (mWebContents != null) mWebContents.stop();
901 } 888 }
902 889
903 /** 890 /**
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 */ 1081 */
1095 public void continuePendingReload() { 1082 public void continuePendingReload() {
1096 if (mWebContents != null) mWebContents.getNavigationController().continu ePendingReload(); 1083 if (mWebContents != null) mWebContents.getNavigationController().continu ePendingReload();
1097 } 1084 }
1098 1085
1099 /** 1086 /**
1100 * Clears the ContentViewCore's page history in both the backwards and 1087 * Clears the ContentViewCore's page history in both the backwards and
1101 * forwards directions. 1088 * forwards directions.
1102 */ 1089 */
1103 public void clearHistory() { 1090 public void clearHistory() {
1104 if (mNativeContentViewCore != 0) nativeClearHistory(mNativeContentViewCo re); 1091 assert mWebContents != null;
1092 mWebContents.getNavigationController().clearHistory();
1105 } 1093 }
1106 1094
1107 /** 1095 /**
1108 * @return The selected text (empty if no text selected). 1096 * @return The selected text (empty if no text selected).
1109 */ 1097 */
1110 public String getSelectedText() { 1098 public String getSelectedText() {
1111 return mHasSelection ? mLastSelectedText : ""; 1099 return mHasSelection ? mLastSelectedText : "";
1112 } 1100 }
1113 1101
1114 /** 1102 /**
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 mUnselectAllOnActionModeDismiss = true; 2229 mUnselectAllOnActionModeDismiss = true;
2242 if (mActionMode == null) { 2230 if (mActionMode == null) {
2243 // There is no ActionMode, so remove the selection. 2231 // There is no ActionMode, so remove the selection.
2244 mImeAdapter.unselect(); 2232 mImeAdapter.unselect();
2245 } else { 2233 } else {
2246 getContentViewClient().onContextualActionBarShown(); 2234 getContentViewClient().onContextualActionBarShown();
2247 } 2235 }
2248 } 2236 }
2249 2237
2250 public boolean getUseDesktopUserAgent() { 2238 public boolean getUseDesktopUserAgent() {
2251 if (mNativeContentViewCore != 0) { 2239 assert mWebContents != null;
2252 return nativeGetUseDesktopUserAgent(mNativeContentViewCore); 2240 return mWebContents.getNavigationController().getUseDesktopUserAgent();
2253 }
2254 return false;
2255 } 2241 }
2256 2242
2257 /** 2243 /**
2258 * Set whether or not we're using a desktop user agent for the currently loa ded page. 2244 * Set whether or not we're using a desktop user agent for the currently loa ded page.
2259 * @param override If true, use a desktop user agent. Use a mobile one othe rwise. 2245 * @param override If true, use a desktop user agent. Use a mobile one othe rwise.
2260 * @param reloadOnChange Reload the page if the UA has changed. 2246 * @param reloadOnChange Reload the page if the UA has changed.
2261 */ 2247 */
2262 public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange) { 2248 public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange) {
2263 if (mNativeContentViewCore != 0) { 2249 assert mWebContents != null;
Yaron 2014/07/22 20:49:06 Sadly, I think this one can happen, which would be
Ted C 2014/07/23 00:04:22 A CVC should always have a WebContents (unless des
2264 nativeSetUseDesktopUserAgent(mNativeContentViewCore, override, reloa dOnChange); 2250 mWebContents.getNavigationController().setUseDesktopUserAgent(override,
2265 } 2251 reloadOnChange);
2266 } 2252 }
2267 2253
2268 public void clearSslPreferences() { 2254 public void clearSslPreferences() {
2269 if (mNativeContentViewCore != 0) nativeClearSslPreferences(mNativeConten tViewCore); 2255 assert mWebContents != null;
2256 mWebContents.getNavigationController().clearSslPreferences();
2270 } 2257 }
2271 2258
2272 private boolean isSelectionHandleShowing() { 2259 private boolean isSelectionHandleShowing() {
2273 return mSelectionHandleController != null && mSelectionHandleController. isShowing(); 2260 return mSelectionHandleController != null && mSelectionHandleController. isShowing();
2274 } 2261 }
2275 2262
2276 private boolean isInsertionHandleShowing() { 2263 private boolean isInsertionHandleShowing() {
2277 return mInsertionHandleController != null && mInsertionHandleController. isShowing(); 2264 return mInsertionHandleController != null && mInsertionHandleController. isShowing();
2278 } 2265 }
2279 2266
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 * @param animate Whether the transition should be animated or not. 3065 * @param animate Whether the transition should be animated or not.
3079 */ 3066 */
3080 public void updateTopControlsState(boolean enableHiding, boolean enableShowi ng, 3067 public void updateTopControlsState(boolean enableHiding, boolean enableShowi ng,
3081 boolean animate) { 3068 boolean animate) {
3082 assert mWebContents != null; 3069 assert mWebContents != null;
3083 mWebContents.updateTopControlsState( 3070 mWebContents.updateTopControlsState(
3084 enableHiding, enableShowing, animate); 3071 enableHiding, enableShowing, animate);
3085 } 3072 }
3086 3073
3087 /** 3074 /**
3088 * Callback factory method for nativeGetNavigationHistory().
3089 */
3090 @CalledByNative
3091 private void addToNavigationHistory(Object history, int index, String url, S tring virtualUrl,
3092 String originalUrl, String title, Bitmap favicon) {
3093 NavigationEntry entry = new NavigationEntry(
3094 index, url, virtualUrl, originalUrl, title, favicon);
3095 ((NavigationHistory) history).addEntry(entry);
3096 }
3097
3098 /**
3099 * Get a copy of the navigation history of the view. 3075 * Get a copy of the navigation history of the view.
3100 */ 3076 */
3101 public NavigationHistory getNavigationHistory() { 3077 public NavigationHistory getNavigationHistory() {
3102 NavigationHistory history = new NavigationHistory(); 3078 assert mWebContents != null;
3103 if (mNativeContentViewCore != 0) { 3079 return mWebContents.getNavigationController().getNavigationHistory();
3104 int currentIndex = nativeGetNavigationHistory(mNativeContentViewCore , history);
3105 history.setCurrentEntryIndex(currentIndex);
3106 }
3107 return history;
3108 } 3080 }
3109 3081
3110 @Override 3082 @Override
3111 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) { 3083 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) {
3084 assert mWebContents != null;
3112 NavigationHistory history = new NavigationHistory(); 3085 NavigationHistory history = new NavigationHistory();
3113 if (mNativeContentViewCore != 0) { 3086 mWebContents.getNavigationController().getDirectedNavigationHistory(
3114 nativeGetDirectedNavigationHistory( 3087 isForward, itemLimit);
3115 mNativeContentViewCore, history, isForward, itemLimit);
3116 }
3117 return history; 3088 return history;
3118 } 3089 }
3119 3090
3120 /** 3091 /**
3121 * @return The original request URL for the current navigation entry, or nul l if there is no 3092 * @return The original request URL for the current navigation entry, or nul l if there is no
3122 * current entry. 3093 * current entry.
3123 */ 3094 */
3124 public String getOriginalUrlForActiveNavigationEntry() { 3095 public String getOriginalUrlForActiveNavigationEntry() {
3125 if (mNativeContentViewCore != 0) { 3096 assert mWebContents != null;
3126 return nativeGetOriginalUrlForActiveNavigationEntry(mNativeContentVi ewCore); 3097 return mWebContents.getNavigationController().
3127 } 3098 getOriginalUrlForActiveNavigationEntry();
3128 return "";
3129 } 3099 }
3130 3100
3131 /** 3101 /**
3132 * @return The cached copy of render positions and scales. 3102 * @return The cached copy of render positions and scales.
3133 */ 3103 */
3134 public RenderCoordinates getRenderCoordinates() { 3104 public RenderCoordinates getRenderCoordinates() {
3135 return mRenderCoordinates; 3105 return mRenderCoordinates;
3136 } 3106 }
3137 3107
3138 @CalledByNative 3108 @CalledByNative
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3255 3225
3256 @CalledByNative 3226 @CalledByNative
3257 private boolean isFullscreenRequiredForOrientationLock() { 3227 private boolean isFullscreenRequiredForOrientationLock() {
3258 return mFullscreenRequiredForOrientationLock; 3228 return mFullscreenRequiredForOrientationLock;
3259 } 3229 }
3260 3230
3261 private native WebContents nativeGetWebContentsAndroid(long nativeContentVie wCoreImpl); 3231 private native WebContents nativeGetWebContentsAndroid(long nativeContentVie wCoreImpl);
3262 3232
3263 private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentV iewCoreImpl); 3233 private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentV iewCoreImpl);
3264 3234
3265 private native void nativeLoadUrl(
3266 long nativeContentViewCoreImpl,
3267 String url,
3268 int loadUrlType,
3269 int transitionType,
3270 String referrerUrl,
3271 int referrerPolicy,
3272 int uaOverrideOption,
3273 String extraHeaders,
3274 byte[] postData,
3275 String baseUrlForDataUrl,
3276 String virtualUrlForDataUrl,
3277 boolean canLoadLocalResources,
3278 boolean isRendererInitiated);
3279
3280 private native String nativeGetURL(long nativeContentViewCoreImpl); 3235 private native String nativeGetURL(long nativeContentViewCoreImpl);
3281 3236
3282 private native boolean nativeIsIncognito(long nativeContentViewCoreImpl); 3237 private native boolean nativeIsIncognito(long nativeContentViewCoreImpl);
3283 3238
3284 private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean f ocused); 3239 private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean f ocused);
3285 3240
3286 private native void nativeSendOrientationChangeEvent( 3241 private native void nativeSendOrientationChangeEvent(
3287 long nativeContentViewCoreImpl, int orientation); 3242 long nativeContentViewCoreImpl, int orientation);
3288 3243
3289 // All touch events (including flings, scrolls etc) accept coordinates in ph ysical pixels. 3244 // All touch events (including flings, scrolls etc) accept coordinates in ph ysical pixels.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 private native void nativeMoveCaret(long nativeContentViewCoreImpl, float x, float y); 3295 private native void nativeMoveCaret(long nativeContentViewCoreImpl, float x, float y);
3341 3296
3342 private native void nativeResetGestureDetection(long nativeContentViewCoreIm pl); 3297 private native void nativeResetGestureDetection(long nativeContentViewCoreIm pl);
3343 private native void nativeSetDoubleTapSupportEnabled( 3298 private native void nativeSetDoubleTapSupportEnabled(
3344 long nativeContentViewCoreImpl, boolean enabled); 3299 long nativeContentViewCoreImpl, boolean enabled);
3345 private native void nativeSetMultiTouchZoomSupportEnabled( 3300 private native void nativeSetMultiTouchZoomSupportEnabled(
3346 long nativeContentViewCoreImpl, boolean enabled); 3301 long nativeContentViewCoreImpl, boolean enabled);
3347 3302
3348 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp l, int[] indices); 3303 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp l, int[] indices);
3349 3304
3350 private native void nativeClearHistory(long nativeContentViewCoreImpl);
3351
3352 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl, 3305 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl,
3353 String script, JavaScriptCallback callback, boolean startRenderer); 3306 String script, JavaScriptCallback callback, boolean startRenderer);
3354 3307
3355 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl, String frameId, 3308 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl, String frameId,
3356 String message, String sourceOrigin, String targetOrigin); 3309 String message, String sourceOrigin, String targetOrigin);
3357 3310
3358 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl ); 3311 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl );
3359 3312
3360 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor eImpl); 3313 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor eImpl);
3361 3314
3362 private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreI mpl,
3363 boolean enabled, boolean reloadOnChange);
3364 private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCo reImpl);
3365
3366 private native void nativeClearSslPreferences(long nativeContentViewCoreImpl );
3367
3368 private native void nativeSetAllowJavascriptInterfacesInspection( 3315 private native void nativeSetAllowJavascriptInterfacesInspection(
3369 long nativeContentViewCoreImpl, boolean allow); 3316 long nativeContentViewCoreImpl, boolean allow);
3370 3317
3371 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI mpl, Object object, 3318 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI mpl, Object object,
3372 String name, Class requiredAnnotation); 3319 String name, Class requiredAnnotation);
3373 3320
3374 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo reImpl, 3321 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo reImpl,
3375 String name); 3322 String name);
3376 3323
3377 private native int nativeGetNavigationHistory(long nativeContentViewCoreImpl , Object context);
3378 private native void nativeGetDirectedNavigationHistory(long nativeContentVie wCoreImpl,
3379 Object context, boolean isForward, int maxEntries);
3380 private native String nativeGetOriginalUrlForActiveNavigationEntry(
3381 long nativeContentViewCoreImpl);
3382
3383 private native void nativeWasResized(long nativeContentViewCoreImpl); 3324 private native void nativeWasResized(long nativeContentViewCoreImpl);
3384 3325
3385 private native void nativeSetAccessibilityEnabled( 3326 private native void nativeSetAccessibilityEnabled(
3386 long nativeContentViewCoreImpl, boolean enabled); 3327 long nativeContentViewCoreImpl, boolean enabled);
3387 3328
3388 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, 3329 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l,
3389 int x, int y, int w, int h); 3330 int x, int y, int w, int h);
3390 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); 3331 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque);
3391 3332
3392 private native void nativeResumeResponseDeferredAtStart( 3333 private native void nativeResumeResponseDeferredAtStart(
3393 long nativeContentViewCoreImpl); 3334 long nativeContentViewCoreImpl);
3394 private native void nativeSetHasPendingNavigationTransitionForTesting( 3335 private native void nativeSetHasPendingNavigationTransitionForTesting(
3395 long nativeContentViewCoreImpl); 3336 long nativeContentViewCoreImpl);
3396 } 3337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698