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.app.Activity; | 8 import android.app.Activity; |
9 import android.content.ComponentCallbacks2; | 9 import android.content.ComponentCallbacks2; |
10 import android.content.Context; | 10 import android.content.Context; |
11 import android.content.res.Configuration; | 11 import android.content.res.Configuration; |
12 import android.graphics.Bitmap; | 12 import android.graphics.Bitmap; |
13 import android.graphics.Canvas; | 13 import android.graphics.Canvas; |
14 import android.graphics.Color; | 14 import android.graphics.Color; |
15 import android.graphics.Paint; | 15 import android.graphics.Paint; |
16 import android.graphics.Picture; | 16 import android.graphics.Picture; |
17 import android.graphics.Rect; | 17 import android.graphics.Rect; |
18 import android.net.Uri; | 18 import android.net.Uri; |
19 import android.net.http.SslCertificate; | 19 import android.net.http.SslCertificate; |
20 import android.os.AsyncTask; | 20 import android.os.AsyncTask; |
21 import android.os.Build; | 21 import android.os.Build; |
22 import android.os.Bundle; | 22 import android.os.Bundle; |
23 import android.os.Message; | 23 import android.os.Message; |
24 import android.text.TextUtils; | 24 import android.text.TextUtils; |
25 import android.util.Log; | 25 import android.util.Log; |
| 26 import android.util.Pair; |
26 import android.view.KeyEvent; | 27 import android.view.KeyEvent; |
27 import android.view.MotionEvent; | 28 import android.view.MotionEvent; |
28 import android.view.View; | 29 import android.view.View; |
29 import android.view.ViewGroup; | 30 import android.view.ViewGroup; |
30 import android.view.accessibility.AccessibilityEvent; | 31 import android.view.accessibility.AccessibilityEvent; |
31 import android.view.accessibility.AccessibilityNodeInfo; | 32 import android.view.accessibility.AccessibilityNodeInfo; |
32 import android.view.accessibility.AccessibilityNodeProvider; | 33 import android.view.accessibility.AccessibilityNodeProvider; |
33 import android.view.inputmethod.EditorInfo; | 34 import android.view.inputmethod.EditorInfo; |
34 import android.view.inputmethod.InputConnection; | 35 import android.view.inputmethod.InputConnection; |
35 import android.webkit.GeolocationPermissions; | 36 import android.webkit.GeolocationPermissions; |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 final boolean wasWindowFocused = mWindowFocused; | 798 final boolean wasWindowFocused = mWindowFocused; |
798 | 799 |
799 // Properly clean up existing mContentViewCore and mNativeAwContents. | 800 // Properly clean up existing mContentViewCore and mNativeAwContents. |
800 if (wasFocused) onFocusChanged(false, 0, null); | 801 if (wasFocused) onFocusChanged(false, 0, null); |
801 if (wasWindowFocused) onWindowFocusChanged(false); | 802 if (wasWindowFocused) onWindowFocusChanged(false); |
802 if (wasViewVisible) setViewVisibilityInternal(false); | 803 if (wasViewVisible) setViewVisibilityInternal(false); |
803 if (wasWindowVisible) setWindowVisibilityInternal(false); | 804 if (wasWindowVisible) setWindowVisibilityInternal(false); |
804 if (wasAttached) onDetachedFromWindow(); | 805 if (wasAttached) onDetachedFromWindow(); |
805 if (!wasPaused) onPause(); | 806 if (!wasPaused) onPause(); |
806 | 807 |
| 808 // Save injected JavaScript interfaces. |
| 809 Map<String, Pair<Object, Class>> javascriptInterfaces = |
| 810 new HashMap<String, Pair<Object, Class>>(); |
| 811 if (mContentViewCore != null) { |
| 812 javascriptInterfaces.putAll(mContentViewCore.getJavascriptInterfaces
()); |
| 813 } |
| 814 |
807 setNewAwContents(popupNativeAwContents); | 815 setNewAwContents(popupNativeAwContents); |
808 | 816 |
809 // Finally refresh all view state for mContentViewCore and mNativeAwCont
ents. | 817 // Finally refresh all view state for mContentViewCore and mNativeAwCont
ents. |
810 if (!wasPaused) onResume(); | 818 if (!wasPaused) onResume(); |
811 if (wasAttached) { | 819 if (wasAttached) { |
812 onAttachedToWindow(); | 820 onAttachedToWindow(); |
813 postInvalidateOnAnimation(); | 821 postInvalidateOnAnimation(); |
814 } | 822 } |
815 onSizeChanged(mContainerView.getWidth(), mContainerView.getHeight(), 0,
0); | 823 onSizeChanged(mContainerView.getWidth(), mContainerView.getHeight(), 0,
0); |
816 if (wasWindowVisible) setWindowVisibilityInternal(true); | 824 if (wasWindowVisible) setWindowVisibilityInternal(true); |
817 if (wasViewVisible) setViewVisibilityInternal(true); | 825 if (wasViewVisible) setViewVisibilityInternal(true); |
818 if (wasWindowFocused) onWindowFocusChanged(wasWindowFocused); | 826 if (wasWindowFocused) onWindowFocusChanged(wasWindowFocused); |
819 if (wasFocused) onFocusChanged(true, 0, null); | 827 if (wasFocused) onFocusChanged(true, 0, null); |
| 828 |
| 829 // Restore injected JavaScript interfaces. |
| 830 for (Map.Entry<String, Pair<Object, Class>> entry : javascriptInterfaces
.entrySet()) { |
| 831 mContentViewCore.addPossiblyUnsafeJavascriptInterface( |
| 832 entry.getValue().first, |
| 833 entry.getKey(), |
| 834 entry.getValue().second); |
| 835 } |
820 } | 836 } |
821 | 837 |
822 /** | 838 /** |
823 * Deletes the native counterpart of this object. | 839 * Deletes the native counterpart of this object. |
824 */ | 840 */ |
825 public void destroy() { | 841 public void destroy() { |
826 if (mCleanupReference != null) { | 842 if (mCleanupReference != null) { |
827 assert mNativeAwContents != 0; | 843 assert mNativeAwContents != 0; |
828 // If we are attached, we have to call native detach to clean up | 844 // If we are attached, we have to call native detach to clean up |
829 // hardware resources. | 845 // hardware resources. |
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 | 2480 |
2465 private native void nativeSetJsOnlineProperty(long nativeAwContents, boolean
networkUp); | 2481 private native void nativeSetJsOnlineProperty(long nativeAwContents, boolean
networkUp); |
2466 | 2482 |
2467 private native void nativeTrimMemory(long nativeAwContents, int level, boole
an visible); | 2483 private native void nativeTrimMemory(long nativeAwContents, int level, boole
an visible); |
2468 | 2484 |
2469 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo
rter awPdfExporter); | 2485 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo
rter awPdfExporter); |
2470 | 2486 |
2471 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, | 2487 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, |
2472 long resources); | 2488 long resources); |
2473 } | 2489 } |
OLD | NEW |