summaryrefslogtreecommitdiffstats
path: root/android_webview/java
diff options
context:
space:
mode:
authortserng <tserng@amazon.com>2015-08-05 12:01:45 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-05 19:02:15 +0000
commit67e9830ff10d26bf8840598dde988e4af9581fde (patch)
tree0e4e5ae9897349569d078d94e549a43d4e5b0b0b /android_webview/java
parenta8f1ac39c6a9471bb1fc16933c82cb2cd982412e (diff)
downloadchromium_src-67e9830ff10d26bf8840598dde988e4af9581fde.zip
chromium_src-67e9830ff10d26bf8840598dde988e4af9581fde.tar.gz
chromium_src-67e9830ff10d26bf8840598dde988e4af9581fde.tar.bz2
Implement HttpUserAgentSettings delegate for Android WebView
Instead of using a static accept language and user agent, we set a HttpUserAgentSettings delegate to allow those values to change dynamically. BUG=35049 Review URL: https://codereview.chromium.org/1172093002 Cr-Commit-Position: refs/heads/master@{#341931}
Diffstat (limited to 'android_webview/java')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 8040d06..e56aca1 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -43,6 +43,7 @@ import android.widget.OverScroller;
import org.chromium.android_webview.permission.AwGeolocationCallback;
import org.chromium.android_webview.permission.AwPermissionRequest;
+import org.chromium.base.LocaleUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.VisibleForTesting;
@@ -294,6 +295,8 @@ public class AwContents implements SmartClipProvider,
// Do not use directly, call isDestroyed() instead.
private boolean mIsDestroyed = false;
+ private static String sCurrentLocale = "";
+
private static final class DestroyRunnable implements Runnable {
private final long mNativeAwContents;
@@ -626,7 +629,9 @@ public class AwContents implements SmartClipProvider,
public void onLowMemory() {}
@Override
- public void onConfigurationChanged(Configuration configuration) {}
+ public void onConfigurationChanged(Configuration configuration) {
+ setLocale(LocaleUtils.getLocale(configuration.locale));
+ }
};
//--------------------------------------------------------------------------------------------
@@ -659,6 +664,8 @@ public class AwContents implements SmartClipProvider,
InternalAccessDelegate internalAccessAdapter, NativeGLDelegate nativeGLDelegate,
AwContentsClient contentsClient, AwSettings settings,
DependencyFactory dependencyFactory) {
+ setLocale(LocaleUtils.getDefaultLocale());
+
mBrowserContext = browserContext;
// setWillNotDraw(false) is required since WebView draws it's own contents using it's
@@ -915,6 +922,13 @@ public class AwContents implements SmartClipProvider,
return activityWindowAndroid;
}
+ private static void setLocale(String locale) {
+ if (!sCurrentLocale.equals(locale)) {
+ sCurrentLocale = locale;
+ nativeSetLocale(sCurrentLocale);
+ }
+ }
+
/* Common initialization routine for adopting a native AwContents instance into this
* java instance.
*
@@ -2903,6 +2917,8 @@ public class AwContents implements SmartClipProvider,
mContainerView.getHeight());
updateHardwareAcceleratedFeaturesToggle();
+ setLocale(LocaleUtils.getDefaultLocale());
+
if (mComponentCallbacks != null) return;
mComponentCallbacks = new AwComponentCallbacks();
mContext.registerComponentCallbacks(mComponentCallbacks);
@@ -3056,6 +3072,7 @@ public class AwContents implements SmartClipProvider,
private static native long nativeGetAwDrawGLFunction();
private static native int nativeGetNativeInstanceCount();
private static native void nativeSetShouldDownloadFavicons();
+ private static native void nativeSetLocale(String locale);
private native void nativeSetJavaPeers(long nativeAwContents, AwContents awContents,
AwWebContentsDelegate webViewWebContentsDelegate,