diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 391d961c..54f33e00 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -747,5 +747,8 @@
},
"commandGeneratePasswordDesc": {
"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."
}
}
diff --git a/src/popup/app/config.js b/src/popup/app/config.js
index 1f0b5dbf..6fc24b0e 100644
--- a/src/popup/app/config.js
+++ b/src/popup/app/config.js
@@ -11,6 +11,12 @@
$urlRouterProvider.otherwise(function ($injector, $location) {
var $state = $injector.get('$state');
+
+ if (!chrome.extension.getBackgroundPage()) {
+ $state.go('privateMode');
+ return;
+ }
+
var userService = $injector.get('userService');
var cryptoService = $injector.get('cryptoService');
@@ -34,14 +40,21 @@
$stateProvider
.state('splash', {
url: '/splash',
- controller: 'splashController',
+ controller: 'baseController',
templateUrl: 'app/global/splash.html',
data: { authorize: false },
params: { animation: null }
})
+ .state('privateMode', {
+ url: '/private-mode',
+ controller: 'privateModeController',
+ templateUrl: 'app/global/privateMode.html',
+ data: { authorize: false },
+ params: { animation: null }
+ })
.state('home', {
url: '/home',
- controller: 'homeController',
+ controller: 'baseController',
templateUrl: 'app/global/home.html',
data: { authorize: false },
params: { animation: null }
@@ -248,6 +261,10 @@
stateService.purgeState();
}
+ if (!userService) {
+ return;
+ }
+
userService.isAuthenticated(function (isAuthenticated) {
if (isAuthenticated) {
var obj = {};
diff --git a/src/popup/app/global/homeController.js b/src/popup/app/global/baseController.js
similarity index 56%
rename from src/popup/app/global/homeController.js
rename to src/popup/app/global/baseController.js
index f9f2d6c7..5eb980ad 100644
--- a/src/popup/app/global/homeController.js
+++ b/src/popup/app/global/baseController.js
@@ -1,6 +1,6 @@
angular
.module('bit.global')
- .controller('homeController', function ($scope, i18nService) {
+ .controller('baseController', function ($scope, i18nService) {
$scope.i18n = i18nService;
});
diff --git a/src/popup/app/global/mainController.js b/src/popup/app/global/mainController.js
index 1f85b7b6..315534b7 100644
--- a/src/popup/app/global/mainController.js
+++ b/src/popup/app/global/mainController.js
@@ -7,7 +7,7 @@ angular
self.currentYear = new Date().getFullYear();
self.animation = '';
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) {
if (toParams.animation) {
diff --git a/src/popup/app/global/privateMode.html b/src/popup/app/global/privateMode.html
new file mode 100644
index 00000000..096b9282
--- /dev/null
+++ b/src/popup/app/global/privateMode.html
@@ -0,0 +1,6 @@
+
+
{{privateModeMessage}}
+
+
diff --git a/src/popup/app/global/privateModeController.js b/src/popup/app/global/privateModeController.js
new file mode 100644
index 00000000..395000ea
--- /dev/null
+++ b/src/popup/app/global/privateModeController.js
@@ -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/' });
+ };
+ });
diff --git a/src/popup/app/global/splashController.js b/src/popup/app/global/splashController.js
deleted file mode 100644
index e8cf550e..00000000
--- a/src/popup/app/global/splashController.js
+++ /dev/null
@@ -1,6 +0,0 @@
-angular
- .module('bit.global')
-
- .controller('splashController', function ($scope) {
-
- });
diff --git a/src/popup/app/services/backgroundService.js b/src/popup/app/services/backgroundService.js
index 06a10342..766f76fd 100644
--- a/src/popup/app/services/backgroundService.js
+++ b/src/popup/app/services/backgroundService.js
@@ -2,53 +2,70 @@
.module('bit.services')
.factory('tokenService', function () {
- return chrome.extension.getBackgroundPage().bg_tokenService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_tokenService : null;
})
.factory('cryptoService', function () {
- return chrome.extension.getBackgroundPage().bg_cryptoService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_cryptoService : null;
})
.factory('userService', function () {
- return chrome.extension.getBackgroundPage().bg_userService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_userService : null;
})
.factory('apiService', function () {
- return chrome.extension.getBackgroundPage().bg_apiService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_apiService : null;
})
.factory('folderService', function () {
- return chrome.extension.getBackgroundPage().bg_folderService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_folderService : null;
})
.factory('loginService', function () {
- return chrome.extension.getBackgroundPage().bg_loginService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_loginService : null;
})
.factory('syncService', function () {
- return chrome.extension.getBackgroundPage().bg_syncService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_syncService : null;
})
.factory('autofillService', function () {
- return chrome.extension.getBackgroundPage().bg_autofillService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_autofillService : null;
})
.factory('passwordGenerationService', function () {
- return chrome.extension.getBackgroundPage().bg_passwordGenerationService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_passwordGenerationService : null;
})
.factory('utilsService', function () {
- return chrome.extension.getBackgroundPage().bg_utilsService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_utilsService : null;
})
.factory('appIdService', function () {
- return chrome.extension.getBackgroundPage().bg_appIdService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_appIdService : null;
})
.factory('i18nService', function () {
- return chrome.extension.getBackgroundPage().bg_i18nService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_i18nService : null;
})
.factory('constantsService', function () {
- return chrome.extension.getBackgroundPage().bg_constantsService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_constantsService : null;
})
.factory('settingsService', function () {
- return chrome.extension.getBackgroundPage().bg_settingsService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_settingsService : null;
})
.factory('lockService', function () {
- return chrome.extension.getBackgroundPage().bg_lockService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_lockService : null;
})
.factory('totpService', function () {
- return chrome.extension.getBackgroundPage().bg_totpService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_totpService : null;
})
.factory('environmentService', function () {
- return chrome.extension.getBackgroundPage().bg_environmentService;
+ var page = chrome.extension.getBackgroundPage();
+ return page ? page.bg_environmentService : null;
});
diff --git a/src/popup/index.html b/src/popup/index.html
index e867ccdf..2a297766 100644
--- a/src/popup/index.html
+++ b/src/popup/index.html
@@ -53,8 +53,8 @@
-
-
+
+
diff --git a/src/scripts/analytics.js b/src/scripts/analytics.js
index c3bbc6fc..4d700aca 100644
--- a/src/scripts/analytics.js
+++ b/src/scripts/analytics.js
@@ -1,60 +1,67 @@
-var gaTrackingId = chrome.extension.getBackgroundPage().bg_utilsService.analyticsId();
-var gaFunc = null;
-var isFirefox = chrome.extension.getBackgroundPage().bg_utilsService.isFirefox();
-
-window.GoogleAnalyticsObject = 'ga';
-window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3, param4) {
- if (!gaFunc) {
+(function () {
+ var bgPage = chrome.extension.getBackgroundPage();
+ if (!bgPage) {
return;
}
- chrome.storage.local.get('disableGa', function (obj) {
- // Default for Firefox is disabled.
- if ((isFirefox && obj.disableGa === undefined) || obj.disableGa) {
+ var gaTrackingId = bgPage.bg_utilsService.analyticsId();
+ var gaFunc = null;
+ var isFirefox = bgPage.bg_utilsService.isFirefox();
+
+ window.GoogleAnalyticsObject = 'ga';
+ window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3, param4) {
+ if (!gaFunc) {
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) {
- 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);
+ gaFunc(action, param1, param2, param3, param4);
+ });
};
- if (typeof bg_isBackground !== 'undefined') {
- ga('send', 'pageview', '/background.html');
+ function gaTrackEvent(options) {
+ 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');
+ }
+ });
+})();