Bug 784842 - Add the new async nsIFilePicker::open to the XUL file picker. r=roc
authorBrian R. Bondy <netzen@gmail.com>
Fri, 24 Aug 2012 07:55:08 -0400
changeset 103433 730c4f0ec3ae03637cd8d79135d10fa125677640
parent 103432 af3d980899704fa608576eb27c5a97088311a315
child 103434 b543ecb718e3dd5e51b43942a137f75d86c1c2ed
push id13988
push userbbondy@mozilla.com
push dateSat, 25 Aug 2012 23:40:21 +0000
treeherdermozilla-inbound@730c4f0ec3ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs784842
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 784842 - Add the new async nsIFilePicker::open to the XUL file picker. r=roc
toolkit/components/filepicker/nsFilePicker.js
--- a/toolkit/components/filepicker/nsFilePicker.js
+++ b/toolkit/components/filepicker/nsFilePicker.js
@@ -178,16 +178,29 @@ nsFilePicker.prototype = {
     }
   },
 
   appendFilter: function(title, extensions) {
     this.mFilterTitles.push(title);
     this.mFilters.push(extensions);
   },
 
+  open: function(aFilePickerShownCallback) {
+    var tm = Components.classes["@mozilla.org/thread-manager;1"]
+                       .getService(Components.interfaces.nsIThreadManager);
+    tm.mainThread.dispatch(function() {
+      try {
+        let result = this.show();
+        aFilePickerShownCallback.done(result);
+      } catch(ex) {
+        aFilePickerShownCallback.done(this.returnCancel);
+      }
+    }.bind(this), Components.interfaces.nsIThread.DISPATCH_NORMAL);
+  },
+
   show: function() {
     var o = new Object();
     o.title = this.mTitle;
     o.mode = this.mMode;
     o.displayDirectory = this.mDisplayDirectory;
     o.defaultString = this.mDefaultString;
     o.filterIndex = this.mFilterIndex;
     o.filters = new Object();