       # Aw snap! Notify the user via `callback`.
       log.error error
       callback?(
-        message:   i18n.get 'shortener_error', name
-        shortener: name
+        message:   i18n.get 'shortener_error', title
+        shortener: title
         success:   no
       )
 

      $('#loadDiv', popup.document).hide()
      $('#item', popup.document).show()

# Update the context menu items to reflect the currently enabled templates.  
# If the context menu option has been disabled by the user, just remove all of
# the existing menu items.
updateContextMenu = ->
  # Ensure that any previously added context menu items are removed.
  chrome.contextMenus.removeAll ->
    # Called whenever a menu item is clicked.  
    # Send a self request, passing along the available information.
    onMenuClick = (info, tab) ->
      onRequest
        data: info
        type: 'menu'
    if store.get 'contextMenu'
      # Create and add the top-level Template menu.
      parentId = chrome.contextMenus.create
        contexts: ['all']
        title:    i18n.get 'name'
      # Create and add a sub-menu item for each enabled template.
      for template in ext.templates when template.enabled
        menuId = chrome.contextMenus.create
          contexts: ['all']
          onclick:  onMenuClick
          parentId: parentId
          title:    template.title
        template.menuId = menuId

# Update the statistical information.
updateStatistics = ->
  store.modify 'stats', (stats) =>
    # Determine which template has the greatest usage.
    maxUsage = 0

    @templates.sort (a, b) ->
      a.index - b.index
    buildPopup()
    @updateContextMenu()
    updateStatistics()

  # Update the toolbar/browser action depending on the current settings.
