cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject cordova-plugin-geolocation git commit: CB-10277 Error callback should be called w/ PositionError when location access is denied
Date Mon, 04 Jan 2016 08:45:32 GMT
Repository: cordova-plugin-geolocation
Updated Branches:
  refs/heads/master a754436ee -> a818d6dcc


CB-10277 Error callback should be called w/ PositionError when location access is denied

github close #62


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/a818d6dc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/a818d6dc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/a818d6dc

Branch: refs/heads/master
Commit: a818d6dcc02cc26a06fec3d95f9eff40f4e6568a
Parents: a754436
Author: sgrebnov <v-segreb@microsoft.com>
Authored: Tue Dec 29 12:26:25 2015 +0300
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Mon Jan 4 11:45:36 2016 +0300

----------------------------------------------------------------------
 plugin.xml                 |  4 ++++
 www/android/geolocation.js | 19 ++++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/a818d6dc/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 7fff532..e6269ca 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -56,6 +56,10 @@ xmlns:android="http://schemas.android.com/apk/res/android"
             <clobbers target="navigator.geolocation" />
         </js-module>
 
+        <!-- We don't expose PositionError via clobber on Android as we use it internally
only -->
+        <js-module src="www/PositionError.js" name="PositionError">
+            <runs />
+        </js-module>
 
     </platform>
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/a818d6dc/www/android/geolocation.js
----------------------------------------------------------------------
diff --git a/www/android/geolocation.js b/www/android/geolocation.js
index e1d678b..57b8122 100644
--- a/www/android/geolocation.js
+++ b/www/android/geolocation.js
@@ -22,6 +22,7 @@
 
 var exec = cordova.require('cordova/exec');
 var utils = require('cordova/utils');
+var PositionError = require('./PositionError');
 
 module.exports = {
 
@@ -30,7 +31,12 @@ module.exports = {
           var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
           geo.getCurrentPosition(success, error, args);
         };
-        exec(win, error, "Geolocation", "getPermission", []);
+        var fail = function() {
+            if (error) {
+                error(new PositionError (PositionError.PERMISSION_DENIED, 'Illegal Access'));
+            }
+        };
+        exec(win, fail, "Geolocation", "getPermission", []);
     },
 
     watchPosition: function(success, error, args) {
@@ -40,7 +46,13 @@ module.exports = {
             var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
             pluginToNativeWatchMap[pluginWatchId] = geo.watchPosition(success, error, args);
         };
-        exec(win, error, "Geolocation", "getPermission", []);
+
+        var fail = function() {
+            if (error) {
+                error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access'));
+            }
+        };
+        exec(win, fail, "Geolocation", "getPermission", []);
 
         return pluginWatchId;
     },
@@ -50,7 +62,8 @@ module.exports = {
             var nativeWatchId = pluginToNativeWatchMap[pluginWatchId];
             var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
             geo.clearWatch(nativeWatchId);
-        }
+        };
+
         exec(win, null, "Geolocation", "getPermission", []);
     }
 };


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message