~ubuntu-branches/ubuntu/quantal/ubufox/quantal-security

« back to all changes in this revision

Viewing changes to components/aboutStartpage.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-06-27 20:37:53 UTC
  • mfrom: (1.1.33)
  • Revision ID: package-import@ubuntu.com-20120627203753-h33vgglw1fiozx7t
Tags: 2.1-0ubuntu1
* New upstream release.
  - Drop the alternative plugin selector, as it depends on a patch that
    we no longer carry in Firefox
* Drop the lsb-release build-depend now, as we don't hardcode distro
  information in the build now

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 * the terms of any one of the MPL, the GPL or the LGPL.
36
36
 *
37
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
38
39
const Cc = Components.classes;
39
40
const Ci = Components.interfaces;
40
41
 
41
42
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
42
43
Components.utils.import("resource://gre/modules/Services.jsm");
43
 
 
44
 
var HOMEPAGE_PREFIX = "http://start.ubuntu.com/";
45
 
var HOMEPAGE_GOOGLE_QUERY = "sourceid=hp";
46
 
 
47
 
function getCurrentSearchEngineParams() {
48
 
  try {
49
 
    if (Services.search.currentEngine.searchForm.indexOf("search.yahoo.com")
50
 
        != -1) {
51
 
      return {"name": "Yahoo", "query": null};
52
 
    } else {
53
 
      return {"name": "Google", "query": HOMEPAGE_GOOGLE_QUERY};
54
 
    }
55
 
  } catch(e) { return {"name": "Google", "query": HOMEPAGE_GOOGLE_QUERY}; }
56
 
}
 
44
Components.utils.import("resource://ubufox/Distro.jsm");
57
45
 
58
46
function AboutStartpage() {}
59
47
AboutStartpage.prototype = {
72
60
                 getService(Ci.nsIScriptSecurityManager);
73
61
    let principal = secMan.getCodebasePrincipal(aURI);
74
62
 
75
 
    let params = getCurrentSearchEngineParams();
76
 
    let release = Services.prefs.getCharPref("extensions.ubufox.release");
77
 
 
78
63
    let uri;
79
64
    // allow defaults packages to overwrite the homepage
80
65
    try {
81
 
      uri = Services.prefs.getCharPref("extensions.ubufox@ubuntu.com.custom_homepage");
 
66
      uri = Services.io.newURI(Services.prefs.getCharPref("extensions.ubufox@ubuntu.com.custom_homepage"),
 
67
                               null, null);
82
68
    } catch(e) {
83
 
      uri = HOMEPAGE_PREFIX + release + "/" + params.name + "/";
84
 
      if (params.query != null) {
85
 
        uri += "?" + params.query;
86
 
      }
 
69
      uri = distro.startpageURI;
87
70
    }
88
71
 
89
 
    let channel = Services.io.newChannel(uri, null, null);
 
72
    let channel = Services.io.newChannelFromURI(uri);
90
73
    channel.originalURI = aURI;
91
74
    channel.owner = principal;
92
75
 
94
77
  }
95
78
};
96
79
 
97
 
function NSGetModule(compMgr, fileSpec) {
98
 
  return XPCOMUtils.generateModule([AboutStartpage]);
99
 
}
100
 
 
101
 
if (typeof XPCOMUtils.generateNSGetFactory == "function") {
102
 
  const NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutStartpage]);
103
 
}
 
80
const NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutStartpage]);