| OLD | NEW |
| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * An interface that allows the embedder to be notified when the results of | 209 * An interface that allows the embedder to be notified when the results of |
| 210 * extractSmartClipData are available. | 210 * extractSmartClipData are available. |
| 211 */ | 211 */ |
| 212 public interface SmartClipDataListener { | 212 public interface SmartClipDataListener { |
| 213 public void onSmartClipDataExtracted(String result); | 213 public void onSmartClipDataExtracted(String result); |
| 214 } | 214 } |
| 215 | 215 |
| 216 /** |
| 217 * An interface that allows the embedder to be notified of navigation transi
tion |
| 218 * related events and respond to them. |
| 219 */ |
| 220 public interface NavigationTransitionDelegate { |
| 221 /** |
| 222 * Called when the navigation is deferred immediately after the response
started. |
| 223 */ |
| 224 public void didDeferAfterResponseStarted(); |
| 225 |
| 226 /** |
| 227 * Called when a navigation transition has been detected, and we need to
check |
| 228 * if it's supported. |
| 229 */ |
| 230 public boolean willHandleDeferAfterResponseStarted(); |
| 231 } |
| 232 |
| 216 private final Context mContext; | 233 private final Context mContext; |
| 217 private ViewGroup mContainerView; | 234 private ViewGroup mContainerView; |
| 218 private InternalAccessDelegate mContainerViewInternals; | 235 private InternalAccessDelegate mContainerViewInternals; |
| 219 private WebContents mWebContents; | 236 private WebContents mWebContents; |
| 220 private WebContentsObserverAndroid mWebContentsObserver; | 237 private WebContentsObserverAndroid mWebContentsObserver; |
| 221 | 238 |
| 222 private ContentViewClient mContentViewClient; | 239 private ContentViewClient mContentViewClient; |
| 223 | 240 |
| 224 private ContentSettings mContentSettings; | 241 private ContentSettings mContentSettings; |
| 225 | 242 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 private boolean mTouchScrollInProgress; | 328 private boolean mTouchScrollInProgress; |
| 312 | 329 |
| 313 // The outstanding fling start events that hasn't got fling end yet. It may
be > 1 because | 330 // The outstanding fling start events that hasn't got fling end yet. It may
be > 1 because |
| 314 // onNativeFlingStopped() is called asynchronously. | 331 // onNativeFlingStopped() is called asynchronously. |
| 315 private int mPotentiallyActiveFlingCount; | 332 private int mPotentiallyActiveFlingCount; |
| 316 | 333 |
| 317 private ViewAndroid mViewAndroid; | 334 private ViewAndroid mViewAndroid; |
| 318 | 335 |
| 319 private SmartClipDataListener mSmartClipDataListener = null; | 336 private SmartClipDataListener mSmartClipDataListener = null; |
| 320 | 337 |
| 338 private NavigationTransitionDelegate mNavigationTransitionDelegate = null; |
| 339 |
| 321 // This holds the state of editable text (e.g. contents of <input>, contente
ditable) of | 340 // This holds the state of editable text (e.g. contents of <input>, contente
ditable) of |
| 322 // a focused element. | 341 // a focused element. |
| 323 // Every time the user, IME, javascript (Blink), autofill etc. modifies the
content, the new | 342 // Every time the user, IME, javascript (Blink), autofill etc. modifies the
content, the new |
| 324 // state must be reflected to this to keep consistency. | 343 // state must be reflected to this to keep consistency. |
| 325 private final Editable mEditable; | 344 private final Editable mEditable; |
| 326 | 345 |
| 327 /** | 346 /** |
| 328 * PID used to indicate an invalid render process. | 347 * PID used to indicate an invalid render process. |
| 329 */ | 348 */ |
| 330 // Keep in sync with the value returned from ContentViewCoreImpl::GetCurrent
RendererProcessId() | 349 // Keep in sync with the value returned from ContentViewCoreImpl::GetCurrent
RendererProcessId() |
| (...skipping 2682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3013 public void setSmartClipDataListener(SmartClipDataListener listener) { | 3032 public void setSmartClipDataListener(SmartClipDataListener listener) { |
| 3014 mSmartClipDataListener = listener; | 3033 mSmartClipDataListener = listener; |
| 3015 } | 3034 } |
| 3016 | 3035 |
| 3017 public void setBackgroundOpaque(boolean opaque) { | 3036 public void setBackgroundOpaque(boolean opaque) { |
| 3018 if (mNativeContentViewCore != 0) { | 3037 if (mNativeContentViewCore != 0) { |
| 3019 nativeSetBackgroundOpaque(mNativeContentViewCore, opaque); | 3038 nativeSetBackgroundOpaque(mNativeContentViewCore, opaque); |
| 3020 } | 3039 } |
| 3021 } | 3040 } |
| 3022 | 3041 |
| 3042 @CalledByNative |
| 3043 private void didDeferAfterResponseStarted() { |
| 3044 if (mNavigationTransitionDelegate != null ) { |
| 3045 mNavigationTransitionDelegate.didDeferAfterResponseStarted(); |
| 3046 } |
| 3047 } |
| 3048 |
| 3049 @CalledByNative |
| 3050 private boolean willHandleDeferAfterResponseStarted() { |
| 3051 if (mNavigationTransitionDelegate == null) return false; |
| 3052 return mNavigationTransitionDelegate.willHandleDeferAfterResponseStarted
(); |
| 3053 } |
| 3054 |
| 3055 @VisibleForTesting |
| 3056 void setHasPendingNavigationTransitionForTesting() { |
| 3057 if (mNativeContentViewCore == 0) return; |
| 3058 nativeSetHasPendingNavigationTransitionForTesting(mNativeContentViewCore
); |
| 3059 } |
| 3060 |
| 3061 public void setNavigationTransitionDelegate(NavigationTransitionDelegate del
egate) { |
| 3062 mNavigationTransitionDelegate = delegate; |
| 3063 } |
| 3064 |
| 3023 /** | 3065 /** |
| 3024 * Offer a long press gesture to the embedding View, primarily for WebView c
ompatibility. | 3066 * Offer a long press gesture to the embedding View, primarily for WebView c
ompatibility. |
| 3025 * | 3067 * |
| 3026 * @return true if the embedder handled the event. | 3068 * @return true if the embedder handled the event. |
| 3027 */ | 3069 */ |
| 3028 private boolean offerLongPressToEmbedder() { | 3070 private boolean offerLongPressToEmbedder() { |
| 3029 return mContainerView.performLongClick(); | 3071 return mContainerView.performLongClick(); |
| 3030 } | 3072 } |
| 3031 | 3073 |
| 3032 /** | 3074 /** |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3067 if (mPotentiallyActiveFlingCount <= 0) return; | 3109 if (mPotentiallyActiveFlingCount <= 0) return; |
| 3068 mPotentiallyActiveFlingCount--; | 3110 mPotentiallyActiveFlingCount--; |
| 3069 updateGestureStateListener(GestureEventType.FLING_END); | 3111 updateGestureStateListener(GestureEventType.FLING_END); |
| 3070 } | 3112 } |
| 3071 | 3113 |
| 3072 @Override | 3114 @Override |
| 3073 public void onScreenOrientationChanged(int orientation) { | 3115 public void onScreenOrientationChanged(int orientation) { |
| 3074 sendOrientationChangeEvent(orientation); | 3116 sendOrientationChangeEvent(orientation); |
| 3075 } | 3117 } |
| 3076 | 3118 |
| 3119 public void resumeResponseDeferredAtStart() { |
| 3120 if (mNativeContentViewCore == 0) return; |
| 3121 nativeResumeResponseDeferredAtStart(mNativeContentViewCore); |
| 3122 } |
| 3123 |
| 3077 private native WebContents nativeGetWebContentsAndroid(long nativeContentVie
wCoreImpl); | 3124 private native WebContents nativeGetWebContentsAndroid(long nativeContentVie
wCoreImpl); |
| 3078 | 3125 |
| 3079 private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentV
iewCoreImpl); | 3126 private native void nativeOnJavaContentViewCoreDestroyed(long nativeContentV
iewCoreImpl); |
| 3080 | 3127 |
| 3081 private native void nativeLoadUrl( | 3128 private native void nativeLoadUrl( |
| 3082 long nativeContentViewCoreImpl, | 3129 long nativeContentViewCoreImpl, |
| 3083 String url, | 3130 String url, |
| 3084 int loadUrlType, | 3131 int loadUrlType, |
| 3085 int transitionType, | 3132 int transitionType, |
| 3086 String referrerUrl, | 3133 String referrerUrl, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3228 boolean enableHiding, boolean enableShowing, boolean animate); | 3275 boolean enableHiding, boolean enableShowing, boolean animate); |
| 3229 | 3276 |
| 3230 private native void nativeShowImeIfNeeded(long nativeContentViewCoreImpl); | 3277 private native void nativeShowImeIfNeeded(long nativeContentViewCoreImpl); |
| 3231 | 3278 |
| 3232 private native void nativeSetAccessibilityEnabled( | 3279 private native void nativeSetAccessibilityEnabled( |
| 3233 long nativeContentViewCoreImpl, boolean enabled); | 3280 long nativeContentViewCoreImpl, boolean enabled); |
| 3234 | 3281 |
| 3235 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, | 3282 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, |
| 3236 int x, int y, int w, int h); | 3283 int x, int y, int w, int h); |
| 3237 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); | 3284 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); |
| 3285 |
| 3286 private native void nativeResumeResponseDeferredAtStart( |
| 3287 long nativeContentViewCoreImpl); |
| 3288 private native void nativeSetHasPendingNavigationTransitionForTesting( |
| 3289 long nativeContentViewCoreImpl); |
| 3238 } | 3290 } |
| OLD | NEW |