~ubuntu-branches/ubuntu/raring/ubufox/raring-security

« back to all changes in this revision

Viewing changes to .pc/06_firefox-4.patch/content/pluginInstallerService.js

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2011-04-09 00:08:51 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20110409000851-5wd2d1p8cws3y3u8
Tags: 0.9-0ubuntu1
* New upstream release v0.9
* All patches are merged in to the upstream branch now

* Fix LP: #750305 - Please update links and configs for Natty release.
  Rather than doing this manually for every release, we add a dist.js with
  distro information (populated at build time with lsb_release) and just
  do all this automatically.
* Fix LP: #752364 - Plugin Finder Service never finds anything. Use the
  release info in dist.js to construct the URL, now that this got dropped
  from Firefox
* Fix LP: #728826 - Update icons to new versions.
* Drop the pluginGlue.js module. This didn't work, as we can no longer
  use a modules registerSelf method to use nsICategoryManager at startup,
  due to the XPCOM registration changes in Firefox 4. Instead, add
  category entries with the chrome.manifest
* Fix LP: #709125 - User agent doesn't include Ubuntu in it so
  apt.ubuntu.com doesn't work. We add an extra X-Ubuntu HTTP header in
  requests to apt.ubuntu.com, rather than send this information out in
  every request in the UA string

* Add build-depend on lsb-release so we can create dist.js

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ***** BEGIN LICENSE BLOCK *****
2
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
 
 *
4
 
 * The contents of this file are subject to the Mozilla Public License Version
5
 
 * 1.1 (the "License"); you may not use this file except in compliance with
6
 
 * the License. You may obtain a copy of the License at
7
 
 * http://www.mozilla.org/MPL/
8
 
 *
9
 
 * Software distributed under the License is distributed on an "AS IS" basis,
10
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
 
 * for the specific language governing rights and limitations under the
12
 
 * License.
13
 
 *
14
 
 * The Original Code is Plugin Finder Service.
15
 
 *
16
 
 * The Initial Developer of the Original Code is
17
 
 * IBM Corporation.
18
 
 * Portions created by the IBM Corporation are Copyright (C) 2004
19
 
 * IBM Corporation. All Rights Reserved.
20
 
 *
21
 
 * Contributor(s):
22
 
 *   Doron Rosenberg <doronr@us.ibm.com>
23
 
 *   Alexander Sack <asac@jwsdot.com> - Canonical Ltd.
24
 
 *
25
 
 * Alternatively, the contents of this file may be used under the terms of
26
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
27
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
29
 
 * of those above. If you wish to allow use of your version of this file only
30
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
31
 
 * use your version of this file under the terms of the MPL, indicate your
32
 
 * decision by deleting the provisions above and replace them with the notice
33
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
34
 
 * the provisions above, a recipient may use your version of this file under
35
 
 * the terms of any one of the MPL, the GPL or the LGPL.
36
 
 *
37
 
 * ***** END LICENSE BLOCK ***** */
38
 
 
39
 
var PluginXPIInstallService = {
40
 
  
41
 
  init: function () 
42
 
  {
43
 
  },
44
 
 
45
 
  pluginPidArray: null,
46
 
 
47
 
  startPluginInstallation: function (aPluginXPIUrlsArray,
48
 
                                     aPluginHashes,
49
 
                                     aPluginPidArray) {
50
 
     this.pluginPidArray = aPluginPidArray;
51
 
 
52
 
     var xpiManager = Components.classes["@mozilla.org/xpinstall/install-manager;1"]
53
 
                                .createInstance(Components.interfaces.nsIXPInstallManager);
54
 
     xpiManager.initManagerWithHashes(aPluginXPIUrlsArray, aPluginHashes,
55
 
                                      aPluginXPIUrlsArray.length, this);
56
 
  },
57
 
 
58
 
  // XPI progress listener stuff
59
 
  onStateChange: function (aIndex, aState, aValue)
60
 
  {
61
 
    // get the pid to return to the wizard
62
 
    var pid = this.pluginPidArray[aIndex];
63
 
    var errorMsg;
64
 
 
65
 
    if (aState == Components.interfaces.nsIXPIProgressDialog.INSTALL_DONE) {
66
 
      if (aValue != 0) {
67
 
        var xpinstallStrings = document.getElementById("xpinstallStrings");
68
 
        try {
69
 
          errorMsg = xpinstallStrings.getString("error" + aValue);
70
 
        }
71
 
        catch (e) {
72
 
          errorMsg = xpinstallStrings.getFormattedString("unknown.error", [aValue]);
73
 
        }
74
 
      }
75
 
    }
76
 
 
77
 
    gPluginInstaller.pluginXPIInstallationProgress(pid, aState, errorMsg);
78
 
 
79
 
  },
80
 
 
81
 
  onProgress: function (aIndex, aValue, aMaxValue)
82
 
  {
83
 
    // get the pid to return to the wizard
84
 
    var pid = this.pluginPidArray[aIndex];
85
 
 
86
 
    gPluginInstaller.pluginXPIInstallationProgressMeter(pid, aValue, aMaxValue);
87
 
  }
88
 
}
89
 
 
90
 
 
91
 
