From 931b75ae4ff6e530ec26a2d802a05c1479671c74 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sat, 2 Mar 2013 08:04:22 -0500 Subject: [PATCH] Bug 843536 - Ctrl-o doesn't open file picker. r=sfoster --- browser/metro/base/content/browser-ui.js | 26 +++++++++++++++++++ browser/metro/base/content/browser.xul | 2 ++ .../locales/en-US/chrome/browser.properties | 1 + 3 files changed, 29 insertions(+) diff --git a/browser/metro/base/content/browser-ui.js b/browser/metro/base/content/browser-ui.js index 23dbe6ffc32..8311620b2e2 100644 --- a/browser/metro/base/content/browser-ui.js +++ b/browser/metro/base/content/browser-ui.js @@ -758,6 +758,28 @@ var BrowserUI = { } }, + openFile: function() { + try { + const nsIFilePicker = Ci.nsIFilePicker; + let fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + let self = this; + let fpCallback = function fpCallback_done(aResult) { + if (aResult == nsIFilePicker.returnOK) { + self.goToURI(fp.fileURL.spec); + } + }; + + let windowTitle = Strings.browser.GetStringFromName("browserForOpenLocation"); + fp.init(window, windowTitle, nsIFilePicker.modeOpen); + fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText | + nsIFilePicker.filterImages | nsIFilePicker.filterXML | + nsIFilePicker.filterHTML); + fp.open(fpCallback); + } catch (ex) { + dump ('BrowserUI openFile exception: ' + ex + '\n'); + } + }, + receiveMessage: function receiveMessage(aMessage) { let browser = aMessage.target; let json = aMessage.json; @@ -812,6 +834,7 @@ var BrowserUI = { case "cmd_zoomout": case "cmd_volumeLeft": case "cmd_volumeRight": + case "cmd_openFile": isSupported = true; break; default: @@ -935,6 +958,9 @@ var BrowserUI = { // Zoom out (portrait) or in (landscape) Browser.zoom(Util.isPortrait() ? 1 : -1); break; + case "cmd_openFile": + this.openFile(); + break; } } }; diff --git a/browser/metro/base/content/browser.xul b/browser/metro/base/content/browser.xul index e8db2dbbd92..574c2f77d7c 100644 --- a/browser/metro/base/content/browser.xul +++ b/browser/metro/base/content/browser.xul @@ -67,6 +67,7 @@ + @@ -133,6 +134,7 @@ + diff --git a/browser/metro/locales/en-US/chrome/browser.properties b/browser/metro/locales/en-US/chrome/browser.properties index e856861de74..672799e417c 100644 --- a/browser/metro/locales/en-US/chrome/browser.properties +++ b/browser/metro/locales/en-US/chrome/browser.properties @@ -21,6 +21,7 @@ helpOnlineCharm=Help (online) # General browserForSaveLocation=Save Location +browserForOpenLocation=Open Location # Download Manager downloadsUnknownSize=Unknown size