diff --git a/src/popup/app/components/iconComponent.js b/src/popup/app/components/iconComponent.js
index d4ae16b9bff..ef7b6d50eea 100644
--- a/src/popup/app/components/iconComponent.js
+++ b/src/popup/app/components/iconComponent.js
@@ -5,32 +5,28 @@ angular
bindings: {
cipher: '<'
},
- template: '
' +
- '
![]()
' +
- '
' +
- '
',
+ templateUrl: 'app/components/views/icon.html',
controller: function (stateService, constantsService) {
var ctrl = this;
- ctrl.enabled = stateService.getState('faviconEnabled');
+ ctrl.imageEnabled = stateService.getState('faviconEnabled');
ctrl.$onChanges = function () {
- if (ctrl.enabled) {
- switch (ctrl.cipher.type) {
- case constantsService.cipherType.login:
- setLoginIcon(ctrl.cipher);
- break;
- case constantsService.cipherType.secureNote:
- ctrl.icon = 'fa-sticky-note-o';
- break;
- case constantsService.cipherType.card:
- ctrl.icon = 'fa-credit-card';
- break;
- case constantsService.cipherType.identity:
- ctrl.icon = 'fa-id-card-o';
- break;
- default:
- break;
- }
+ switch (ctrl.cipher.type) {
+ case constantsService.cipherType.login:
+ ctrl.icon = 'fa-globe';
+ setLoginIcon(ctrl.cipher);
+ break;
+ case constantsService.cipherType.secureNote:
+ ctrl.icon = 'fa-sticky-note-o';
+ break;
+ case constantsService.cipherType.card:
+ ctrl.icon = 'fa-credit-card';
+ break;
+ case constantsService.cipherType.identity:
+ ctrl.icon = 'fa-id-card-o';
+ break;
+ default:
+ break;
}
};
@@ -47,18 +43,16 @@ angular
ctrl.icon = 'fa-apple';
ctrl.image = null;
}
- else if (hostnameUri.indexOf('://') === -1 && hostnameUri.indexOf('http://') !== 0 &&
+ else if (ctrl.imageEnabled && hostnameUri.indexOf('://') === -1 && hostnameUri.indexOf('http://') !== 0 &&
hostnameUri.indexOf('https://') !== 0) {
hostnameUri = "http://" + hostnameUri;
isWebsite = true;
- ctrl.icon = 'fa-globe';
}
- else {
+ else if (ctrl.imageEnabled) {
isWebsite = hostnameUri.indexOf('http') === 0 && hostnameUri.indexOf('.') > 0;
- ctrl.icon = 'fa-globe';
}
- if (isWebsite) {
+ if (ctrl.imageEnabled && isWebsite) {
try {
var url = new URL(hostnameUri);
ctrl.image = 'https://icons.bitwarden.com/' + url.hostname + '/icon.png';
@@ -68,7 +62,6 @@ angular
}
}
else {
- ctrl.icon = 'fa-globe';
ctrl.image = null;
}
}
diff --git a/src/popup/app/components/views/icon.html b/src/popup/app/components/views/icon.html
new file mode 100644
index 00000000000..4fba1ccccb4
--- /dev/null
+++ b/src/popup/app/components/views/icon.html
@@ -0,0 +1,4 @@
+
+
![]()
+
+
diff --git a/src/popup/app/config.js b/src/popup/app/config.js
index cf69c05ff7f..50c9178be8f 100644
--- a/src/popup/app/config.js
+++ b/src/popup/app/config.js
@@ -2,7 +2,8 @@
.module('bit')
.config(function ($stateProvider, $urlRouterProvider, $compileProvider, $sceDelegateProvider, toastrConfig) {
- $compileProvider.imgSrcSanitizationWhitelist(/^\s*((https?|ftp|file|blob):|data:image\/|(moz|chrome|ms-browser)-extension)/);
+ $compileProvider.imgSrcSanitizationWhitelist(
+ /^\s*((https?|ftp|file|blob):|data:image\/|(moz|chrome|ms-browser)-extension)/);
angular.extend(toastrConfig, {
closeButton: true,
@@ -258,9 +259,7 @@
});
})
.run(function ($rootScope, userService, $state, constantsService, stateService) {
- chrome.storage.local.get(constantsService.disableFaviconKey, function(obj) {
- stateService.saveState('faviconEnabled', !obj[constantsService.disableFaviconKey]);
- });
+ stateService.init();
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
if ($state.current.name.indexOf('tabs.') > -1 && toState.name.indexOf('tabs.') > -1) {
diff --git a/src/popup/app/services/stateService.js b/src/popup/app/services/stateService.js
index 58b11a1c575..8385faf2676 100644
--- a/src/popup/app/services/stateService.js
+++ b/src/popup/app/services/stateService.js
@@ -1,10 +1,16 @@
angular
.module('bit.services')
- .factory('stateService', function () {
+ .factory('stateService', function (utilsService, constantsService) {
var _service = {},
_state = {};
+ _service.init = function () {
+ utilsService.getObjFromStorage(constantsService.disableFaviconKey).then(function (disabledFavicons) {
+ _service.saveState('faviconEnabled', !disabledFavicons);
+ });
+ };
+
_service.saveState = function (key, data) {
_state[key] = data;
};