| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 import org.chromium.content.browser.AppWebMessagePort; | 59 import org.chromium.content.browser.AppWebMessagePort; |
| 60 import org.chromium.content.browser.AppWebMessagePortService; | 60 import org.chromium.content.browser.AppWebMessagePortService; |
| 61 import org.chromium.content.browser.ContentViewClient; | 61 import org.chromium.content.browser.ContentViewClient; |
| 62 import org.chromium.content.browser.ContentViewCore; | 62 import org.chromium.content.browser.ContentViewCore; |
| 63 import org.chromium.content.browser.ContentViewStatics; | 63 import org.chromium.content.browser.ContentViewStatics; |
| 64 import org.chromium.content.browser.PostMessageSender; | 64 import org.chromium.content.browser.PostMessageSender; |
| 65 import org.chromium.content.browser.SmartClipProvider; | 65 import org.chromium.content.browser.SmartClipProvider; |
| 66 import org.chromium.content_public.browser.GestureStateListener; | 66 import org.chromium.content_public.browser.GestureStateListener; |
| 67 import org.chromium.content_public.browser.JavaScriptCallback; | 67 import org.chromium.content_public.browser.JavaScriptCallback; |
| 68 import org.chromium.content_public.browser.LoadUrlParams; | 68 import org.chromium.content_public.browser.LoadUrlParams; |
| 69 import org.chromium.content_public.browser.MessagePort; | |
| 70 import org.chromium.content_public.browser.NavigationController; | 69 import org.chromium.content_public.browser.NavigationController; |
| 71 import org.chromium.content_public.browser.NavigationHistory; | 70 import org.chromium.content_public.browser.NavigationHistory; |
| 72 import org.chromium.content_public.browser.WebContents; | 71 import org.chromium.content_public.browser.WebContents; |
| 73 import org.chromium.content_public.browser.navigation_controller.LoadURLType; | 72 import org.chromium.content_public.browser.navigation_controller.LoadURLType; |
| 74 import org.chromium.content_public.browser.navigation_controller.UserAgentOverri
deOption; | 73 import org.chromium.content_public.browser.navigation_controller.UserAgentOverri
deOption; |
| 75 import org.chromium.content_public.common.Referrer; | 74 import org.chromium.content_public.common.Referrer; |
| 76 import org.chromium.net.NetError; | 75 import org.chromium.net.NetError; |
| 77 import org.chromium.net.NetworkChangeNotifier; | 76 import org.chromium.net.NetworkChangeNotifier; |
| 78 import org.chromium.ui.base.ActivityWindowAndroid; | 77 import org.chromium.ui.base.ActivityWindowAndroid; |
| 79 import org.chromium.ui.base.PageTransition; | 78 import org.chromium.ui.base.PageTransition; |
| 80 import org.chromium.ui.base.ViewAndroidDelegate; | 79 import org.chromium.ui.base.ViewAndroidDelegate; |
| 81 import org.chromium.ui.base.WindowAndroid; | 80 import org.chromium.ui.base.WindowAndroid; |
| 82 | 81 |
| 83 import java.io.File; | 82 import java.io.File; |
| 84 import java.lang.annotation.Annotation; | 83 import java.lang.annotation.Annotation; |
| 85 import java.net.MalformedURLException; | 84 import java.net.MalformedURLException; |
| 86 import java.net.URL; | 85 import java.net.URL; |
| 87 import java.util.HashMap; | 86 import java.util.HashMap; |
| 88 import java.util.Locale; | 87 import java.util.Locale; |
| 89 import java.util.Map; | 88 import java.util.Map; |
| 89 import java.util.Map.Entry; |
| 90 import java.util.WeakHashMap; | 90 import java.util.WeakHashMap; |
| 91 import java.util.concurrent.Callable; | 91 import java.util.concurrent.Callable; |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * Exposes the native AwContents class, and together these classes wrap the Cont
entViewCore | 94 * Exposes the native AwContents class, and together these classes wrap the Cont
entViewCore |
| 95 * and Browser components that are required to implement Android WebView API. Th
is is the | 95 * and Browser components that are required to implement Android WebView API. Th
is is the |
| 96 * primary entry point for the WebViewProvider implementation; it holds a 1:1 ob
ject | 96 * primary entry point for the WebViewProvider implementation; it holds a 1:1 ob
ject |
| 97 * relationship with application WebView instances. | 97 * relationship with application WebView instances. |
| 98 * (We define this class independent of the hidden WebViewProvider interfaces, t
o allow | 98 * (We define this class independent of the hidden WebViewProvider interfaces, t
o allow |
| 99 * continuous build & test in the open source SDK-based tree). | 99 * continuous build & test in the open source SDK-based tree). |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 nativeTrimMemory(mNativeAwContents, level, visible); | 698 nativeTrimMemory(mNativeAwContents, level, visible); |
| 699 } | 699 } |
| 700 }); | 700 }); |
| 701 } | 701 } |
| 702 | 702 |
| 703 @Override | 703 @Override |
| 704 public void onLowMemory() {} | 704 public void onLowMemory() {} |
| 705 | 705 |
| 706 @Override | 706 @Override |
| 707 public void onConfigurationChanged(Configuration configuration) { | 707 public void onConfigurationChanged(Configuration configuration) { |
| 708 setLocale(LocaleUtils.getLocale(configuration.locale)); | 708 setLocale(LocaleUtils.getLocaleString(configuration.locale)); |
| 709 mSettings.updateAcceptLanguages(); | 709 mSettings.updateAcceptLanguages(); |
| 710 } | 710 } |
| 711 }; | 711 }; |
| 712 | 712 |
| 713 //--------------------------------------------------------------------------
------------------ | 713 //--------------------------------------------------------------------------
------------------ |
| 714 /** | 714 /** |
| 715 * @param browserContext the browsing context to associate this view content
s with. | 715 * @param browserContext the browsing context to associate this view content
s with. |
| 716 * @param containerView the view-hierarchy item this object will be bound to
. | 716 * @param containerView the view-hierarchy item this object will be bound to
. |
| 717 * @param context the context to use, usually containerView.getContext(). | 717 * @param context the context to use, usually containerView.getContext(). |
| 718 * @param internalAccessAdapter to access private methods on containerView. | 718 * @param internalAccessAdapter to access private methods on containerView. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 734 * @param dependencyFactory an instance of the DependencyFactory used to pro
vide instances of | 734 * @param dependencyFactory an instance of the DependencyFactory used to pro
vide instances of |
| 735 * classes that this class depends on. | 735 * classes that this class depends on. |
| 736 * | 736 * |
| 737 * This version of the constructor is used in test code to inject test versi
ons of the above | 737 * This version of the constructor is used in test code to inject test versi
ons of the above |
| 738 * documented classes. | 738 * documented classes. |
| 739 */ | 739 */ |
| 740 public AwContents(AwBrowserContext browserContext, ViewGroup containerView,
Context context, | 740 public AwContents(AwBrowserContext browserContext, ViewGroup containerView,
Context context, |
| 741 InternalAccessDelegate internalAccessAdapter, | 741 InternalAccessDelegate internalAccessAdapter, |
| 742 NativeDrawGLFunctorFactory nativeDrawGLFunctorFactory, AwContentsCli
ent contentsClient, | 742 NativeDrawGLFunctorFactory nativeDrawGLFunctorFactory, AwContentsCli
ent contentsClient, |
| 743 AwSettings settings, DependencyFactory dependencyFactory) { | 743 AwSettings settings, DependencyFactory dependencyFactory) { |
| 744 setLocale(LocaleUtils.getDefaultLocale()); | 744 setLocale(LocaleUtils.getDefaultLocaleString()); |
| 745 settings.updateAcceptLanguages(); | 745 settings.updateAcceptLanguages(); |
| 746 | 746 |
| 747 mBrowserContext = browserContext; | 747 mBrowserContext = browserContext; |
| 748 | 748 |
| 749 // setWillNotDraw(false) is required since WebView draws it's own conten
ts using it's | 749 // setWillNotDraw(false) is required since WebView draws it's own conten
ts using it's |
| 750 // container view. If this is ever not the case we should remove this, a
s it removes | 750 // container view. If this is ever not the case we should remove this, a
s it removes |
| 751 // Android's gatherTransparentRegion optimization for the view. | 751 // Android's gatherTransparentRegion optimization for the view. |
| 752 mContainerView = containerView; | 752 mContainerView = containerView; |
| 753 mContainerView.setWillNotDraw(false); | 753 mContainerView.setWillNotDraw(false); |
| 754 | 754 |
| (...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 * Post a message to a frame. | 2239 * Post a message to a frame. |
| 2240 * | 2240 * |
| 2241 * @param frameName The name of the frame. If the name is null the message i
s posted | 2241 * @param frameName The name of the frame. If the name is null the message i
s posted |
| 2242 * to the main frame. | 2242 * to the main frame. |
| 2243 * @param message The message | 2243 * @param message The message |
| 2244 * @param targetOrigin The target origin | 2244 * @param targetOrigin The target origin |
| 2245 * @param sentPorts The sent message ports, if any. Pass null if there is no | 2245 * @param sentPorts The sent message ports, if any. Pass null if there is no |
| 2246 * message ports to pass. | 2246 * message ports to pass. |
| 2247 */ | 2247 */ |
| 2248 public void postMessageToFrame( | 2248 public void postMessageToFrame( |
| 2249 String frameName, String message, String targetOrigin, MessagePort[]
sentPorts) { | 2249 String frameName, String message, String targetOrigin, AppWebMessage
Port[] sentPorts) { |
| 2250 if (isDestroyed(WARN)) return; | 2250 if (isDestroyed(WARN)) return; |
| 2251 if (mPostMessageSender == null) { | 2251 if (mPostMessageSender == null) { |
| 2252 AppWebMessagePortService service = mBrowserContext.getMessagePortSer
vice(); | 2252 AppWebMessagePortService service = mBrowserContext.getMessagePortSer
vice(); |
| 2253 mPostMessageSender = new PostMessageSender(this, service); | 2253 mPostMessageSender = new PostMessageSender(this, service); |
| 2254 service.addObserver(mPostMessageSender); | 2254 service.addObserver(mPostMessageSender); |
| 2255 } | 2255 } |
| 2256 mPostMessageSender.postMessage(frameName, message, targetOrigin, | 2256 mPostMessageSender.postMessage(frameName, message, targetOrigin, sentPor
ts); |
| 2257 (AppWebMessagePort[]) sentPorts); | |
| 2258 } | 2257 } |
| 2259 | 2258 |
| 2260 // Implements PostMessageSender.PostMessageSenderDelegate interface method. | 2259 // Implements PostMessageSender.PostMessageSenderDelegate interface method. |
| 2261 @Override | 2260 @Override |
| 2262 public boolean isPostMessageSenderReady() { | 2261 public boolean isPostMessageSenderReady() { |
| 2263 return true; | 2262 return true; |
| 2264 } | 2263 } |
| 2265 | 2264 |
| 2266 // Implements PostMessageSender.PostMessageSenderDelegate interface method. | 2265 // Implements PostMessageSender.PostMessageSenderDelegate interface method. |
| 2267 @Override | 2266 @Override |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3142 } | 3141 } |
| 3143 mIsAttachedToWindow = true; | 3142 mIsAttachedToWindow = true; |
| 3144 | 3143 |
| 3145 mContentViewCore.onAttachedToWindow(); | 3144 mContentViewCore.onAttachedToWindow(); |
| 3146 nativeOnAttachedToWindow(mNativeAwContents, mContainerView.getWidth(
), | 3145 nativeOnAttachedToWindow(mNativeAwContents, mContainerView.getWidth(
), |
| 3147 mContainerView.getHeight()); | 3146 mContainerView.getHeight()); |
| 3148 updateHardwareAcceleratedFeaturesToggle(); | 3147 updateHardwareAcceleratedFeaturesToggle(); |
| 3149 postUpdateContentViewCoreVisibility(); | 3148 postUpdateContentViewCoreVisibility(); |
| 3150 mCurrentFunctor.onAttachedToWindow(); | 3149 mCurrentFunctor.onAttachedToWindow(); |
| 3151 | 3150 |
| 3152 setLocale(LocaleUtils.getDefaultLocale()); | 3151 setLocale(LocaleUtils.getDefaultLocaleString()); |
| 3153 mSettings.updateAcceptLanguages(); | 3152 mSettings.updateAcceptLanguages(); |
| 3154 | 3153 |
| 3155 if (mComponentCallbacks != null) return; | 3154 if (mComponentCallbacks != null) return; |
| 3156 mComponentCallbacks = new AwComponentCallbacks(); | 3155 mComponentCallbacks = new AwComponentCallbacks(); |
| 3157 mContext.registerComponentCallbacks(mComponentCallbacks); | 3156 mContext.registerComponentCallbacks(mComponentCallbacks); |
| 3158 } | 3157 } |
| 3159 | 3158 |
| 3160 @Override | 3159 @Override |
| 3161 public void onDetachedFromWindow() { | 3160 public void onDetachedFromWindow() { |
| 3162 if (isDestroyed(NO_WARN)) return; | 3161 if (isDestroyed(NO_WARN)) return; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3377 | 3376 |
| 3378 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, | 3377 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, |
| 3379 String message, String targetOrigin, int[] msgPorts); | 3378 String message, String targetOrigin, int[] msgPorts); |
| 3380 | 3379 |
| 3381 private native void nativeCreateMessageChannel( | 3380 private native void nativeCreateMessageChannel( |
| 3382 long nativeAwContents, AppWebMessagePort[] ports); | 3381 long nativeAwContents, AppWebMessagePort[] ports); |
| 3383 | 3382 |
| 3384 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); | 3383 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); |
| 3385 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw
Contents); | 3384 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw
Contents); |
| 3386 } | 3385 } |
| OLD | NEW |