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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 1172093002: Implement HttpUserAgentSettings delegate for Android WebView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add locale check on attach Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
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 76a9cc8ce54d67b7541cfb96b3e60ef6427c4c53..5315a410d82bd3c44fe919be1db74a701e933e23 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -45,6 +45,7 @@ import android.widget.OverScroller;
import org.chromium.android_webview.permission.AwPermissionRequest;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
+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;
@@ -611,7 +614,12 @@ public class AwContents implements SmartClipProvider,
public void onLowMemory() {}
@Override
- public void onConfigurationChanged(Configuration configuration) {}
+ public void onConfigurationChanged(Configuration configuration) {
+ String newLocale = LocaleUtils.getLocale(configuration.locale);
+ if (!sCurrentLocale.equals(newLocale)) {
Torne 2015/07/24 10:55:39 May not be worth checking if they're equal here si
ctserng 2015/07/24 18:17:22 The caching was left over from a previous patch wh
+ sCurrentLocale = newLocale;
+ }
+ }
};
//--------------------------------------------------------------------------------------------
@@ -644,6 +652,8 @@ public class AwContents implements SmartClipProvider,
InternalAccessDelegate internalAccessAdapter, NativeGLDelegate nativeGLDelegate,
AwContentsClient contentsClient, AwSettings settings,
DependencyFactory dependencyFactory) {
+ sCurrentLocale = LocaleUtils.getDefaultLocale();
+
mBrowserContext = browserContext;
// setWillNotDraw(false) is required since WebView draws it's own contents using it's
@@ -2387,6 +2397,11 @@ public class AwContents implements SmartClipProvider,
}
@CalledByNative
+ private static String getLocale() {
+ return sCurrentLocale;
+ }
+
+ @CalledByNative
private void onReceivedTouchIconUrl(String url, boolean precomposed) {
mContentsClient.onReceivedTouchIconUrl(url, precomposed);
}
@@ -2884,6 +2899,11 @@ public class AwContents implements SmartClipProvider,
mContainerView.getHeight());
updateHardwareAcceleratedFeaturesToggle();
+ String currentLocale = LocaleUtils.getDefaultLocale();
+ if (!sCurrentLocale.equals(currentLocale)) {
+ sCurrentLocale = currentLocale;
+ }
+
if (mComponentCallbacks != null) return;
mComponentCallbacks = new AwComponentCallbacks();
mContext.registerComponentCallbacks(mComponentCallbacks);
« no previous file with comments | « android_webview/browser/net/aw_url_request_context_getter.cc ('k') | android_webview/lib/main/aw_main_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698