Skip to content

Commit

Permalink
[TIMOB-25462] Prevent 'load' event firing twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Nov 7, 2017
1 parent c043584 commit ff006d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class TiUIWebView extends TiUIView
private TiWebChromeClient chromeClient;
private boolean bindingCodeInjected = false;
private boolean isLocalHTML = false;
private boolean disableContextMenu = false;
private HashMap<String, String> extraHeaders = new HashMap<String, String>();

private static Enum<?> enumPluginStateOff;
Expand All @@ -74,7 +75,10 @@ public class TiUIWebView extends TiUIView
public static final int PLUGIN_STATE_ON = 1;
public static final int PLUGIN_STATE_ON_DEMAND = 2;

private boolean disableContextMenu = false;
// TIMOB-25462: minor 'hack' to prevent 'beforeload' and 'load' being
// called when the user-agent has been changed, this is a chromium bug
// https://bugs.chromium.org/p/chromium/issues/detail?id=315891
public boolean hasSetUserAgent = false;

private static enum reloadTypes
{
Expand Down Expand Up @@ -834,6 +838,7 @@ public void setUserAgentString(String userAgentString)
{
WebView currWebView = getWebView();
if (currWebView != null) {
hasSetUserAgent = true;
currWebView.getSettings().setUserAgentString(userAgentString);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
WebViewProxy proxy = (WebViewProxy) webView.getProxy();
if (proxy == null) {
if (proxy == null || webView.hasSetUserAgent) {
webView.hasSetUserAgent = false;
return;
}
webView.changeProxyUrl(url);
Expand Down Expand Up @@ -80,7 +81,7 @@ public void onPageStarted(WebView view, String url, Bitmap favicon)
{
super.onPageStarted(view, url, favicon);
WebViewProxy proxy = (WebViewProxy) webView.getProxy();
if (proxy == null) {
if (proxy == null || webView.hasSetUserAgent) {
return;
}
KrollDict data = new KrollDict();
Expand Down

0 comments on commit ff006d7

Please sign in to comment.