Do not attempt to download non-https URLs.

Bug:3388003

Change-Id: I9d81017820762bcf714453b935488912397dadbc
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 75762a0..80cb2c8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -749,6 +749,8 @@
             the user how to enable SD card storage -->
     <string name="download_sdcard_busy_dlg_msg" product="default">The SD card is busy. To allow downloads, select \"Turn off USB storage\" in the notification.</string>
 
+    <!-- Toast for a download which cannot begin because the URL is not http or https -->
+    <string name="cannot_download">Can only download \"http\" or \"https\" URLs.</string>
     <!-- Title for a dialog informing the user that there is no application on
             the phone that can open the file that was downloaded -->
     <string name="download_no_application_title">Cannot open file</string>
diff --git a/src/com/android/browser/DownloadHandler.java b/src/com/android/browser/DownloadHandler.java
index 40278f4..4903a41 100644
--- a/src/com/android/browser/DownloadHandler.java
+++ b/src/com/android/browser/DownloadHandler.java
@@ -181,7 +181,13 @@
 
         String addressString = webAddress.toString();
         Uri uri = Uri.parse(addressString);
-        final DownloadManager.Request request = new DownloadManager.Request(uri);
+        final DownloadManager.Request request;
+        try {
+            request = new DownloadManager.Request(uri);
+        } catch (IllegalArgumentException e) {
+            Toast.makeText(activity, R.string.cannot_download, Toast.LENGTH_SHORT).show();
+            return;
+        }
         request.setMimeType(mimetype);
         // set downloaded file destination to /sdcard/Download.
         // or, should it be set to one of several Environment.DIRECTORY* dirs depending on mimetype?