mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
utils service. added browser detection method to utils
This commit is contained in:
parent
9a19acef22
commit
5b1172b8d0
@ -1,3 +1,4 @@
|
|||||||
|
var utilsService = new UtilsService();
|
||||||
var cryptoService = new CryptoService();
|
var cryptoService = new CryptoService();
|
||||||
var tokenService = new TokenService();
|
var tokenService = new TokenService();
|
||||||
var apiService = new ApiService(tokenService);
|
var apiService = new ApiService(tokenService);
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
"models/api/responseModels.js",
|
"models/api/responseModels.js",
|
||||||
"models/dataModels.js",
|
"models/dataModels.js",
|
||||||
"models/domainModels.js",
|
"models/domainModels.js",
|
||||||
"services/cryptoService.js",
|
"services/utilsService.js",
|
||||||
"services/cryptoService.js",
|
"services/cryptoService.js",
|
||||||
"services/tokenService.js",
|
"services/tokenService.js",
|
||||||
"services/apiService.js",
|
"services/apiService.js",
|
||||||
|
@ -30,4 +30,7 @@
|
|||||||
})
|
})
|
||||||
.factory('passwordGenerationService', function () {
|
.factory('passwordGenerationService', function () {
|
||||||
return chrome.extension.getBackgroundPage().passwordGenerationService;
|
return chrome.extension.getBackgroundPage().passwordGenerationService;
|
||||||
|
})
|
||||||
|
.factory('utilsService', function () {
|
||||||
|
return chrome.extension.getBackgroundPage().utilsService;
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
angular
|
angular
|
||||||
.module('bit.settings')
|
.module('bit.settings')
|
||||||
|
|
||||||
.controller('settingsController', function ($scope, loginService, $state, syncService, SweetAlert) {
|
.controller('settingsController', function ($scope, loginService, $state, syncService, SweetAlert, utilsService) {
|
||||||
$scope.sync = function () {
|
$scope.sync = function () {
|
||||||
syncService.fullSync(function () {
|
syncService.fullSync(function () {
|
||||||
alert('Sync done!');
|
alert('Sync done!');
|
||||||
@ -65,7 +65,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.rate = function () {
|
$scope.rate = function () {
|
||||||
// TODO: detect which extension store to send them to
|
switch (utilsService.getBrowser()) {
|
||||||
chrome.tabs.create({ url: 'https://google.com' });
|
case 'chrome':
|
||||||
|
chrome.tabs.create({ url: 'https://chrome.com' });
|
||||||
|
break;
|
||||||
|
case 'firefox':
|
||||||
|
chrome.tabs.create({ url: 'https://firefox.com' });
|
||||||
|
break;
|
||||||
|
case 'edge':
|
||||||
|
chrome.tabs.create({ url: 'https://microsoft.com' });
|
||||||
|
break;
|
||||||
|
case 'opera':
|
||||||
|
chrome.tabs.create({ url: 'https://opera.com' });
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
22
src/services/utilsService.js
Normal file
22
src/services/utilsService.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
function UtilsService() {
|
||||||
|
initUtilsService();
|
||||||
|
};
|
||||||
|
|
||||||
|
function initUtilsService() {
|
||||||
|
UtilsService.prototype.getBrowser = function () {
|
||||||
|
if (navigator.userAgent.indexOf("Firefox") !== -1 || navigator.userAgent.indexOf("Gecko/") !== -1) {
|
||||||
|
return 'firefox';
|
||||||
|
}
|
||||||
|
if ((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
|
||||||
|
return 'opera';
|
||||||
|
}
|
||||||
|
if (navigator.userAgent.indexOf(" Edge/") !== -1) {
|
||||||
|
return 'edge';
|
||||||
|
}
|
||||||
|
if (window.chrome) {
|
||||||
|
return 'chrome';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user