Bug 877200 - Make history menu use async prompts. r=mfinkle
☠☠ backed out by b11bffd58de9 ☠ ☠
authorWes Johnston <wjohnston@mozilla.com>
Mon, 03 Jun 2013 09:20:45 -0700
changeset 133819 8904d2bf5da0db6c4dddb632ae85291ffa6e6cc3
parent 133818 80455a25276b4eed1fbe9067c901860ae08c1a3d
child 133820 194d9ece508a434141ec813eb0d8ac01e5b5ad26
push id28907
push userwjohnston@mozilla.com
push dateMon, 03 Jun 2013 16:22:12 +0000
treeherdermozilla-inbound@8904d2bf5da0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs877200
milestone24.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 877200 - Make history menu use async prompts. r=mfinkle
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -244,17 +244,16 @@ var Strings = {};
     return Services.strings.createBundle(bundle);
   });
 });
 
 var BrowserApp = {
   _tabs: [],
   _selectedTab: null,
   _prefObservers: [],
-  _promptHandlers: {},
 
   get isTablet() {
     let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
     delete this.isTablet;
     return this.isTablet = sysInfo.get("tablet");
   },
 
   get isOnLowMemoryPlatform() {
@@ -294,17 +293,16 @@ var BrowserApp = {
     Services.obs.addObserver(this, "FullScreen:Exit", false);
     Services.obs.addObserver(this, "Viewport:Change", false);
     Services.obs.addObserver(this, "Viewport:Flush", false);
     Services.obs.addObserver(this, "Viewport:FixedMarginsChanged", false);
     Services.obs.addObserver(this, "Passwords:Init", false);
     Services.obs.addObserver(this, "FormHistory:Init", false);
     Services.obs.addObserver(this, "gather-telemetry", false);
     Services.obs.addObserver(this, "keyword-search", false);
-    Services.obs.addObserver(this, "Prompt:Reply", false);
 
     Services.obs.addObserver(this, "sessionstore-state-purge-complete", false);
 
     function showFullScreenWarning() {
       NativeWindow.toast.show(Strings.browser.GetStringFromName("alertFullScreenToast"), "short");
     }
 
     window.addEventListener("fullscreen", function() {
@@ -1423,28 +1421,16 @@ var BrowserApp = {
       case "Sanitize:ClearData":
         this.sanitize(aData);
         break;
 
       case "FullScreen:Exit":
         browser.contentDocument.mozCancelFullScreen();
         break;
 
-      case "Prompt:Reply":
-        {
-            let data = JSON.parse(aData);
-            let guid = data.guid;
-            let handler = this._promptHandlers[guid];
-            if (!handler)
-              break;
-            this._promptHandlers[guid];
-            handler(data);
-        }
-        break;
-
       case "Viewport:Change":
         if (this.isBrowserContentDocumentDisplayed())
           this.selectedTab.setViewport(JSON.parse(aData));
         break;
 
       case "Viewport:Flush":
         this.contentDocumentChanged();
         break;
@@ -1499,45 +1485,36 @@ var BrowserApp = {
   getBrowserTab: function(tabId) {
     return this.getTabForId(tabId);
   },
 
   // This method will print a list from fromIndex to toIndex, optionally
   // selecting selIndex(if fromIndex<=selIndex<=toIndex)
   showHistory: function(fromIndex, toIndex, selIndex) {
     let browser = this.selectedBrowser;
-    let guid = uuidgen.generateUUID().toString();
-    let result = {
-      type: "Prompt:Show",
-      multiple: false,
-      async: true,
-      guid: guid,
-      selected: [],
-      listitems: []
-    };
     let hist = browser.sessionHistory;
+    let listitems = [];
     for (let i = toIndex; i >= fromIndex; i--) {
       let entry = hist.getEntryAtIndex(i, false);
       let item = {
         label: entry.title || entry.URI.spec,
-        isGroup: false,
-        inGroup: false,
-        disabled: false,
-        id: i
+        selected: (i == selIndex)
       };
-      result.listitems.push(item);
-      result.selected.push(i == selIndex);
-    }
-    this._promptHandlers[guid] = function (data) {
+      listitems.push(item);
+    }
+
+    let p = new Prompt({
+      window: browser.contentWindow
+    }).setSingleChoiceItems(listitems).show(function(data) {
         let selected = data.button;
         if (selected == -1)
           return;
+
         browser.gotoIndex(toIndex-selected);
-    };
-    sendMessageToJava(result);
+    });
   },
 };
 
 var NativeWindow = {
   init: function() {
     Services.obs.addObserver(this, "Menu:Clicked", false);
     Services.obs.addObserver(this, "Doorhanger:Reply", false);
     this.contextmenus.init();