Fix iOS crash related to window.performance

Fix crashes on iOS related to using window.performance and reading
window.location.href in a UIWebView. You must set the global variable
distiller_on_ios=true prior to evaluating the distiller.

BUG=
R=mdjones@chromium.org

Review URL: https://codereview.chromium.org/1386363003 .

Patch from gnachman <georgen@google.com>.
diff --git a/java/org/chromium/distiller/DomDistiller.java b/java/org/chromium/distiller/DomDistiller.java
index 37d86ca..531122e 100644
--- a/java/org/chromium/distiller/DomDistiller.java
+++ b/java/org/chromium/distiller/DomDistiller.java
@@ -47,7 +47,9 @@
             result.addContentImages().setUrl(url);
         }
 
-        String original_url = options.hasOriginalUrl() ? options.getOriginalUrl() : Window.Location.getHref();
+        // iOS doesn't support reading window.location.href, so we use document.URL instead.
+        String original_url =
+                options.hasOriginalUrl() ? options.getOriginalUrl() : Document.get().getURL();
         TimingInfo timingInfo = contentExtractor.getTimingInfo();
         double stPaging = DomUtil.getTime();
         result.setPaginationInfo(PagingLinksFinder.getPaginationInfo(original_url));
diff --git a/java/org/chromium/distiller/DomUtil.java b/java/org/chromium/distiller/DomUtil.java
index 91aabde..d0bcb1b 100644
--- a/java/org/chromium/distiller/DomUtil.java
+++ b/java/org/chromium/distiller/DomUtil.java
@@ -112,8 +112,9 @@
     }-*/;
 
     public static native double getTime() /*-{
-        // window.performance is unavailable in Gwt's dev environment.
-        if (window.performance) {
+        // window.performance is unavailable in Gwt's dev environment and even referencing it on iOS
+        // causes a crash.
+        if ((typeof distiller_on_ios === 'undefined' || !distiller_on_ios) && window.performance) {
           return window.performance.now();
         }
         return Date.now();