1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 const Cu = Components.utils;
6 const Cc = Components.classes;
7 const Ci = Components.interfaces;
9 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
10 Cu.import("resource://gre/modules/UserAgentOverrides.jsm");
12 const HTTP_PROTO_HANDLER = Cc["@mozilla.org/network/protocol;1?name=http"]
13 .getService(Ci.nsIHttpProtocolHandler);
15 function SiteSpecificUserAgent() {}
17 SiteSpecificUserAgent.prototype = {
18 getUserAgentForURIAndWindow: function ssua_getUserAgentForURIAndWindow(aURI, aWindow) {
19 return UserAgentOverrides.getOverrideForURI(aURI) || HTTP_PROTO_HANDLER.userAgent;
22 classID: Components.ID("{506c680f-3d1c-4954-b351-2c80afbc37d3}"),
23 QueryInterface: XPCOMUtils.generateQI([Ci.nsISiteSpecificUserAgent])
26 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SiteSpecificUserAgent]);