appId service and removed unnecessary permissions from manifest
This commit is contained in:
parent
6b06772f22
commit
ffa8b5024b
|
@ -8,6 +8,7 @@ var folderService = new FolderService(cryptoService, userService, apiService);
|
||||||
var syncService = new SyncService(siteService, folderService, userService, apiService);
|
var syncService = new SyncService(siteService, folderService, userService, apiService);
|
||||||
var autofillService = new AutofillService();
|
var autofillService = new AutofillService();
|
||||||
var passwordGenerationService = new PasswordGenerationService();
|
var passwordGenerationService = new PasswordGenerationService();
|
||||||
|
var appIdService = new AppIdService();
|
||||||
|
|
||||||
function buildContextMenu() {
|
function buildContextMenu() {
|
||||||
chrome.contextMenus.removeAll();
|
chrome.contextMenus.removeAll();
|
||||||
|
|
|
@ -60,13 +60,9 @@
|
||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"tabs",
|
"tabs",
|
||||||
"idle",
|
|
||||||
"notifications",
|
|
||||||
"contextMenus",
|
"contextMenus",
|
||||||
"storage",
|
"storage",
|
||||||
"unlimitedStorage",
|
"unlimitedStorage",
|
||||||
"webRequest",
|
|
||||||
"webRequestBlocking",
|
|
||||||
"http://*/*",
|
"http://*/*",
|
||||||
"https://*/*"
|
"https://*/*"
|
||||||
],
|
],
|
||||||
|
|
|
@ -33,4 +33,7 @@
|
||||||
})
|
})
|
||||||
.factory('utilsService', function () {
|
.factory('utilsService', function () {
|
||||||
return chrome.extension.getBackgroundPage().utilsService;
|
return chrome.extension.getBackgroundPage().utilsService;
|
||||||
|
})
|
||||||
|
.factory('appIdService', function () {
|
||||||
|
return chrome.extension.getBackgroundPage().appIdService;
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
function AppIdService() {
|
||||||
|
initAppIdService();
|
||||||
|
};
|
||||||
|
|
||||||
|
function initAppIdService() {
|
||||||
|
AppIdService.prototype.getAppId = function (callback) {
|
||||||
|
if (!callback || typeof callback !== 'function') {
|
||||||
|
throw 'callback function required';
|
||||||
|
}
|
||||||
|
|
||||||
|
makeAndGetAppId('appId');
|
||||||
|
};
|
||||||
|
|
||||||
|
AppIdService.prototype.getAnonymousAppId = function (callback) {
|
||||||
|
if (!callback || typeof callback !== 'function') {
|
||||||
|
throw 'callback function required';
|
||||||
|
}
|
||||||
|
|
||||||
|
makeAndGetAppId('anonymousAppId');
|
||||||
|
};
|
||||||
|
|
||||||
|
function makeAndGetAppId(key) {
|
||||||
|
chrome.storage.local.get(key, function (obj) {
|
||||||
|
if (obj && obj[key]) {
|
||||||
|
callback(obj[key]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var setObj = {};
|
||||||
|
setObj[key] = newGuid();
|
||||||
|
chrome.storage.local.set(setObj, function () {
|
||||||
|
callback(setObj[key]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ref: http://stackoverflow.com/a/2117523/1090359
|
||||||
|
function newGuid() {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
|
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||||
|
return v.toString(16);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue