~ps-jenkins/unity-chromium-extension/trusty-proposed

« back to all changes in this revision

Viewing changes to chromium-extension/content/unity-favicon-utils.js

  • Committer: Tarmac
  • Author(s): Alexandre Abreu
  • Date: 2013-09-16 15:40:39 UTC
  • mfrom: (227.1.5 latest)
  • Revision ID: tarmac-20130916154039-oj5t4j3stjrog9sz
Release version 3.0
Remove tab integration
Keep webapps installation scheme
Keep website api injection but only handle the init() w/ a default desktop file generated to launch the webbrowser-app in chromeless mode
.

Approved by PS Jenkins bot, Robert Bruce Park.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
var UnityFaviconUtils = (function () {
2
 
  function findFaviconLink (document){
3
 
    var linkElements = document.getElementsByTagName("link");
4
 
    var i = 0;
5
 
    
6
 
    for (i = 0; i < linkElements.length; i++){
7
 
      var element = linkElements[i];
8
 
      
9
 
      if (element.hasAttribute("rel") &&
10
 
          (element.rel == "shortcut icon")) {
11
 
        var link = element.href;
12
 
        
13
 
        if (link[0] == "/") {
14
 
          return document.location + link;
15
 
        } else {
16
 
          return link;
17
 
        }
18
 
      }
19
 
    }
20
 
    
21
 
    return null;
22
 
  }
23
 
  
24
 
  UnityFaviconUtils = {
25
 
    getFaviconForDocument: function (document) {
26
 
      var favIcon = findFaviconLink (document);
27
 
      
28
 
      if (favIcon == null) {
29
 
        favIcon = "http://" + document.domain + "/favicon.ico";
30
 
      }
31
 
      
32
 
      return favIcon;
33
 
    }
34
 
  }
35
 
 
36
 
  return UnityFaviconUtils;
37
 
 
38
 
}) ();
39