MDM Download Restriction support

This commit adds MDM management of the following if the restriction
is enabled via the MDM mechanism:
    1. The ability to download.
    2. The download directory under '/Phone Storage/', if
       downloading is permitted.

These restrictions are only effective on SWE provisioned in the
'Work' profile. Non-work-profile SWE will not be affected.

When the download capability has been restricted, clicking a download
link results in a Toast message (Managed by your administrator). A long-press
of the link still brings up a context menu, but the 'Save link as' menuitem
is disabled in this case.

If MDM sets the download directory, it is not setting the full path, just
the directory under '/Phone Storage'. The directory specified must include
a leading '/' i.e. '/NewDownloadDir'.

Change-Id: I13a44892a36925d6324b87f7655d79fb0776f8a9
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 6337237..8271475 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -96,6 +96,7 @@
 
 import com.android.browser.IntentHandler.UrlData;
 import com.android.browser.UI.ComboViews;
+import com.android.browser.mdm.DownloadDirRestriction;
 import com.android.browser.mdm.EditBookmarksRestriction;
 import com.android.browser.mdm.IncognitoRestriction;
 import com.android.browser.mdm.URLFilterRestriction;
@@ -1540,8 +1541,14 @@
             menu.setGroupVisible(R.id.ANCHOR_MENU,
                     type == WebView.HitTestResult.SRC_ANCHOR_TYPE
                             || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE);
-            menu.findItem(R.id.save_link_context_menu_id).setEnabled(
-                UrlUtils.isDownloadableScheme(extra));
+
+            if (DownloadDirRestriction.getInstance().downloadsAllowed()) {
+                menu.findItem(R.id.save_link_context_menu_id).setEnabled(
+                        UrlUtils.isDownloadableScheme(extra));
+            }
+            else {
+                menu.findItem(R.id.save_link_context_menu_id).setEnabled(false);
+            }
         }
         // Setup custom handling depending on the type
         switch (type) {