Use system setting for default geolocation permissions

This reverts change I0be5dbf4d99d07ca13b07fb299155c5aa17a51bd
and adds an observer on the new default geolocation permission
secure setting.

Bug http://b/issue?id=2535598

Change-Id: I4edcbd3080b7d3af5dc6d74f26779b6d92248010
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java
index 501a52a..bf1f9d5 100644
--- a/src/com/android/browser/BrowserProvider.java
+++ b/src/com/android/browser/BrowserProvider.java
@@ -48,7 +48,6 @@
 import android.util.Log;
 import android.util.Patterns;
 import android.util.TypedValue;
-import android.webkit.GeolocationPermissions;
 
 
 import java.io.File;
@@ -71,7 +70,7 @@
             "viewer?source=androidclient";
 
     private static final String[] TABLE_NAMES = new String[] {
-        "bookmarks", "searches", "geolocation"
+        "bookmarks", "searches"
     };
     private static final String[] SUGGEST_PROJECTION = new String[] {
             "_id", "url", "title", "bookmark", "user_entered"
@@ -113,7 +112,6 @@
     // make sure that these match the index of TABLE_NAMES
     private static final int URI_MATCH_BOOKMARKS = 0;
     private static final int URI_MATCH_SEARCHES = 1;
-    private static final int URI_MATCH_GEOLOCATION = 2;
     // (id % 10) should match the table name index
     private static final int URI_MATCH_BOOKMARKS_ID = 10;
     private static final int URI_MATCH_SEARCHES_ID = 11;
@@ -138,8 +136,6 @@
         URI_MATCHER.addURI("browser",
                 TABLE_NAMES[URI_MATCH_BOOKMARKS] + "/" + SearchManager.SUGGEST_URI_PATH_QUERY,
                 URI_MATCH_BOOKMARKS_SUGGEST);
-        URI_MATCHER.addURI("browser", TABLE_NAMES[URI_MATCH_GEOLOCATION],
-                URI_MATCH_GEOLOCATION);
     }
 
     // 1 -> 2 add cache table
@@ -839,9 +835,6 @@
         if (match == -1) {
             throw new IllegalArgumentException("Unknown URL");
         }
-        if (match == URI_MATCH_GEOLOCATION) {
-            throw new UnsupportedOperationException("query() not supported for geolocation");
-        }
         if (match == URI_MATCH_SUGGEST && mResultsCursor != null) {
             Cursor results = mResultsCursor;
             mResultsCursor = null;
@@ -942,9 +935,6 @@
             case URI_MATCH_SUGGEST:
                 return SearchManager.SUGGEST_MIME_TYPE;
 
-            case URI_MATCH_GEOLOCATION:
-                return "vnd.android.cursor.dir/geolocation";
-
             default:
                 throw new IllegalArgumentException("Unknown URL");
         }
@@ -981,16 +971,6 @@
                 break;
             }
 
-            case URI_MATCH_GEOLOCATION:
-                String origin = initialValues.getAsString(Browser.GeolocationColumns.ORIGIN);
-                if (TextUtils.isEmpty(origin)) {
-                    throw new IllegalArgumentException("Empty origin");
-                }
-                GeolocationPermissions.getInstance().allow(origin);
-                // TODO: Should we have one URI per permission?
-                uri = Browser.GEOLOCATION_URI;
-                break;
-
             default:
                 throw new IllegalArgumentException("Unknown URL");
         }
@@ -1020,10 +1000,6 @@
             throw new IllegalArgumentException("Unknown URL");
         }
 
-        if (match == URI_MATCH_GEOLOCATION) {
-            return deleteGeolocation(url, where, whereArgs);
-        }
-
         // need to know whether it's the bookmarks table for a couple of reasons
         boolean isBookmarkTable = (match == URI_MATCH_BOOKMARKS_ID);
         String id = null;
@@ -1062,19 +1038,6 @@
         return count;
     }
 
-    private int deleteGeolocation(Uri uri, String where, String[] whereArgs) {
-        if (whereArgs.length != 1) {
-            throw new IllegalArgumentException("Bad where arguments");
-        }
-        String origin = whereArgs[0];
-        if (TextUtils.isEmpty(origin)) {
-            throw new IllegalArgumentException("Empty origin");
-        }
-        GeolocationPermissions.getInstance().clear(origin);
-        getContext().getContentResolver().notifyChange(Browser.GEOLOCATION_URI, null);
-        return 1;  // We always return 1, to avoid having to check whether anything was actually removed
-    }
-
     @Override
     public int update(Uri url, ContentValues values, String where,
             String[] whereArgs) {