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
This commit is contained in:
Zeeshan Ali (Khattak) 2016-02-23 17:29:47 +00:00
parent 364f1453c1
commit 3492121c3f

View File

@ -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,