diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index b912439..256c064 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -820,6 +820,45 @@ public class InAppBrowser extends CordovaPlugin { } + /* + * onPageStarted fires the LOAD_START_EVENT + * + * @param view + * @param url + * @param favicon + */ + @Override + public void onPageStarted(WebView view, String url, Bitmap favicon) { + super.onPageStarted(view, url, favicon); + String newloc = ""; + if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) { + newloc = url; + } + else + { + // Assume that everything is HTTP at this point, because if we don't specify, + // it really should be. Complain loudly about this!!! + LOG.e(LOG_TAG, "Possible Uncaught/Unknown URI"); + newloc = "http://" + url; + } + + // Update the UI if we haven't already + if (!newloc.equals(edittext.getText().toString())) { + edittext.setText(newloc); + } + + try { + JSONObject obj = new JSONObject(); + obj.put("type", LOAD_START_EVENT); + obj.put("url", newloc); + sendUpdate(obj, true); + } catch (JSONException ex) { + LOG.e(LOG_TAG, "URI passed in has caused a JSON error."); + } + } + + + public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url);