diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java b/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java index 9cfc99bb..221a884c 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java +++ b/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java @@ -60,6 +60,7 @@ public class SystemWebViewEngine implements CordovaWebViewEngine { protected final SystemWebView webView; protected final SystemCookieManager cookieManager; + protected CordovaPreferences preferences; protected CordovaBridge bridge; protected CordovaWebViewEngine.Client client; protected CordovaWebView parentWebView; @@ -71,10 +72,15 @@ public class SystemWebViewEngine implements CordovaWebViewEngine { /** Used when created via reflection. */ public SystemWebViewEngine(Context context, CordovaPreferences preferences) { - this(new SystemWebView(context)); + this(new SystemWebView(context), preferences); } public SystemWebViewEngine(SystemWebView webView) { + this(webView, null); + } + + public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) { + this.preferences = preferences; this.webView = webView; cookieManager = new SystemCookieManager(webView); } @@ -86,6 +92,10 @@ public class SystemWebViewEngine implements CordovaWebViewEngine { if (this.cordova != null) { throw new IllegalStateException(); } + // Needed when prefs are not passed by the constructor + if (preferences == null) { + preferences = parentWebView.getPreferences(); + } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; @@ -199,7 +209,19 @@ public class SystemWebViewEngine implements CordovaWebViewEngine { // Fix for CB-1405 // Google issue 4641 - settings.getUserAgentString(); + String defaultUserAgent = settings.getUserAgentString(); + + // Fix for CB-3360 + String overrideUserAgent = preferences.getString("OverrideUserAgent", null); + if (overrideUserAgent != null) { + settings.setUserAgentString(overrideUserAgent); + } else { + String appendUserAgent = preferences.getString("AppendUserAgent", null); + if (appendUserAgent != null) { + settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent); + } + } + // End CB-3360 IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);