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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 2898593002: WebView: choose loud vs. quiet interstitial (Closed)
Patch Set: Rebase and fix patch conflict Created 3 years, 7 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.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 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 (float) Math.hypot(velocityX, velocityY)); 2910 (float) Math.hypot(velocityX, velocityY));
2911 2911
2912 if (mOverScrollGlow.isAnimating()) { 2912 if (mOverScrollGlow.isAnimating()) {
2913 postInvalidateOnAnimation(); 2913 postInvalidateOnAnimation();
2914 } 2914 }
2915 } 2915 }
2916 2916
2917 /** 2917 /**
2918 * Determine if at least one edge of the WebView extends over the edge of th e window. 2918 * Determine if at least one edge of the WebView extends over the edge of th e window.
2919 */ 2919 */
2920 @CalledByNative
2920 private boolean extendsOutOfWindow() { 2921 private boolean extendsOutOfWindow() {
2921 int loc[] = new int[2]; 2922 int loc[] = new int[2];
2922 mContainerView.getLocationOnScreen(loc); 2923 mContainerView.getLocationOnScreen(loc);
2923 int x = loc[0]; 2924 int x = loc[0];
2924 int y = loc[1]; 2925 int y = loc[1];
2925 mContainerView.getRootView().getLocationOnScreen(loc); 2926 mContainerView.getRootView().getLocationOnScreen(loc);
2926 int rootX = loc[0]; 2927 int rootX = loc[0];
2927 int rootY = loc[1]; 2928 int rootY = loc[1];
2928 2929
2929 // Get the position of the current view, relative to its root view 2930 // Get the position of the current view, relative to its root view
2930 int relativeX = x - rootX; 2931 int relativeX = x - rootX;
2931 int relativeY = y - rootY; 2932 int relativeY = y - rootY;
2932 2933
2933 if (relativeX < 0 || relativeY < 0 2934 if (relativeX < 0 || relativeY < 0
2934 || relativeX + mContainerView.getWidth() > mContainerView.getRoo tView().getWidth() 2935 || relativeX + mContainerView.getWidth() > mContainerView.getRoo tView().getWidth()
2935 || relativeY + mContainerView.getHeight() 2936 || relativeY + mContainerView.getHeight()
2936 > mContainerView.getRootView().getHeight()) { 2937 > mContainerView.getRootView().getHeight()) {
2937 return true; 2938 return true;
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
2952 /** 2954 /**
2953 * Determine if it's suitable to show the interstitial for browsers and main UIs. If the WebView 2955 * 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 2956 * 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, 2957 * interstital Chrome uses. Otherwise, we assume the WebView is part of a la rger composed page,
2956 * and will show a different interstitial. 2958 * and will show a different interstitial.
2957 * @return true if the WebView should display the large interstitial 2959 * @return true if the WebView should display the large interstitial
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
3519 private native void nativeTrimMemory(long nativeAwContents, int level, boole an visible); 3521 private native void nativeTrimMemory(long nativeAwContents, int level, boole an visible);
3520 3522
3521 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter); 3523 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter);
3522 3524
3523 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, 3525 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin,
3524 long resources); 3526 long resources);
3525 3527
3526 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC ontents); 3528 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC ontents);
3527 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw Contents); 3529 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw Contents);
3528 } 3530 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698