[gnome-shell] location: Only ask user once



commit 3492121c3f8ec762455ce578bd13118796bd272b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Feb 23 17:29:47 2016 +0000

    location: Only ask user once
    
    Let's make it really simple and ask user interactively, once. This
    simplifies things for:
    
    * Privacy panel of gnome-control-center as it doesn't have to filter
      applications.
    
    * Apps: If they are denied access, they can simply point users to
      privacy panel of gnome-control-center since they can be sure location
      access for the app can be enabled in there.
    
    Also it's less annoying to user. Before this patch, if they denied
    access to application, they had to keep doing that at least each time
    they launched the application.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762559

 js/ui/status/location.js |   28 ++++++++++------------------
 1 files changed, 10 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/status/location.js b/js/ui/status/location.js
index 6662308..00c1f42 100644
--- a/js/ui/status/location.js
+++ b/js/ui/status/location.js
@@ -286,7 +286,6 @@ const AppAuthorizer = new Lang.Class({
         this._maxAccuracyLevel = maxAccuracyLevel;
 
         this._accuracyLevel = GeoclueAccuracyLevel.NONE;
-        this._timesAllowed = 0;
     },
 
     authorize: function(onAuthDone) {
@@ -329,15 +328,14 @@ const AppAuthorizer = new Lang.Class({
         [this._permissions] = result;
         let permission = this._permissions[this.desktopId];
 
-        let [levelStr, timeStr] = permission || ['NONE', '0'];
-        this._accuracyLevel = GeoclueAccuracyLevel[levelStr] ||
-                              GeoclueAccuracyLevel.NONE;
-        this._timesAllowed = Number(timeStr) || 0;
-
-        if (this._timesAllowed < 3)
+        if (permission == null) {
             this._userAuthorizeApp();
-        else
+        } else {
+            let [levelStr] = permission || ['NONE'];
+            this._accuracyLevel = GeoclueAccuracyLevel[levelStr] ||
+                                  GeoclueAccuracyLevel.NONE;
             this._completeAuth();
+        }
     },
 
     _userAuthorizeApp: function() {
@@ -368,7 +366,6 @@ const AppAuthorizer = new Lang.Class({
             this._accuracyLevel = clamp(this._accuracyLevel,
                                         0,
                                         this._maxAccuracyLevel);
-            this._timesAllowed++;
         }
         this._saveToPermissionStore();
 
@@ -379,15 +376,10 @@ const AppAuthorizer = new Lang.Class({
         if (this._permStoreProxy == null)
             return;
 
-        if (this._accuracyLevel != GeoclueAccuracyLevel.NONE) {
-            let levelStr = accuracyLevelToString(this._accuracyLevel);
-            let dateStr = Math.round(Date.now() / 1000).toString();
-            this._permissions[this.desktopId] = [levelStr,
-                                                 this._timesAllowed.toString(),
-                                                 dateStr];
-        } else {
-            delete this._permissions[this.desktopId];
-        }
+        let levelStr = accuracyLevelToString(this._accuracyLevel);
+        let dateStr = Math.round(Date.now() / 1000).toString();
+        this._permissions[this.desktopId] = [levelStr, dateStr];
+
         let data = GLib.Variant.new('av', {});
 
         this._permStoreProxy.SetRemote(APP_PERMISSIONS_TABLE,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]