Changeset 1069
- Timestamp:
- 2008-09-08 09:19:36 (2 months ago)
- Files:
-
- trunk/chrome/content/common/internalFunctions.js (modified) (1 diff)
- trunk/chrome/content/common/overlayFunctions.js (modified) (1 diff)
- trunk/chrome/content/dta/manager.js (modified) (1 diff)
- trunk/chrome/content/dta/manager/alertservice.js (modified) (1 diff)
- trunk/chrome/content/dta/manager/prefs.js (modified) (1 diff)
- trunk/chrome/content/dta/select.js (modified) (1 diff)
- trunk/chrome/content/integration/toolbarButtons.js (modified) (1 diff)
- trunk/chrome/content/preferences/prefs.js (modified) (1 diff)
- trunk/modules/preferences.jsm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/chrome/content/common/internalFunctions.js
r1047 r1069 400 400 } 401 401 402 var makeObserver = DTA_makeObserver;403 404 402 /** 405 403 * Encapulates all stringbundles of the current document and provides unified trunk/chrome/content/common/overlayFunctions.js
r1067 r1069 607 607 return null; 608 608 } 609 610 /**611 * Tiny helper to "convert" given object into a weak observer. Object must still612 * implement .observe()613 *614 * @author Nils615 * @param obj616 * Object to convert617 */618 function DTA_makeObserver(obj) {619 // nsiSupports620 let __QueryInterface = obj.QueryInterface;621 obj.QueryInterface = function(iid) {622 try {623 if (624 iid.equals(Components.interfaces.nsISupports)625 || iid.equals(Components.interfaces.nsISupportsWeakReference)626 || iid.equals(Components.interfaces.nsIWeakReference)627 || iid.equals(Components.interfaces.nsIObserver)628 ) {629 return obj;630 }631 if (__QueryInterface) {632 debug("calling original: " + iid);633 return __QueryInterface.call(this, iid);634 }635 throw Components.results.NS_ERROR_NO_INTERFACE;636 }637 catch (ex) {638 debug("requested interface not available: " + iid);639 throw ex;640 }641 };642 // nsiWeakReference643 obj.QueryReferent = function(iid) {644 return obj.QueryInterface(iid);645 };646 // nsiSupportsWeakReference647 obj.GetWeakReference = function() {648 return obj;649 };650 }trunk/chrome/content/dta/manager.js
r1066 r1069 139 139 } 140 140 141 makeObserver(this);141 Preferences.makeObserver(this); 142 142 this._observes.forEach( 143 143 function(topic) { trunk/chrome/content/dta/manager/alertservice.js
r719 r1069 43 43 try { 44 44 this._service = Serv('@mozilla.org/alerts-service;1', 'nsIAlertsService'); 45 makeObserver(this);45 Preferences.makeObserver(this); 46 46 this._available = true; 47 47 } trunk/chrome/content/dta/manager/prefs.js
r1066 r1069 71 71 72 72 init: function() { 73 makeObserver(this);74 75 73 try { 76 74 this._resetConnPrefs(); trunk/chrome/content/dta/select.js
r1062 r1069 801 801 // * filterManager 802 802 registerObserver: function() { 803 makeObserver(this);803 Preferences.makeObserver(this); 804 804 try { 805 805 var os = Cc["@mozilla.org/observer-service;1"] trunk/chrome/content/integration/toolbarButtons.js
r993 r1069 43 43 } 44 44 ); 45 DTA_makeObserver(this);46 45 DTA_preferences.addObserver("extensions.dta.sm.", this); 47 46 this._refresh(); trunk/chrome/content/preferences/prefs.js
r1066 r1069 202 202 registerObserver: function() { 203 203 try { 204 makeObserver(this);204 Preferences.makeObserver(this); 205 205 var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); 206 206 os.addObserver(this, 'DTA:filterschanged', true); trunk/modules/preferences.jsm
r995 r1069 50 50 'resetAllExt', 51 51 'addObserver', 52 'removeObserver' 52 'removeObserver', 53 'makeObserver' 53 54 ]; 54 55 … … 189 190 190 191 function addObserver(branch, obj) { 192 makeObserver(obj); 191 193 prefs.QueryInterface(nsIPrefBranch2).addObserver(branch, obj, true); 192 194 } … … 195 197 prefs.QueryInterface(nsIPrefBranch2).removeObserver(branch, obj); 196 198 } 199 200 function makeObserver(obj) { 201 try { 202 if ( 203 obj.QueryInterface(Ci.nsISupportsWeakReference) 204 && obj.QueryInterface(Ci.nsIObserver) 205 ) { 206 return; 207 } 208 } 209 catch (ex) { 210 // fall-through 211 } 212 let __QueryInterface = obj.QueryInterface; 213 obj.QueryInterface = function(iid) { 214 try { 215 if ( 216 iid.equals(Components.interfaces.nsISupports) 217 || iid.equals(Components.interfaces.nsISupportsWeakReference) 218 || iid.equals(Components.interfaces.nsIWeakReference) 219 || iid.equals(Components.interfaces.nsIObserver) 220 ) { 221 return obj; 222 } 223 if (__QueryInterface) { 224 debug("calling original: " + iid); 225 return __QueryInterface.call(this, iid); 226 } 227 throw Components.results.NS_ERROR_NO_INTERFACE; 228 } 229 catch (ex) { 230 debug("requested interface not available: " + iid); 231 throw ex; 232 } 233 }; 234 // nsiWeakReference 235 obj.QueryReferent = function(iid) { 236 return obj.QueryInterface(iid); 237 }; 238 // nsiSupportsWeakReference 239 obj.GetWeakReference = function() { 240 return obj; 241 }; 242 }
