1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-02 08:30:14 +01:00

private mode page with message

This commit is contained in:
Kyle Spearrin 2017-09-09 15:41:49 -04:00
parent ac00d1f106
commit 60d75ce5fe
10 changed files with 133 additions and 79 deletions

View File

@ -747,5 +747,8 @@
}, },
"commandGeneratePasswordDesc": { "commandGeneratePasswordDesc": {
"message": "Generate and copy a new random password to the clipboard." "message": "Generate and copy a new random password to the clipboard."
},
"privateModeMessage": {
"message": "Unfortunately this window is not available in private mode for this browser."
} }
} }

View File

@ -11,6 +11,12 @@
$urlRouterProvider.otherwise(function ($injector, $location) { $urlRouterProvider.otherwise(function ($injector, $location) {
var $state = $injector.get('$state'); var $state = $injector.get('$state');
if (!chrome.extension.getBackgroundPage()) {
$state.go('privateMode');
return;
}
var userService = $injector.get('userService'); var userService = $injector.get('userService');
var cryptoService = $injector.get('cryptoService'); var cryptoService = $injector.get('cryptoService');
@ -34,14 +40,21 @@
$stateProvider $stateProvider
.state('splash', { .state('splash', {
url: '/splash', url: '/splash',
controller: 'splashController', controller: 'baseController',
templateUrl: 'app/global/splash.html', templateUrl: 'app/global/splash.html',
data: { authorize: false }, data: { authorize: false },
params: { animation: null } params: { animation: null }
}) })
.state('privateMode', {
url: '/private-mode',
controller: 'privateModeController',
templateUrl: 'app/global/privateMode.html',
data: { authorize: false },
params: { animation: null }
})
.state('home', { .state('home', {
url: '/home', url: '/home',
controller: 'homeController', controller: 'baseController',
templateUrl: 'app/global/home.html', templateUrl: 'app/global/home.html',
data: { authorize: false }, data: { authorize: false },
params: { animation: null } params: { animation: null }
@ -248,6 +261,10 @@
stateService.purgeState(); stateService.purgeState();
} }
if (!userService) {
return;
}
userService.isAuthenticated(function (isAuthenticated) { userService.isAuthenticated(function (isAuthenticated) {
if (isAuthenticated) { if (isAuthenticated) {
var obj = {}; var obj = {};

View File

@ -1,6 +1,6 @@
angular angular
.module('bit.global') .module('bit.global')
.controller('homeController', function ($scope, i18nService) { .controller('baseController', function ($scope, i18nService) {
$scope.i18n = i18nService; $scope.i18n = i18nService;
}); });

View File

@ -7,7 +7,7 @@ angular
self.currentYear = new Date().getFullYear(); self.currentYear = new Date().getFullYear();
self.animation = ''; self.animation = '';
self.shBody = $window.screen.availHeight <= 800; self.shBody = $window.screen.availHeight <= 800;
self.lgBody = !utilsService.isFirefox() && !utilsService.isEdge() && !self.shBody; self.lgBody = utilsService && !utilsService.isFirefox() && !utilsService.isEdge() && !self.shBody;
$scope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) { $scope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
if (toParams.animation) { if (toParams.animation) {

View File

@ -0,0 +1,6 @@
<div class="content text-center">
<p>{{privateModeMessage}}</p>
<button type="button" class="btn btn-lg btn-link btn-block" ng-click="learnMore()">
{{learnMoreMessage}}
</button>
</div>

View File

@ -0,0 +1,10 @@
angular
.module('bit.global')
.controller('privateModeController', function ($scope) {
$scope.privateModeMessage = chrome.i18n.getMessage("privateModeMessage");
$scope.learnMoreMessage = chrome.i18n.getMessage("learnMore");
$scope.learnMore = function () {
chrome.tabs.create({ url: 'https://help.bitwarden.com/article/extension-wont-load-in-private-mode/' });
};
});

View File

@ -1,6 +0,0 @@
angular
.module('bit.global')
.controller('splashController', function ($scope) {
});

View File

@ -2,53 +2,70 @@
.module('bit.services') .module('bit.services')
.factory('tokenService', function () { .factory('tokenService', function () {
return chrome.extension.getBackgroundPage().bg_tokenService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_tokenService : null;
}) })
.factory('cryptoService', function () { .factory('cryptoService', function () {
return chrome.extension.getBackgroundPage().bg_cryptoService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_cryptoService : null;
}) })
.factory('userService', function () { .factory('userService', function () {
return chrome.extension.getBackgroundPage().bg_userService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_userService : null;
}) })
.factory('apiService', function () { .factory('apiService', function () {
return chrome.extension.getBackgroundPage().bg_apiService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_apiService : null;
}) })
.factory('folderService', function () { .factory('folderService', function () {
return chrome.extension.getBackgroundPage().bg_folderService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_folderService : null;
}) })
.factory('loginService', function () { .factory('loginService', function () {
return chrome.extension.getBackgroundPage().bg_loginService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_loginService : null;
}) })
.factory('syncService', function () { .factory('syncService', function () {
return chrome.extension.getBackgroundPage().bg_syncService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_syncService : null;
}) })
.factory('autofillService', function () { .factory('autofillService', function () {
return chrome.extension.getBackgroundPage().bg_autofillService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_autofillService : null;
}) })
.factory('passwordGenerationService', function () { .factory('passwordGenerationService', function () {
return chrome.extension.getBackgroundPage().bg_passwordGenerationService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_passwordGenerationService : null;
}) })
.factory('utilsService', function () { .factory('utilsService', function () {
return chrome.extension.getBackgroundPage().bg_utilsService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_utilsService : null;
}) })
.factory('appIdService', function () { .factory('appIdService', function () {
return chrome.extension.getBackgroundPage().bg_appIdService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_appIdService : null;
}) })
.factory('i18nService', function () { .factory('i18nService', function () {
return chrome.extension.getBackgroundPage().bg_i18nService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_i18nService : null;
}) })
.factory('constantsService', function () { .factory('constantsService', function () {
return chrome.extension.getBackgroundPage().bg_constantsService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_constantsService : null;
}) })
.factory('settingsService', function () { .factory('settingsService', function () {
return chrome.extension.getBackgroundPage().bg_settingsService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_settingsService : null;
}) })
.factory('lockService', function () { .factory('lockService', function () {
return chrome.extension.getBackgroundPage().bg_lockService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_lockService : null;
}) })
.factory('totpService', function () { .factory('totpService', function () {
return chrome.extension.getBackgroundPage().bg_totpService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_totpService : null;
}) })
.factory('environmentService', function () { .factory('environmentService', function () {
return chrome.extension.getBackgroundPage().bg_environmentService; var page = chrome.extension.getBackgroundPage();
return page ? page.bg_environmentService : null;
}); });

View File

@ -53,8 +53,8 @@
<script src="app/global/globalModule.js"></script> <script src="app/global/globalModule.js"></script>
<script src="app/global/mainController.js"></script> <script src="app/global/mainController.js"></script>
<script src="app/global/tabsController.js"></script> <script src="app/global/tabsController.js"></script>
<script src="app/global/splashController.js"></script> <script src="app/global/baseController.js"></script>
<script src="app/global/homeController.js"></script> <script src="app/global/privateModeController.js"></script>
<script src="app/accounts/accountsModule.js"></script> <script src="app/accounts/accountsModule.js"></script>
<script src="app/accounts/accountsLoginController.js"></script> <script src="app/accounts/accountsLoginController.js"></script>

View File

@ -1,60 +1,67 @@
var gaTrackingId = chrome.extension.getBackgroundPage().bg_utilsService.analyticsId(); (function () {
var gaFunc = null; var bgPage = chrome.extension.getBackgroundPage();
var isFirefox = chrome.extension.getBackgroundPage().bg_utilsService.isFirefox(); if (!bgPage) {
window.GoogleAnalyticsObject = 'ga';
window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3, param4) {
if (!gaFunc) {
return; return;
} }
chrome.storage.local.get('disableGa', function (obj) { var gaTrackingId = bgPage.bg_utilsService.analyticsId();
// Default for Firefox is disabled. var gaFunc = null;
if ((isFirefox && obj.disableGa === undefined) || obj.disableGa) { var isFirefox = bgPage.bg_utilsService.isFirefox();
window.GoogleAnalyticsObject = 'ga';
window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3, param4) {
if (!gaFunc) {
return; return;
} }
gaFunc(action, param1, param2, param3, param4); chrome.storage.local.get('disableGa', function (obj) {
}); // Default for Firefox is disabled.
}; if ((isFirefox && obj.disableGa === undefined) || obj.disableGa) {
return;
}
function gaTrackEvent(options) { gaFunc(action, param1, param2, param3, param4);
return '&t=event&ec=' + (options.eventCategory ? encodeURIComponent(options.eventCategory) : 'Event') + });
'&ea=' + encodeURIComponent(options.eventAction) +
(options.eventLabel ? '&el=' + encodeURIComponent(options.eventLabel) : '') +
(options.eventValue ? '&ev=' + encodeURIComponent(options.eventValue) : '') +
(options.page ? '&dp=' + encodeURIComponent(options.page) : '');
}
function gaTrackPageView(pagePath) {
return '&t=pageview&dp=' + encodeURIComponent(pagePath);
}
chrome.extension.getBackgroundPage().bg_appIdService.getAnonymousAppId(function (gaAnonAppId) {
gaFunc = function (action, param1, param2, param3, param4) {
if (action !== 'send' || !param1) {
return;
}
var version = encodeURIComponent(chrome.runtime.getManifest().version);
var message = 'v=1&tid=' + gaTrackingId + '&cid=' + gaAnonAppId + '&cd1=' + version;
if (param1 === 'pageview' && param2) {
message += gaTrackPageView(param2);
}
else if (param1 === 'event' && param2) {
message += gaTrackEvent(param2);
}
else if (typeof param1 === 'object' && param1.hitType === 'event') {
message += gaTrackEvent(param1);
}
var request = new XMLHttpRequest();
request.open('POST', 'https://www.google-analytics.com/collect', true);
request.send(message);
}; };
if (typeof bg_isBackground !== 'undefined') { function gaTrackEvent(options) {
ga('send', 'pageview', '/background.html'); return '&t=event&ec=' + (options.eventCategory ? encodeURIComponent(options.eventCategory) : 'Event') +
'&ea=' + encodeURIComponent(options.eventAction) +
(options.eventLabel ? '&el=' + encodeURIComponent(options.eventLabel) : '') +
(options.eventValue ? '&ev=' + encodeURIComponent(options.eventValue) : '') +
(options.page ? '&dp=' + encodeURIComponent(options.page) : '');
} }
});
function gaTrackPageView(pagePath) {
return '&t=pageview&dp=' + encodeURIComponent(pagePath);
}
bgPage.bg_appIdService.getAnonymousAppId(function (gaAnonAppId) {
gaFunc = function (action, param1, param2, param3, param4) {
if (action !== 'send' || !param1) {
return;
}
var version = encodeURIComponent(chrome.runtime.getManifest().version);
var message = 'v=1&tid=' + gaTrackingId + '&cid=' + gaAnonAppId + '&cd1=' + version;
if (param1 === 'pageview' && param2) {
message += gaTrackPageView(param2);
}
else if (param1 === 'event' && param2) {
message += gaTrackEvent(param2);
}
else if (typeof param1 === 'object' && param1.hitType === 'event') {
message += gaTrackEvent(param1);
}
var request = new XMLHttpRequest();
request.open('POST', 'https://www.google-analytics.com/collect', true);
request.send(message);
};
if (typeof bg_isBackground !== 'undefined') {
ga('send', 'pageview', '/background.html');
}
});
})();