diff --git a/src/popup/app/components/iconComponent.js b/src/popup/app/components/iconComponent.js
index 837314e7b24..48b6f9c101c 100644
--- a/src/popup/app/components/iconComponent.js
+++ b/src/popup/app/components/iconComponent.js
@@ -3,25 +3,76 @@ angular
.component('icon', {
bindings: {
- uri: '<'
+ cipher: '<'
},
- template: '
',
- controller: function (stateService) {
- this.$onInit = (function () {
- this.enabled = function () {
- return stateService.getState('faviconEnabled');
- };
- }).bind(this);
+ template: '' +
+ '

' +
+ '
' +
+ '
',
+ controller: function (stateService, constantsService) {
+ var ctrl = this;
- this.$onChanges = (function () {
- var hostname;
- try {
- hostname = new URL(this.uri).hostname;
- this.url = 'https://icons.bitwarden.com/' + hostname + '/icon.png';
- } catch (e) {
- // Invalid URL.
- this.url = chrome.extension.getURL('images/fa-globe.png');
+ ctrl.$onInit = function () {
+ ctrl.enabled = stateService.getState('faviconEnabled');
+ 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;
+ }
}
- }).bind(this);
+ };
+
+ ctrl.$onChanges = function () {
+ if (ctrl.cipher.type === constantsService.cipherType.login) {
+ setLoginIcon(ctrl.cipher);
+ }
+ };
+
+ function setLoginIcon() {
+ if (ctrl.cipher.login.uri) {
+ var hostnameUri = ctrl.cipher.login.uri,
+ isWebsite = false;
+
+ if (hostnameUri.indexOf('androidapp://') === 0) {
+ ctrl.icon = 'fa-android';
+ }
+ else if (hostnameUri.indexOf('iosapp://') === 0) {
+ ctrl.icon = 'fa-apple';
+ }
+ else if (hostnameUri.indexOf('://') === -1 && hostnameUri.indexOf('http://') !== 0 &&
+ hostnameUri.indexOf('https://') !== 0) {
+ hostnameUri = "http://" + hostnameUri;
+ isWebsite = true;
+ }
+ else {
+ isWebsite = hostnameUri.indexOf('http') === 0 && hostnameUri.indexOf('.') > 0;
+ }
+
+ if (isWebsite) {
+ try {
+ var url = new URL(hostnameUri);
+ ctrl.image = 'https://icons.bitwarden.com/' + url.hostname + '/icon.png';
+ ctrl.fallbackImage = chrome.extension.getURL('images/fa-globe.png');
+ }
+ catch (e) { }
+ }
+ }
+
+ if (!ctrl.icon) {
+ ctrl.icon = 'fa-globe';
+ }
+ }
}
});
diff --git a/src/popup/app/directives/fallbackSrcDirective.js b/src/popup/app/directives/fallbackSrcDirective.js
new file mode 100644
index 00000000000..ac93c191458
--- /dev/null
+++ b/src/popup/app/directives/fallbackSrcDirective.js
@@ -0,0 +1,11 @@
+angular
+ .module('bit.directives')
+
+ .directive('fallbackSrc', function () {
+ return function (scope, element, attrs) {
+ var el = $(element);
+ el.bind('error', function (event) {
+ el.attr('src', attrs.fallbackSrc);
+ });
+ };
+ });
diff --git a/src/popup/app/vault/views/vault.html b/src/popup/app/vault/views/vault.html
index 6c7b0b09d0d..f5ef2208c68 100644
--- a/src/popup/app/vault/views/vault.html
+++ b/src/popup/app/vault/views/vault.html
@@ -55,7 +55,7 @@
ng-class="{'disabled': !cipher.uri}">
-
+
{{cipher.name}}
@@ -88,7 +88,7 @@
ng-class="{'disabled': !cipher.uri}">
-
+
{{cipher.name}}
diff --git a/src/popup/index.html b/src/popup/index.html
index 738543005a5..9d4337520ae 100644
--- a/src/popup/index.html
+++ b/src/popup/index.html
@@ -58,6 +58,7 @@
+
diff --git a/src/popup/less/components.less b/src/popup/less/components.less
index ee9d6b9b59f..8edc078c446 100644
--- a/src/popup/less/components.less
+++ b/src/popup/less/components.less
@@ -357,6 +357,7 @@
height: 36px;
width: 34px;
margin-left: -5px;
+ color: @text-muted;
img {
border-radius: 3px;