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

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: Fixed review comments. 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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 } 853 }
854 854
855 /** 855 /**
856 * Load url without fixing up the url string. Consumers of ContentView are r esponsible for 856 * Load url without fixing up the url string. Consumers of ContentView are r esponsible for
857 * ensuring the URL passed in is properly formatted (i.e. the scheme has bee n added if left 857 * ensuring the URL passed in is properly formatted (i.e. the scheme has bee n added if left
858 * off during user input). 858 * off during user input).
859 * 859 *
860 * @param params Parameters for this load. 860 * @param params Parameters for this load.
861 */ 861 */
862 public void loadUrl(LoadUrlParams params) { 862 public void loadUrl(LoadUrlParams params) {
863 if (mNativeContentViewCore == 0) return; 863 assert mWebContents != null;
864 864 mWebContents.getNavigationController().loadUrl(params);
865 nativeLoadUrl(mNativeContentViewCore,
866 params.mUrl,
867 params.mLoadUrlType,
868 params.mTransitionType,
869 params.getReferrer() != null ? params.getReferrer().getUrl() : n ull,
870 params.getReferrer() != null ? params.getReferrer().getPolicy() : 0,
871 params.mUaOverrideOption,
872 params.getExtraHeadersString(),
873 params.mPostData,
874 params.mBaseUrlForDataUrl,
875 params.mVirtualUrlForDataUrl,
876 params.mCanLoadLocalResources,
877 params.mIsRendererInitiated);
878 } 865 }
879 866
880 /** 867 /**
881 * Stops loading the current web contents. 868 * Stops loading the current web contents.
882 */ 869 */
883 public void stopLoading() { 870 public void stopLoading() {
884 if (mWebContents != null) mWebContents.stop(); 871 if (mWebContents != null) mWebContents.stop();
885 } 872 }
886 873
887 /** 874 /**
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 * Cancel the pending reload. 1057 * Cancel the pending reload.
1071 */ 1058 */
1072 public void cancelPendingReload() { 1059 public void cancelPendingReload() {
1073 if (mWebContents != null) mWebContents.getNavigationController().cancelP endingReload(); 1060 if (mWebContents != null) mWebContents.getNavigationController().cancelP endingReload();
1074 } 1061 }
1075 1062
1076 /** 1063 /**
1077 * Continue the pending reload. 1064 * Continue the pending reload.
1078 */ 1065 */
1079 public void continuePendingReload() { 1066 public void continuePendingReload() {
1080 if (mWebContents != null) mWebContents.getNavigationController().continu ePendingReload(); 1067 if (mWebContents != null) mWebContents.getNavigationController().continu ePendingReload();
Yaron 2014/07/23 18:58:38 make this an assert to be consistent with others.
AKVT 2014/07/24 07:47:24 All NavigationController related functions has bee
1081 } 1068 }
1082 1069
1083 /** 1070 /**
1084 * Clears the ContentViewCore's page history in both the backwards and 1071 * Clears the ContentViewCore's page history in both the backwards and
1085 * forwards directions. 1072 * forwards directions.
1086 */ 1073 */
1087 public void clearHistory() { 1074 public void clearHistory() {
1088 if (mNativeContentViewCore != 0) nativeClearHistory(mNativeContentViewCo re); 1075 assert mWebContents != null;
1076 mWebContents.getNavigationController().clearHistory();
1089 } 1077 }
1090 1078
1091 /** 1079 /**
1092 * @return The selected text (empty if no text selected). 1080 * @return The selected text (empty if no text selected).
1093 */ 1081 */
1094 public String getSelectedText() { 1082 public String getSelectedText() {
1095 return mHasSelection ? mLastSelectedText : ""; 1083 return mHasSelection ? mLastSelectedText : "";
1096 } 1084 }
1097 1085
1098 /** 1086 /**
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 mHasInsertion = false; 2154 mHasInsertion = false;
2167 hidePastePopup(); 2155 hidePastePopup();
2168 break; 2156 break;
2169 2157
2170 default: 2158 default:
2171 assert false : "Invalid selection event type."; 2159 assert false : "Invalid selection event type.";
2172 } 2160 }
2173 } 2161 }
2174 2162
2175 public boolean getUseDesktopUserAgent() { 2163 public boolean getUseDesktopUserAgent() {
2176 if (mNativeContentViewCore != 0) { 2164 assert mWebContents != null;
2177 return nativeGetUseDesktopUserAgent(mNativeContentViewCore); 2165 return mWebContents.getNavigationController().getUseDesktopUserAgent();
2178 }
2179 return false;
2180 } 2166 }
2181 2167
2182 /** 2168 /**
2183 * Set whether or not we're using a desktop user agent for the currently loa ded page. 2169 * Set whether or not we're using a desktop user agent for the currently loa ded page.
2184 * @param override If true, use a desktop user agent. Use a mobile one othe rwise. 2170 * @param override If true, use a desktop user agent. Use a mobile one othe rwise.
2185 * @param reloadOnChange Reload the page if the UA has changed. 2171 * @param reloadOnChange Reload the page if the UA has changed.
2186 */ 2172 */
2187 public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange) { 2173 public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange) {
2188 if (mNativeContentViewCore != 0) { 2174 assert mWebContents != null;
2189 nativeSetUseDesktopUserAgent(mNativeContentViewCore, override, reloa dOnChange); 2175 mWebContents.getNavigationController().setUseDesktopUserAgent(override,
2190 } 2176 reloadOnChange);
2191 } 2177 }
2192 2178
2193 public void clearSslPreferences() { 2179 public void clearSslPreferences() {
2194 if (mNativeContentViewCore != 0) nativeClearSslPreferences(mNativeConten tViewCore); 2180 assert mWebContents != null;
2181 mWebContents.getNavigationController().clearSslPreferences();
2195 } 2182 }
2196 2183
2197 private void hideTextHandles() { 2184 private void hideTextHandles() {
2198 mHasSelection = false; 2185 mHasSelection = false;
2199 mHasInsertion = false; 2186 mHasInsertion = false;
2200 if (mNativeContentViewCore != 0) nativeHideTextHandles(mNativeContentVie wCore); 2187 if (mNativeContentViewCore != 0) nativeHideTextHandles(mNativeContentVie wCore);
2201 } 2188 }
2202 2189
2203 /** 2190 /**
2204 * Shows the IME if the focused widget could accept text input. 2191 * Shows the IME if the focused widget could accept text input.
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 * @param animate Whether the transition should be animated or not. 2903 * @param animate Whether the transition should be animated or not.
2917 */ 2904 */
2918 public void updateTopControlsState(boolean enableHiding, boolean enableShowi ng, 2905 public void updateTopControlsState(boolean enableHiding, boolean enableShowi ng,
2919 boolean animate) { 2906 boolean animate) {
2920 assert mWebContents != null; 2907 assert mWebContents != null;
2921 mWebContents.updateTopControlsState( 2908 mWebContents.updateTopControlsState(
2922 enableHiding, enableShowing, animate); 2909 enableHiding, enableShowing, animate);
2923 } 2910 }
2924 2911
2925 /** 2912 /**
2926 * Callback factory method for nativeGetNavigationHistory().
2927 */
2928 @CalledByNative
2929 private void addToNavigationHistory(Object history, int index, String url, S tring virtualUrl,
2930 String originalUrl, String title, Bitmap favicon) {
2931 NavigationEntry entry = new NavigationEntry(
2932 index, url, virtualUrl, originalUrl, title, favicon);
2933 ((NavigationHistory) history).addEntry(entry);
2934 }
2935
2936 /**
2937 * Get a copy of the navigation history of the view. 2913 * Get a copy of the navigation history of the view.
2938 */ 2914 */
2939 public NavigationHistory getNavigationHistory() { 2915 public NavigationHistory getNavigationHistory() {
2940 NavigationHistory history = new NavigationHistory(); 2916 assert mWebContents != null;
2941 if (mNativeContentViewCore != 0) { 2917 return mWebContents.getNavigationController().getNavigationHistory();
2942 int currentIndex = nativeGetNavigationHistory(mNativeContentViewCore , history);
2943 history.setCurrentEntryIndex(currentIndex);
2944 }
2945 return history;
2946 } 2918 }
2947 2919
2948 @Override 2920 @Override
Yaron 2014/07/23 18:58:38 Interesting. I think with the new NavigationContro
AKVT 2014/07/24 07:47:24 As suggested will take care in follow up patch.
2949 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) { 2921 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) {
2922 assert mWebContents != null;
2950 NavigationHistory history = new NavigationHistory(); 2923 NavigationHistory history = new NavigationHistory();
Yaron 2014/07/23 18:58:38 remove this.
AKVT 2014/07/24 07:47:24 Done.
2951 if (mNativeContentViewCore != 0) { 2924 mWebContents.getNavigationController().getDirectedNavigationHistory(
Yaron 2014/07/23 18:58:38 missing "return"
AKVT 2014/07/24 07:47:24 Thanks. Removed unnecessary local variable.
2952 nativeGetDirectedNavigationHistory( 2925 isForward, itemLimit);
2953 mNativeContentViewCore, history, isForward, itemLimit);
2954 }
2955 return history; 2926 return history;
2956 } 2927 }
2957 2928
2958 /** 2929 /**
2959 * @return The original request URL for the current navigation entry, or nul l if there is no 2930 * @return The original request URL for the current navigation entry, or nul l if there is no
2960 * current entry. 2931 * current entry.
2961 */ 2932 */
2962 public String getOriginalUrlForActiveNavigationEntry() { 2933 public String getOriginalUrlForActiveNavigationEntry() {
2963 if (mNativeContentViewCore != 0) { 2934 assert mWebContents != null;
2964 return nativeGetOriginalUrlForActiveNavigationEntry(mNativeContentVi ewCore); 2935 return mWebContents.getNavigationController().
2965 } 2936 getOriginalUrlForActiveNavigationEntry();
2966 return "";
2967 } 2937 }
2968 2938
2969 /** 2939 /**
2970 * @return The cached copy of render positions and scales. 2940 * @return The cached copy of render positions and scales.
2971 */ 2941 */
2972 public RenderCoordinates getRenderCoordinates() { 2942 public RenderCoordinates getRenderCoordinates() {
2973 return mRenderCoordinates; 2943 return mRenderCoordinates;
2974 } 2944 }
2975 2945
2976 @CalledByNative 2946 @CalledByNative
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3093 3063
3094 @CalledByNative 3064 @CalledByNative
3095 private boolean isFullscreenRequiredForOrientationLock() { 3065 private boolean isFullscreenRequiredForOrientationLock() {
3096 return mFullscreenRequiredForOrientationLock; 3066 return mFullscreenRequiredForOrientationLock;
3097 } 3067 }
3098 3068
3099 private native WebContents nativeGetWebContentsAndroid(long nativeContentVie wCoreImpl); 3069 private native WebContents nativeGetWebContentsAndroid(long nativeContentVie wCoreImpl);
3100 3070
3101 private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentV iewCoreImpl); 3071 private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentV iewCoreImpl);
3102 3072
3103 private native void nativeLoadUrl(
3104 long nativeContentViewCoreImpl,
3105 String url,
3106 int loadUrlType,
3107 int transitionType,
3108 String referrerUrl,
3109 int referrerPolicy,
3110 int uaOverrideOption,
3111 String extraHeaders,
3112 byte[] postData,
3113 String baseUrlForDataUrl,
3114 String virtualUrlForDataUrl,
3115 boolean canLoadLocalResources,
3116 boolean isRendererInitiated);
3117
3118 private native String nativeGetURL(long nativeContentViewCoreImpl); 3073 private native String nativeGetURL(long nativeContentViewCoreImpl);
3119 3074
3120 private native boolean nativeIsIncognito(long nativeContentViewCoreImpl); 3075 private native boolean nativeIsIncognito(long nativeContentViewCoreImpl);
3121 3076
3122 private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean f ocused); 3077 private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean f ocused);
3123 3078
3124 private native void nativeSendOrientationChangeEvent( 3079 private native void nativeSendOrientationChangeEvent(
3125 long nativeContentViewCoreImpl, int orientation); 3080 long nativeContentViewCoreImpl, int orientation);
3126 3081
3127 // All touch events (including flings, scrolls etc) accept coordinates in ph ysical pixels. 3082 // All touch events (including flings, scrolls etc) accept coordinates in ph ysical pixels.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3181 private native void nativeHideTextHandles(long nativeContentViewCoreImpl); 3136 private native void nativeHideTextHandles(long nativeContentViewCoreImpl);
3182 3137
3183 private native void nativeResetGestureDetection(long nativeContentViewCoreIm pl); 3138 private native void nativeResetGestureDetection(long nativeContentViewCoreIm pl);
3184 private native void nativeSetDoubleTapSupportEnabled( 3139 private native void nativeSetDoubleTapSupportEnabled(
3185 long nativeContentViewCoreImpl, boolean enabled); 3140 long nativeContentViewCoreImpl, boolean enabled);
3186 private native void nativeSetMultiTouchZoomSupportEnabled( 3141 private native void nativeSetMultiTouchZoomSupportEnabled(
3187 long nativeContentViewCoreImpl, boolean enabled); 3142 long nativeContentViewCoreImpl, boolean enabled);
3188 3143
3189 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp l, int[] indices); 3144 private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImp l, int[] indices);
3190 3145
3191 private native void nativeClearHistory(long nativeContentViewCoreImpl);
3192
3193 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl, 3146 private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl,
3194 String script, JavaScriptCallback callback, boolean startRenderer); 3147 String script, JavaScriptCallback callback, boolean startRenderer);
3195 3148
3196 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl, String frameId, 3149 private native void nativePostMessageToFrame(long nativeContentViewCoreImpl, String frameId,
3197 String message, String sourceOrigin, String targetOrigin); 3150 String message, String sourceOrigin, String targetOrigin);
3198 3151
3199 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl ); 3152 private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl );
3200 3153
3201 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor eImpl); 3154 private native int nativeGetCurrentRenderProcessId(long nativeContentViewCor eImpl);
3202 3155
3203 private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreI mpl,
3204 boolean enabled, boolean reloadOnChange);
3205 private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCo reImpl);
3206
3207 private native void nativeClearSslPreferences(long nativeContentViewCoreImpl );
3208
3209 private native void nativeSetAllowJavascriptInterfacesInspection( 3156 private native void nativeSetAllowJavascriptInterfacesInspection(
3210 long nativeContentViewCoreImpl, boolean allow); 3157 long nativeContentViewCoreImpl, boolean allow);
3211 3158
3212 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI mpl, Object object, 3159 private native void nativeAddJavascriptInterface(long nativeContentViewCoreI mpl, Object object,
3213 String name, Class requiredAnnotation); 3160 String name, Class requiredAnnotation);
3214 3161
3215 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo reImpl, 3162 private native void nativeRemoveJavascriptInterface(long nativeContentViewCo reImpl,
3216 String name); 3163 String name);
3217 3164
3218 private native int nativeGetNavigationHistory(long nativeContentViewCoreImpl , Object context);
3219 private native void nativeGetDirectedNavigationHistory(long nativeContentVie wCoreImpl,
3220 Object context, boolean isForward, int maxEntries);
3221 private native String nativeGetOriginalUrlForActiveNavigationEntry(
3222 long nativeContentViewCoreImpl);
3223
3224 private native void nativeWasResized(long nativeContentViewCoreImpl); 3165 private native void nativeWasResized(long nativeContentViewCoreImpl);
3225 3166
3226 private native void nativeSetAccessibilityEnabled( 3167 private native void nativeSetAccessibilityEnabled(
3227 long nativeContentViewCoreImpl, boolean enabled); 3168 long nativeContentViewCoreImpl, boolean enabled);
3228 3169
3229 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, 3170 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l,
3230 int x, int y, int w, int h); 3171 int x, int y, int w, int h);
3231 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); 3172 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque);
3232 3173
3233 private native void nativeResumeResponseDeferredAtStart( 3174 private native void nativeResumeResponseDeferredAtStart(
3234 long nativeContentViewCoreImpl); 3175 long nativeContentViewCoreImpl);
3235 private native void nativeSetHasPendingNavigationTransitionForTesting( 3176 private native void nativeSetHasPendingNavigationTransitionForTesting(
3236 long nativeContentViewCoreImpl); 3177 long nativeContentViewCoreImpl);
3237 } 3178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698