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 167015 5fd318a789f6a57d3ff8d52b723b042f2cc17512
parent 167014 d0e1eff200975c5dbce1c2e8b1f0d49796b2a3f8
child 167016 eae47207061055885e5817650e068c1392f39b4e
push id26157
push userryanvm@gmail.com
push dateWed, 05 Feb 2014 20:31:25 +0000
treeherdermozilla-central@bb4aa981b683 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs819613
milestone30.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 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;