var AptInstaller = {
92
 
 
93
 
  mAptInstallerService: null,
94
 
  mAptUrlArray: null,
95
 
  mAptPidArray: null,
96
 
  mRunning: false,
97
 
 
98
 
  install: function(aAptUrlArray,
99
 
                    aAptPidArray,
100
 
                    aAptInstallerService) {
101
 
 
102
 
    this.mAptInstallerService = aAptInstallerService;
103
 
    this.mAptUrlArray = aAptUrlArray;
104
 
    this.mAptPidArray = aAptPidArray;
105
 
    this.mRunning = true;
106
 
 
107
 
    //    var thread = Components.classes["@mozilla.org/thread;1"]
108
 
    //      .createInstance(Components.interfaces.nsIThread);
109
 
    //    thread.init(this, 0, nsIThread.PRIORITY_NORMAL, nsIThread.SCOPE_LOCAL, nsIThread.STATE_UNJOINABLE);
110
 
    this.run();
111
 
  },
112
 
 
113
 
  run: function()
114
 
  {
115
 
    for (var i = 0; i < this.mAptUrlArray.length; i++) {
116
 
      var aptUrl = this.mAptUrlArray[i];
117
 
      var aptPid = this.mAptPidArray[i];
118
 
      this.mAptInstallerService.onNotifyStart(aptUrl, aptPid);
119
 
 
120
 
      var executable =
121
 
        Components.classes['@mozilla.org/file/local;1']
122
 
       .createInstance(Components.interfaces.nsILocalFile);
123
 
 
124
 
      executable.initWithPath("/usr/bin/apturl");
125
 
 
126
 
      if(!executable.exists() || !executable.isExecutable()) {
127
 
        window.alert('Unexpected error!');
128
 
        this.mAptInstallerService.onNotifyResult(aptUrl, aptPid, -1 );
129
 
        continue;
130
 
      }
131
 
 
132
 
      var procUtil =
133
 
        Components.classes['@mozilla.org/process/util;1']
134
 
        .createInstance(Components.interfaces.nsIProcess);
135
 
 
136
 
      var nsFile = executable.QueryInterface(Components.interfaces.nsIFile);
137
 
 
138
 
      procUtil.init(executable);
139
 
 
140
 
      var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
141
 
                                .getService(Components.interfaces.nsIPrefBranch);
142
 
 
143
 
      var proxyType = prefBranch.getIntPref("network.proxy.type");
144
 
      var proxyHost = prefBranch.getCharPref("network.proxy.http");
145
 
      var proxyPort = prefBranch.getIntPref("network.proxy.http_port");
146
 
 
147
 
      var httpProxy = "";
148
 
      if(proxyType > 0 && proxyHost != null && proxyHost.length > 0)
149
 
      {
150
 
        httpProxy = proxyHost;
151
 
        if(proxyPort > 0)
152
 
        {
153
 
          httpProxy = httpProxy + ":" + proxyPort;
154
 
        }
155
 
      }
156
 
 
157
 
      var args = new Array();
158
 
      if(httpProxy.length > 0)
159
 
      {
160
 
        args = new Array("--http-proxy", httpProxy, aptUrl);
161
 
      } else {
162
 
        args = new Array(aptUrl);
163
 
      }
164
 
      procUtil.run(true, args, args.length);
165
 
      res = procUtil.exitValue;
166
 
 
167
 
      this.mAptInstallerService.onNotifyResult(aptUrl, aptPid, res);
168
 
    }
169
 
 
170
 
    this.mAptInstallerService.onNotifyResult(null, null, -1 );
171
 
    mRunning = false;
172
 
    return true;
173
 
  }
174
 
}
175
 
 
176
 
var PluginAPTInstallService = {
177
 
  
178
 
  init: function () 
179
 
  {
180
 
  },
181
 
 
182
 
  pluginPidArray: null,
183
 
 
184
 
  startPluginInstallation: function (aPluginAptUrlsArray,
185
 
                                     aPluginPidArray) {
186
 
    AptInstaller.install(aPluginAptUrlsArray, aPluginPidArray, this);
187
 
  },
188
 
 
189
 
  onNotifyStart: function (aptUrl, aptPid) {
190
 
    gPluginInstaller.pluginXPIInstallationProgress(aptPid, 6, null);
191
 
  },
192
 
 
193
 
  onNotifyResult: function (aptUrl, aptPid, result) {
194
 
    if(result > 0) {
195
 
      gPluginInstaller.pluginXPIInstallationProgress(aptPid, 7, "Apt Install Failed or Cancelled");
196
 
    } else if (result == 0) {
197
 
      gPluginInstaller.pluginXPIInstallationProgress(aptPid, 7, null);
198
 
    } else {
199
 
      gPluginInstaller.pluginXPIInstallationProgress(null, 8, null);
200
 
    }
201
 
  }
202
 
}