Bug 819613 - Add app command support to browser-ui.js. r=sfoster
authorJim Mathies <jmathies@mozilla.com>
Wed, 05 Feb 2014 09:37:02 -0600
changeset 166971 5fd318a789f6a57d3ff8d52b723b042f2cc17512
parent 166970 d0e1eff200975c5dbce1c2e8b1f0d49796b2a3f8
child 166972 eae47207061055885e5817650e068c1392f39b4e
push id4857
push userjmathies@mozilla.com
push dateWed, 05 Feb 2014 15:37:17 +0000
treeherderfx-team@5fd318a789f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs819613
milestone30.0a1
Bug 819613 - Add app command support to browser-ui.js. r=sfoster
browser/metro/base/content/browser-ui.js
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -101,16 +101,18 @@ var BrowserUI = {
     messageManager.addMessageListener("Content:StateChange", this);
 
     // listening escape to dismiss dialog on VK_ESCAPE
     window.addEventListener("keypress", this, true);
 
     window.addEventListener("MozPrecisePointer", this, true);
     window.addEventListener("MozImprecisePointer", this, true);
 
+    window.addEventListener("AppCommand", this, true);
+
     Services.prefs.addObserver("browser.cache.disk_cache_ssl", this, false);
 
     // Init core UI modules
     ContextUI.init();
     PanelUI.init();
     FlyoutPanelsUI.init();
     PageThumbs.init();
     NewTabUtils.init();
@@ -776,16 +778,19 @@ var BrowserUI = {
           this.handleEscape(aEvent);
         break;
       case "MozPrecisePointer":
         this._onPreciseInput();
         break;
       case "MozImprecisePointer":
         this._onImpreciseInput();
         break;
+      case "AppCommand":
+        this.handleAppCommandEvent(aEvent);
+        break;
     }
   },
 
   // Checks if various different parts of the UI is visible and closes
   // them one at a time.
   handleEscape: function (aEvent) {
     aEvent.stopPropagation();
     aEvent.preventDefault();
@@ -1135,16 +1140,58 @@ var BrowserUI = {
         this.openFile();
         break;
       case "cmd_savePage":
         this.savePage();
         break;
     }
   },
 
+  handleAppCommandEvent: function (aEvent) {
+    switch (aEvent.command) {
+      case "Back":
+        this.doCommand("cmd_back");
+        break;
+      case "Forward":
+        this.doCommand("cmd_forward");
+        break;
+      case "Reload":
+        this.doCommand("cmd_reload");
+        break;
+      case "Stop":
+        this.doCommand("cmd_stop");
+        break;
+      case "Home":
+        this.doCommand("cmd_home");
+        break;
+      case "New":
+        this.doCommand("cmd_newTab");
+        break;
+      case "Close":
+        this.doCommand("cmd_closeTab");
+        break;
+      case "Find":
+        FindHelperUI.show();
+        break;
+      case "Open":
+        this.doCommand("cmd_openFile");
+        break;
+      case "Save":
+        this.doCommand("cmd_savePage");
+        break;
+      case "Search":
+        this.doCommand("cmd_openLocation");
+        break;
+      default:
+        return;
+    }
+    aEvent.stopPropagation();
+    aEvent.preventDefault();
+  },
+
   confirmSanitizeDialog: function () {
     let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
     let title = bundle.GetStringFromName("clearPrivateData.title2");
     let message = bundle.GetStringFromName("clearPrivateData.message3");
     let clearbutton = bundle.GetStringFromName("clearPrivateData.clearButton");
 
     let prefsClearButton = document.getElementById("prefs-clear-data");
     prefsClearButton.disabled = true;