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

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

Issue 2496183002: Use GetDefaultLocaleListString for returning LocaleList (Closed)
Patch Set: extract setLocale method, since configuration.getLocales() returns the same as LocaleUtils.getDefau… Created 4 years, 1 month 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // we are a child of a ListView. This may cause many toggles of View focus, which we suppress 353 // we are a child of a ListView. This may cause many toggles of View focus, which we suppress
354 // when in this state. 354 // when in this state.
355 private boolean mTemporarilyDetached; 355 private boolean mTemporarilyDetached;
356 356
357 private Handler mHandler; 357 private Handler mHandler;
358 358
359 // True when this AwContents has been destroyed. 359 // True when this AwContents has been destroyed.
360 // Do not use directly, call isDestroyed() instead. 360 // Do not use directly, call isDestroyed() instead.
361 private boolean mIsDestroyed = false; 361 private boolean mIsDestroyed = false;
362 362
363 private static String sCurrentLocale = ""; 363 private static String sCurrentLocales = "";
364 364
365 private static final class AwContentsDestroyRunnable implements Runnable { 365 private static final class AwContentsDestroyRunnable implements Runnable {
366 private final long mNativeAwContents; 366 private final long mNativeAwContents;
367 // Hold onto a reference to the window (via its wrapper), so that it is not destroyed 367 // Hold onto a reference to the window (via its wrapper), so that it is not destroyed
368 // until we are done here. 368 // until we are done here.
369 private final WindowAndroidWrapper mWindowAndroid; 369 private final WindowAndroidWrapper mWindowAndroid;
370 370
371 private AwContentsDestroyRunnable( 371 private AwContentsDestroyRunnable(
372 long nativeAwContents, WindowAndroidWrapper windowAndroid) { 372 long nativeAwContents, WindowAndroidWrapper windowAndroid) {
373 mNativeAwContents = nativeAwContents; 373 mNativeAwContents = nativeAwContents;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 nativeTrimMemory(mNativeAwContents, level, visible); 687 nativeTrimMemory(mNativeAwContents, level, visible);
688 } 688 }
689 }); 689 });
690 } 690 }
691 691
692 @Override 692 @Override
693 public void onLowMemory() {} 693 public void onLowMemory() {}
694 694
695 @Override 695 @Override
696 public void onConfigurationChanged(Configuration configuration) { 696 public void onConfigurationChanged(Configuration configuration) {
697 setLocale(LocaleUtils.toLanguageTag(configuration.locale)); 697 setLocale();
Seigo Nonaka 2016/11/15 05:15:59 setLocale() sounds confusing since it doesn't acce
Yirui Huang 2016/11/16 00:23:45 Done.
698 mSettings.updateAcceptLanguages(); 698 mSettings.updateAcceptLanguages();
699 } 699 }
700 }; 700 };
701 701
702 //-------------------------------------------------------------------------- ------------------ 702 //-------------------------------------------------------------------------- ------------------
703 private class AwDisplayAndroidObserver implements DisplayAndroidObserver { 703 private class AwDisplayAndroidObserver implements DisplayAndroidObserver {
704 @Override 704 @Override
705 public void onRotationChanged(int rotation) {} 705 public void onRotationChanged(int rotation) {}
706 706
707 @Override 707 @Override
(...skipping 30 matching lines...) Expand all
738 * @param dependencyFactory an instance of the DependencyFactory used to pro vide instances of 738 * @param dependencyFactory an instance of the DependencyFactory used to pro vide instances of
739 * classes that this class depends on. 739 * classes that this class depends on.
740 * 740 *
741 * This version of the constructor is used in test code to inject test versi ons of the above 741 * This version of the constructor is used in test code to inject test versi ons of the above
742 * documented classes. 742 * documented classes.
743 */ 743 */
744 public AwContents(AwBrowserContext browserContext, ViewGroup containerView, Context context, 744 public AwContents(AwBrowserContext browserContext, ViewGroup containerView, Context context,
745 InternalAccessDelegate internalAccessAdapter, 745 InternalAccessDelegate internalAccessAdapter,
746 NativeDrawGLFunctorFactory nativeDrawGLFunctorFactory, AwContentsCli ent contentsClient, 746 NativeDrawGLFunctorFactory nativeDrawGLFunctorFactory, AwContentsCli ent contentsClient,
747 AwSettings settings, DependencyFactory dependencyFactory) { 747 AwSettings settings, DependencyFactory dependencyFactory) {
748 setLocale(LocaleUtils.getDefaultLocaleString()); 748 setLocale();
749 settings.updateAcceptLanguages(); 749 settings.updateAcceptLanguages();
750 750
751 mBrowserContext = browserContext; 751 mBrowserContext = browserContext;
752 752
753 // setWillNotDraw(false) is required since WebView draws it's own conten ts using it's 753 // setWillNotDraw(false) is required since WebView draws it's own conten ts using it's
754 // container view. If this is ever not the case we should remove this, a s it removes 754 // container view. If this is ever not the case we should remove this, a s it removes
755 // Android's gatherTransparentRegion optimization for the view. 755 // Android's gatherTransparentRegion optimization for the view.
756 mContainerView = containerView; 756 mContainerView = containerView;
757 mContainerView.setWillNotDraw(false); 757 mContainerView.setWillNotDraw(false);
758 758
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 final boolean listenToActivityState = false; 1014 final boolean listenToActivityState = false;
1015 wrapper = new WindowAndroidWrapper( 1015 wrapper = new WindowAndroidWrapper(
1016 new ActivityWindowAndroid(context, listenToActivityState)); 1016 new ActivityWindowAndroid(context, listenToActivityState));
1017 } else { 1017 } else {
1018 wrapper = new WindowAndroidWrapper(new WindowAndroid(context)); 1018 wrapper = new WindowAndroidWrapper(new WindowAndroid(context));
1019 } 1019 }
1020 sContextWindowMap.put(context, wrapper); 1020 sContextWindowMap.put(context, wrapper);
1021 return wrapper; 1021 return wrapper;
1022 } 1022 }
1023 1023
1024 // Set and keep updating locales for webview.
Seigo Nonaka 2016/11/15 05:15:59 I'm confused with "keep updating". What does it in
Yirui Huang 2016/11/16 00:23:45 Done.
1024 @VisibleForTesting 1025 @VisibleForTesting
1025 public static void setLocale(String locale) { 1026 public static void setLocale() {
1026 if (!sCurrentLocale.equals(locale)) { 1027 String locales = LocaleUtils.getDefaultLocaleListString();
1027 sCurrentLocale = locale; 1028 if (!sCurrentLocales.equals(locales)) {
1028 nativeSetLocale(sCurrentLocale); 1029 sCurrentLocales = locales;
1030 nativeSetLocale(LocaleUtils.getDefaultLocaleString(), sCurrentLocale s);
Seigo Nonaka 2016/11/15 05:15:59 I think it is good to leave comments why you still
Yirui Huang 2016/11/16 00:23:45 Done.
1029 } 1031 }
1030 } 1032 }
1031 1033
1032 private void updateNativeAwGLFunctor() { 1034 private void updateNativeAwGLFunctor() {
1033 nativeSetAwGLFunctor(mNativeAwContents, 1035 nativeSetAwGLFunctor(mNativeAwContents,
1034 mCurrentFunctor != null ? mCurrentFunctor.getNativeAwGLFunctor() : 0); 1036 mCurrentFunctor != null ? mCurrentFunctor.getNativeAwGLFunctor() : 0);
1035 } 1037 }
1036 1038
1037 /* Common initialization routine for adopting a native AwContents instance i nto this 1039 /* Common initialization routine for adopting a native AwContents instance i nto this
1038 * java instance. 1040 * java instance.
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 } 3152 }
3151 mIsAttachedToWindow = true; 3153 mIsAttachedToWindow = true;
3152 3154
3153 mContentViewCore.onAttachedToWindow(); 3155 mContentViewCore.onAttachedToWindow();
3154 nativeOnAttachedToWindow(mNativeAwContents, mContainerView.getWidth( ), 3156 nativeOnAttachedToWindow(mNativeAwContents, mContainerView.getWidth( ),
3155 mContainerView.getHeight()); 3157 mContainerView.getHeight());
3156 updateHardwareAcceleratedFeaturesToggle(); 3158 updateHardwareAcceleratedFeaturesToggle();
3157 postUpdateContentViewCoreVisibility(); 3159 postUpdateContentViewCoreVisibility();
3158 mCurrentFunctor.onAttachedToWindow(); 3160 mCurrentFunctor.onAttachedToWindow();
3159 3161
3160 setLocale(LocaleUtils.getDefaultLocaleString()); 3162 setLocale();
3161 mSettings.updateAcceptLanguages(); 3163 mSettings.updateAcceptLanguages();
3162 3164
3163 if (mComponentCallbacks != null) return; 3165 if (mComponentCallbacks != null) return;
3164 mComponentCallbacks = new AwComponentCallbacks(); 3166 mComponentCallbacks = new AwComponentCallbacks();
3165 mContext.registerComponentCallbacks(mComponentCallbacks); 3167 mContext.registerComponentCallbacks(mComponentCallbacks);
3166 } 3168 }
3167 3169
3168 @Override 3170 @Override
3169 public void onDetachedFromWindow() { 3171 public void onDetachedFromWindow() {
3170 if (isDestroyed(NO_WARN)) return; 3172 if (isDestroyed(NO_WARN)) return;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
3302 //-------------------------------------------------------------------------- ------------------ 3304 //-------------------------------------------------------------------------- ------------------
3303 3305
3304 private static native long nativeInit(AwBrowserContext browserContext); 3306 private static native long nativeInit(AwBrowserContext browserContext);
3305 private static native void nativeDestroy(long nativeAwContents); 3307 private static native void nativeDestroy(long nativeAwContents);
3306 private static native void nativeSetForceAuxiliaryBitmapRendering( 3308 private static native void nativeSetForceAuxiliaryBitmapRendering(
3307 boolean forceAuxiliaryBitmapRendering); 3309 boolean forceAuxiliaryBitmapRendering);
3308 private static native void nativeSetAwDrawSWFunctionTable(long functionTable Pointer); 3310 private static native void nativeSetAwDrawSWFunctionTable(long functionTable Pointer);
3309 private static native void nativeSetAwDrawGLFunctionTable(long functionTable Pointer); 3311 private static native void nativeSetAwDrawGLFunctionTable(long functionTable Pointer);
3310 private static native int nativeGetNativeInstanceCount(); 3312 private static native int nativeGetNativeInstanceCount();
3311 private static native void nativeSetShouldDownloadFavicons(); 3313 private static native void nativeSetShouldDownloadFavicons();
3312 private static native void nativeSetLocale(String locale); 3314 private static native void nativeSetLocale(String locale, String locales);
3313 3315
3314 private native void nativeSetJavaPeers(long nativeAwContents, AwContents awC ontents, 3316 private native void nativeSetJavaPeers(long nativeAwContents, AwContents awC ontents,
3315 AwWebContentsDelegate webViewWebContentsDelegate, 3317 AwWebContentsDelegate webViewWebContentsDelegate,
3316 AwContentsClientBridge contentsClientBridge, 3318 AwContentsClientBridge contentsClientBridge,
3317 AwContentsIoThreadClient ioThreadClient, 3319 AwContentsIoThreadClient ioThreadClient,
3318 InterceptNavigationDelegate navigationInterceptionDelegate); 3320 InterceptNavigationDelegate navigationInterceptionDelegate);
3319 private native WebContents nativeGetWebContents(long nativeAwContents); 3321 private native WebContents nativeGetWebContents(long nativeAwContents);
3320 private native void nativeSetAwGLFunctor(long nativeAwContents, long nativeA wGLFunctor); 3322 private native void nativeSetAwGLFunctor(long nativeAwContents, long nativeA wGLFunctor);
3321 3323
3322 private native void nativeDocumentHasImages(long nativeAwContents, Message m essage); 3324 private native void nativeDocumentHasImages(long nativeAwContents, Message m essage);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3385 3387
3386 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId, 3388 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId,
3387 String message, String targetOrigin, int[] msgPorts); 3389 String message, String targetOrigin, int[] msgPorts);
3388 3390
3389 private native void nativeCreateMessageChannel( 3391 private native void nativeCreateMessageChannel(
3390 long nativeAwContents, AppWebMessagePort[] ports); 3392 long nativeAwContents, AppWebMessagePort[] ports);
3391 3393
3392 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC ontents); 3394 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC ontents);
3393 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw Contents); 3395 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw Contents);
3394 } 3396 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698