~ubuntu-branches/ubuntu/intrepid/xulrunner-1.9/intrepid

« back to all changes in this revision

Viewing changes to mozilla/toolkit/components/passwordmgr/content/passwordManagerCommon.js

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Alexander Sack, Fabien Tassin
  • Date: 2008-02-13 11:47:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080213114721-7om0mgzngvuk9czv
Tags: 1.9~b3+nobinonly-0ubuntu1
* release FIREFOX_3_0b3_RELEASE

[ Alexander Sack ]
* submit patch that ships xpcshell to bugzilla
  - rename debian/patches/ship_xpcshell.patch =>
           debian/patches/bz410617_att295212_ship_xpcshell.patch
  - update debian/patches/series
* fix tooltip in epiphany: previously displayed out of screen bounds
  (LP: #37507)
  - add debian/patches/bz233371_att297343_fix_outofscreen_embed_tooltip.patch
  - update debian/patches/series
* use default upstream gcc tweaks for improved performance - especially of the
  javascript engine
  - update debian/rules
* update global extension/plugin patch to apply cleanly against latest code
  - update debian/patches/bzXXX_gre_extension_plugin_support.patch
* fix pyxpcom build failure introduced by recent commit
  - add debian/patches/bzXXX_fix_pyxpcom_build_failure.patch
  - update debian/patches/series
* add distro independent global install locations for extensions,
  /usr/lib/mozilla/extensions and /usr/share/mozilla/extensions
  - update debian/xulrunner-1.9.dirs
* support embedded tarball layout when either there is a *.tar.bz2 in orig tarball
  or if DEBIAN_MOZCLIENT_EMBEDDED is not unset (you will need this to produce embedded
  tarballs during |get-orig-source|
  - update debian/rules
* bump minimum libnss3-dev build requirements to >= 3.12.0~1.9b3
  - update debian/control
* bump minimum libnspr4-dev build requirements to >= 4.7.0~1.9b3
  - update debian/control

[ Fabien Tassin ]
* Drop patches applied upstream
  - drop debian/patches/bz410617_att295212_ship_xpcshell.patch
  - drop debian/patches/bz404634_att294921.patch
  - drop debian/patches/bz386610_python2.5_ftbfs_amd64.patch
  - drop debian/patches/bz373918_att295042.patch
  - drop debian/patches/bz408062_unstable_pc.patch
  - drop debian/patches/bz384304_fix_recursive_symlinks.patch
  - update debian/patches/series
* Refresh diverged patches:
  - update debian/patches/bzXXX_pc_honour_system_nspr_nss.patch
  - update debian/patches/rename_venkman_addon.patch
  - update debian/patches/bz344818_cairo_xrender.patch
* Install links for all .so libs in the -dev package
  - update debian/patches/dont_install_so_in_dev.patch
* Bump gtk requirement to 2.12 as per Mozilla bug 412432
  - update debian/control
* Add #DEBHELPER# token to postinst/prerm scripts
  - update debian/xulrunner-1.9.{postinst,prerm}
* Install previously missed libdbusservice.so
  - update debian/xulrunner-1.9.install
* Update venkman patch to also rename locales
  - update debian/patches/rename_venkman_addon.patch
* Bump requirement for system cairo to >= 1.5.8 as we now need
  the newly added cairo_path_extents()
  - update debian/rules
* Include mozilla-devscripts file using -include so ifneq could be omitted
  - update debian/rules
* Fix missing .so symlinks regression
  - update debian/patches/dont_install_so_in_dev.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
 
#
3
 
# ***** BEGIN LICENSE BLOCK *****
4
 
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
 
#
6
 
# The contents of this file are subject to the Mozilla Public License Version
7
 
# 1.1 (the "License"); you may not use this file except in compliance with
8
 
# the License. You may obtain a copy of the License at
9
 
# http://www.mozilla.org/MPL/
10
 
#
11
 
# Software distributed under the License is distributed on an "AS IS" basis,
12
 
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
 
# for the specific language governing rights and limitations under the
14
 
# License.
15
 
#
16
 
# The Original Code is Mozilla Communicator client code, released
17
 
# March 31, 1998.
18
 
#
19
 
# The Initial Developer of the Original Code is
20
 
# Netscape Communications Corporation.
21
 
# Portions created by the Initial Developer are Copyright (C) 1998
22
 
# the Initial Developer. All Rights Reserved.
23
 
#
24
 
# Contributor(s):
25
 
#   Ben "Count XULula" Goodger
26
 
#   Brian Ryner <bryner@brianryner.com>
27
 
#   Ehsan Akhgari <ehsan.akhgari@gmail.com>
28
 
#
29
 
# Alternatively, the contents of this file may be used under the terms of
30
 
# either the GNU General Public License Version 2 or later (the "GPL"), or
31
 
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32
 
# in which case the provisions of the GPL or the LGPL are applicable instead
33
 
# of those above. If you wish to allow use of your version of this file only
34
 
# under the terms of either the GPL or the LGPL, and not to allow others to
35
 
# use your version of this file under the terms of the MPL, indicate your
36
 
# decision by deleting the provisions above and replace them with the notice
37
 
# and other provisions required by the GPL or the LGPL. If you do not delete
38
 
# the provisions above, a recipient may use your version of this file under
39
 
# the terms of any one of the MPL, the GPL or the LGPL.
40
 
#
41
 
# ***** END LICENSE BLOCK *****
42
 
 
43
 
/*** =================== INITIALISATION CODE =================== ***/
44
 
 
45
 
var kObserverService;
46
 
var gSelectUserInUse = false;
47
 
 
48
 
// interface variables
49
 
var passwordmanager     = null;
50
 
 
51
 
// password-manager lists
52
 
var signons             = [];
53
 
var rejects             = [];
54
 
var deletedSignons      = [];
55
 
var deletedRejects      = [];
56
 
 
57
 
var signonsTree;
58
 
var rejectsTree;
59
 
 
60
 
var showingPasswords = false;
61
 
 
62
 
function Startup() {
63
 
  // xpconnect to password manager interfaces
64
 
  passwordmanager = Components.classes["@mozilla.org/login-manager;1"]
65
 
                        .getService(Components.interfaces.nsILoginManager);
66
 
 
67
 
  // be prepared to reload the display if anything changes
68
 
  kObserverService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
69
 
  kObserverService.addObserver(signonReloadDisplay, "signonChanged", false);
70
 
 
71
 
  // be prepared to disable the buttons when selectuser dialog is in use
72
 
  kObserverService.addObserver(signonReloadDisplay, "signonSelectUser", false);
73
 
 
74
 
  signonsTree = document.getElementById("signonsTree");
75
 
  rejectsTree = document.getElementById("rejectsTree");
76
 
}
77
 
 
78
 
function Shutdown() {
79
 
  kObserverService.removeObserver(signonReloadDisplay, "signonChanged");
80
 
  kObserverService.removeObserver(signonReloadDisplay, "signonSelectUser");
81
 
}
82
 
 
83
 
var signonReloadDisplay = {
84
 
  observe: function(subject, topic, state) {
85
 
    if (topic == "signonChanged") {
86
 
      if (state == "signons") {
87
 
        signons.length = 0;
88
 
        if (lastSignonSortColumn == "hostname") {
89
 
          lastSignonSortAscending = !lastSignonSortAscending; // prevents sort from being reversed
90
 
        }
91
 
        LoadSignons();
92
 
        // apply the filter if needed
93
 
        if (document.getElementById("filter") && document.getElementById("filter").value != "") {
94
 
          _filterPasswords();
95
 
        }
96
 
      } else if (state == "rejects") {
97
 
        rejects.length = 0;
98
 
        if (lastRejectSortColumn == "hostname") {
99
 
          lastRejectSortAscending = !lastRejectSortAscending; // prevents sort from being reversed
100
 
        }
101
 
        LoadRejects();
102
 
      }
103
 
    } else if (topic == "signonSelectUser") {
104
 
      if (state == "suspend") {
105
 
        gSelectUserInUse = true;
106
 
        document.getElementById("removeSignon").disabled = true;
107
 
        document.getElementById("removeAllSignons").disabled = true;
108
 
        document.getElementById("togglePasswords").disabled = true;
109
 
      } else if (state == "resume") {
110
 
        gSelectUserInUse = false;
111
 
        var selections = GetTreeSelections(signonsTree);
112
 
        if (selections.length > 0) {
113
 
          document.getElementById("removeSignon").disabled = false;
114
 
        }
115
 
        if (signons.length > 0) {
116
 
          document.getElementById("removeAllSignons").disabled = false;
117
 
          document.getElementById("togglePasswords").disabled = false;
118
 
        }
119
 
      } else if (state == "inUse") {
120
 
        gSelectUserInUse = true;
121
 
      }
122
 
    }
123
 
  }
124
 
}
125
 
 
126
 
/*** =================== GENERAL CODE =================== ***/
127
 
 
128
 
function DeleteAllFromTree(tree, view, table, deletedTable, removeButton, removeAllButton) {
129
 
 
130
 
  // remove all items from table and place in deleted table
131
 
  for (var i=0; i<table.length; i++) {
132
 
    deletedTable[deletedTable.length] = table[i];
133
 
  }
134
 
  table.length = 0;
135
 
 
136
 
  // clear out selections
137
 
  view.selection.select(-1); 
138
 
 
139
 
  // update the tree view and notify the tree
140
 
  view.rowCount = 0;
141
 
 
142
 
  var box = tree.treeBoxObject;
143
 
  box.rowCountChanged(0, -deletedTable.length);
144
 
  box.invalidate();
145
 
 
146
 
 
147
 
  // disable buttons
148
 
  document.getElementById(removeButton).setAttribute("disabled", "true")
149
 
  document.getElementById(removeAllButton).setAttribute("disabled","true");
150
 
}
151
 
 
152
 
function DeleteSelectedItemFromTree
153
 
    (tree, view, table, deletedTable, removeButton, removeAllButton) {
154
 
 
155
 
  // Turn off tree selection notifications during the deletion
156
 
  tree.view.selection.selectEventsSuppressed = true;
157
 
 
158
 
  // remove selected items from list (by setting them to null) and place in deleted list
159
 
  var selections = GetTreeSelections(tree);
160
 
  for (var s=selections.length-1; s>= 0; s--) {
161
 
    var i = selections[s];
162
 
    deletedTable[deletedTable.length] = table[i];
163
 
    table[i] = null;
164
 
  }
165
 
 
166
 
  // collapse list by removing all the null entries
167
 
  for (var j=0; j<table.length; j++) {
168
 
    if (table[j] == null) {
169
 
      var k = j;
170
 
      while ((k < table.length) && (table[k] == null)) {
171
 
        k++;
172
 
      }
173
 
      table.splice(j, k-j);
174
 
      view.rowCount -= k - j;
175
 
      tree.treeBoxObject.rowCountChanged(j, j - k);
176
 
    }
177
 
  }
178
 
 
179
 
  // update selection and/or buttons
180
 
  if (table.length) {
181
 
    // update selection
182
 
    var nextSelection = (selections[0] < table.length) ? selections[0] : table.length-1;
183
 
    tree.view.selection.select(nextSelection);
184
 
    tree.treeBoxObject.ensureRowIsVisible(nextSelection);
185
 
  } else {
186
 
    // disable buttons
187
 
    document.getElementById(removeButton).setAttribute("disabled", "true")
188
 
    document.getElementById(removeAllButton).setAttribute("disabled","true");
189
 
  }
190
 
  tree.view.selection.selectEventsSuppressed = false;
191
 
}
192
 
 
193
 
function GetTreeSelections(tree) {
194
 
  var selections = [];
195
 
  var select = tree.view.selection;
196
 
  if (select) {
197
 
    var count = select.getRangeCount();
198
 
    var min = new Object();
199
 
    var max = new Object();
200
 
    for (var i=0; i<count; i++) {
201
 
      select.getRangeAt(i, min, max);
202
 
      for (var k=min.value; k<=max.value; k++) {
203
 
        if (k != -1) {
204
 
          selections[selections.length] = k;
205
 
        }
206
 
      }
207
 
    }
208
 
  }
209
 
  return selections;
210
 
}
211
 
 
212
 
function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending, updateSelection) {
213
 
 
214
 
  // remember which item was selected so we can restore it after the sort
215
 
  var selections = GetTreeSelections(tree);
216
 
  var selectedNumber = selections.length ? table[selections[0]].number : -1;
217
 
 
218
 
  // determine if sort is to be ascending or descending
219
 
  var ascending = (column == lastSortColumn) ? !lastSortAscending : true;
220
 
 
221
 
  // do the sort
222
 
  var compareFunc;
223
 
  if (ascending) {
224
 
    compareFunc = function compare(first, second) {
225
 
      return CompareLowerCase(first[column], second[column]);
226
 
    }
227
 
  } else {
228
 
    compareFunc = function compare(first, second) {
229
 
      return CompareLowerCase(second[column], first[column]);
230
 
    }
231
 
  }
232
 
  table.sort(compareFunc);
233
 
 
234
 
  // restore the selection
235
 
  var selectedRow = -1;
236
 
  if (selectedNumber>=0 && updateSelection) {
237
 
    for (var s=0; s<table.length; s++) {
238
 
      if (table[s].number == selectedNumber) {
239
 
        // update selection
240
 
        // note: we need to deselect before reselecting in order to trigger ...Selected()
241
 
        tree.view.selection.select(-1);
242
 
        tree.view.selection.select(s);
243
 
        selectedRow = s;
244
 
        break;
245
 
      }
246
 
    }
247
 
  }
248
 
 
249
 
  // display the results
250
 
  tree.treeBoxObject.invalidate();
251
 
  if (selectedRow >= 0) {
252
 
    tree.treeBoxObject.ensureRowIsVisible(selectedRow)
253
 
  }
254
 
 
255
 
  return ascending;
256
 
}
257
 
 
258
 
/**
259
 
 * Case insensitive string comparator.
260
 
 */
261
 
function CompareLowerCase(first, second) {
262
 
  var firstLower, secondLower;
263
 
 
264
 
  // Are we sorting nsILoginInfo entries or just strings?
265
 
  if (first.hostname) {
266
 
    firstLower  = first.hostname.toLowerCase();
267
 
    secondLower = second.hostname.toLowerCase();
268
 
  } else {
269
 
    firstLower  = first.toLowerCase();
270
 
    secondLower = second.toLowerCase();
271
 
  }
272
 
 
273
 
  if (firstLower < secondLower) {
274
 
    return -1;
275
 
  }
276
 
 
277
 
  if (firstLower > secondLower) {
278
 
    return 1;
279
 
  }
280
 
 
281
 
  return 0;
282
 
}