Blob Blame Raw
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index 41a7169a2..928add0bf 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -132,10 +132,27 @@ NotificationDaemon.prototype = {
             Lang.bind(this, this._onFocusAppChanged));
     },
 
+    _textureFromString: function(cache, icon_string, size) {
+        if (icon_string.substr(0, 7) == 'file://')
+            return cache.load_uri_async(icon_string, size, size);
+        else if (icon_string[0] == '/') {
+            let uri = GLib.filename_to_uri(icon_string, null);
+            return cache.load_uri_async(uri, size, size);
+        } else {
+            let icon_type = St.IconType.FULLCOLOR;
+            if (icon_string.search("-symbolic") != -1)
+                icon_type = St.IconType.SYMBOLIC;
+            return new St.Icon({ icon_name: icon_string,
+                                 icon_type: icon_type,
+                                 icon_size: size });
+        }
+
+        return null;
+    },
+
    // Create an icon for a notification from icon string/path.
     _iconForNotificationData: function(icon, hints, size) {
         let textureCache = St.TextureCache.get_default();
-
         // If an icon is not specified, we use 'image-data' or 'image-path' hint for an icon
         // and don't show a large image. There are currently many applications that use
         // notify_notification_set_icon_from_pixbuf() from libnotify, which in turn sets
@@ -145,25 +162,13 @@ NotificationDaemon.prototype = {
         // one of 'image-data' or 'image-path' are specified, we show both an icon and
         // a large image.
         if (icon) {
-            if (icon.substr(0, 7) == 'file://')
-                return textureCache.load_uri_async(icon, size, size);
-            else if (icon[0] == '/') {
-                let uri = GLib.filename_to_uri(icon, null);
-                return textureCache.load_uri_async(uri, size, size);
-            } else {
-                let icon_type = St.IconType.FULLCOLOR;
-                if (icon.search("-symbolic") != -1)
-                    icon_type = St.IconType.SYMBOLIC;
-                return new St.Icon({ icon_name: icon,
-                                     icon_type: icon_type,
-                                     icon_size: size });
-            }
+            return this._textureFromString(textureCache, icon, size);
         } else if (hints['image-data']) {
             let [width, height, rowStride, hasAlpha,
                  bitsPerSample, nChannels, data] = hints['image-data'];
             return textureCache.load_from_raw(data, hasAlpha, width, height, rowStride, size);
         } else if (hints['image-path']) {
-            return textureCache.load_uri_async(GLib.filename_to_uri(hints['image-path'], null), size, size);
+            return this._textureFromString(textureCache, hints['image-path'], size);
         } else {
             let stockIcon;
             switch (hints.urgency) {
@@ -459,9 +464,7 @@ NotificationDaemon.prototype = {
                 image = St.TextureCache.get_default().load_from_raw(data, hasAlpha,
                                                                     width, height, rowStride, notification.IMAGE_SIZE);
             } else if (hints['image-path']) {
-                image = St.TextureCache.get_default().load_uri_async(GLib.filename_to_uri(hints['image-path'], null),
-                                                                     notification.IMAGE_SIZE,
-                                                                     notification.IMAGE_SIZE);
+                image = this._textureFromString(St.TextureCache.get_default(), hints['image-path'], notification.IMAGE_SIZE);
             }
             notification.setImage(image);
         } else {