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.android_webview; | 5 package org.chromium.android_webview; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
9 import android.app.Activity; | 9 import android.app.Activity; |
10 import android.content.ComponentCallbacks2; | 10 import android.content.ComponentCallbacks2; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 import org.chromium.base.Log; | 52 import org.chromium.base.Log; |
53 import org.chromium.base.ObserverList; | 53 import org.chromium.base.ObserverList; |
54 import org.chromium.base.ThreadUtils; | 54 import org.chromium.base.ThreadUtils; |
55 import org.chromium.base.TraceEvent; | 55 import org.chromium.base.TraceEvent; |
56 import org.chromium.base.VisibleForTesting; | 56 import org.chromium.base.VisibleForTesting; |
57 import org.chromium.base.annotations.CalledByNative; | 57 import org.chromium.base.annotations.CalledByNative; |
58 import org.chromium.base.annotations.JNINamespace; | 58 import org.chromium.base.annotations.JNINamespace; |
59 import org.chromium.base.annotations.SuppressFBWarnings; | 59 import org.chromium.base.annotations.SuppressFBWarnings; |
60 import org.chromium.components.navigation_interception.InterceptNavigationDelega te; | 60 import org.chromium.components.navigation_interception.InterceptNavigationDelega te; |
61 import org.chromium.components.navigation_interception.NavigationParams; | 61 import org.chromium.components.navigation_interception.NavigationParams; |
62 import org.chromium.components.safe_browsing.ErrorUiType; | |
62 import org.chromium.content.browser.AppWebMessagePort; | 63 import org.chromium.content.browser.AppWebMessagePort; |
63 import org.chromium.content.browser.ContentViewCore; | 64 import org.chromium.content.browser.ContentViewCore; |
64 import org.chromium.content.browser.ContentViewStatics; | 65 import org.chromium.content.browser.ContentViewStatics; |
65 import org.chromium.content.browser.SmartClipProvider; | 66 import org.chromium.content.browser.SmartClipProvider; |
66 import org.chromium.content_public.browser.GestureStateListener; | 67 import org.chromium.content_public.browser.GestureStateListener; |
67 import org.chromium.content_public.browser.JavaScriptCallback; | 68 import org.chromium.content_public.browser.JavaScriptCallback; |
68 import org.chromium.content_public.browser.LoadUrlParams; | 69 import org.chromium.content_public.browser.LoadUrlParams; |
69 import org.chromium.content_public.browser.MessagePort; | 70 import org.chromium.content_public.browser.MessagePort; |
70 import org.chromium.content_public.browser.NavigationController; | 71 import org.chromium.content_public.browser.NavigationController; |
71 import org.chromium.content_public.browser.NavigationHistory; | 72 import org.chromium.content_public.browser.NavigationHistory; |
(...skipping 2866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2938 } | 2939 } |
2939 return false; | 2940 return false; |
2940 } | 2941 } |
2941 | 2942 |
2942 /** | 2943 /** |
2943 * Determine if it's reasonable to show any sort of interstitial. If the Web View is not visible, | 2944 * Determine if it's reasonable to show any sort of interstitial. If the Web View is not visible, |
2944 * the user may not be able to interact with the UI. | 2945 * the user may not be able to interact with the UI. |
2945 * @return true if the WebView is visible | 2946 * @return true if the WebView is visible |
2946 */ | 2947 */ |
2947 @VisibleForTesting | 2948 @VisibleForTesting |
2949 @CalledByNative | |
2948 protected boolean canShowInterstitial() { | 2950 protected boolean canShowInterstitial() { |
2949 return mIsAttachedToWindow && mIsViewVisible; | 2951 return mIsAttachedToWindow && mIsViewVisible; |
2950 } | 2952 } |
2951 | 2953 |
2954 @CalledByNative | |
2955 private int getErrorUiType() { | |
2956 if (canShowBigInterstitial()) { | |
2957 return ErrorUiType.LOUD; | |
2958 } else if (extendsOutOfWindow()) { | |
2959 return ErrorUiType.QUIET_GIANT; | |
2960 } else { | |
2961 return ErrorUiType.QUIET_SMALL; | |
2962 } | |
2963 } | |
2964 | |
2952 /** | 2965 /** |
2953 * Determine if it's suitable to show the interstitial for browsers and main UIs. If the WebView | 2966 * Determine if it's suitable to show the interstitial for browsers and main UIs. If the WebView |
2954 * is close to full-screen, we assume the app is using it as the main UI, so we show the same | 2967 * is close to full-screen, we assume the app is using it as the main UI, so we show the same |
2955 * interstital Chrome uses. Otherwise, we assume the WebView is part of a la rger composed page, | 2968 * interstital Chrome uses. Otherwise, we assume the WebView is part of a la rger composed page, |
2956 * and will show a different interstitial. | 2969 * and will show a different interstitial. |
2957 * @return true if the WebView should display the large interstitial | 2970 * @return true if the WebView should display the large interstitial |
2958 */ | 2971 */ |
2959 @VisibleForTesting | 2972 @VisibleForTesting |
2960 @CalledByNative | |
2961 protected boolean canShowBigInterstitial() { | 2973 protected boolean canShowBigInterstitial() { |
2962 if (!canShowInterstitial()) return false; | 2974 if (!canShowInterstitial()) return false; |
sgurun-gerrit only
2017/05/23 17:09:15
I don't think this check is necessary. the caller
Nate Fischer
2017/05/23 20:01:06
I don't think we can add DCHECKs in Java, so I jus
sgurun-gerrit only
2017/05/23 20:19:23
just drop, no need.
Nate Fischer
2017/05/23 20:21:19
Ok, SGTM. That's what I did in PS#9
| |
2963 if (extendsOutOfWindow()) return false; | 2975 if (extendsOutOfWindow()) return false; |
sgurun-gerrit only
2017/05/23 17:09:15
same as above.
Nate Fischer
2017/05/23 20:01:06
Done.
| |
2964 | 2976 |
2965 double percentOfScreenHeight = | 2977 double percentOfScreenHeight = |
2966 (double) mContainerView.getHeight() / mContainerView.getRootView ().getHeight(); | 2978 (double) mContainerView.getHeight() / mContainerView.getRootView ().getHeight(); |
2967 | 2979 |
2968 // Make a guess as to whether the WebView is the predominant part of the UI | 2980 // Make a guess as to whether the WebView is the predominant part of the UI |
2969 return mContainerView.getWidth() == mContainerView.getRootView().getWidt h() | 2981 return mContainerView.getWidth() == mContainerView.getRootView().getWidt h() |
2970 && percentOfScreenHeight >= MIN_SCREEN_HEIGHT_PERCENTAGE_FOR_INT ERSTITIAL; | 2982 && percentOfScreenHeight >= MIN_SCREEN_HEIGHT_PERCENTAGE_FOR_INT ERSTITIAL; |
2971 } | 2983 } |
2972 | 2984 |
2973 @VisibleForTesting | 2985 @VisibleForTesting |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3519 private native void nativeTrimMemory(long nativeAwContents, int level, boole an visible); | 3531 private native void nativeTrimMemory(long nativeAwContents, int level, boole an visible); |
3520 | 3532 |
3521 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter); | 3533 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter); |
3522 | 3534 |
3523 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, | 3535 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, |
3524 long resources); | 3536 long resources); |
3525 | 3537 |
3526 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC ontents); | 3538 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC ontents); |
3527 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw Contents); | 3539 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw Contents); |
3528 } | 3540 } |
OLD | NEW |