From 8cc9cbadae2f85daf54f46634f4574059d4367ce Mon Sep 17 00:00:00 2001 From: Philip Chee Date: Sun, 17 Nov 2013 22:21:55 +0800 Subject: [PATCH] Bug 58986 The find dialog should autocomplete recently searched items r=Neil. --- toolkit/content/finddialog.js | 21 +++++++++++++++++++++ toolkit/content/finddialog.xul | 6 +++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/toolkit/content/finddialog.js b/toolkit/content/finddialog.js index 5c81b40d1547..57c1ead3357f 100644 --- a/toolkit/content/finddialog.js +++ b/toolkit/content/finddialog.js @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Components.utils.import("resource://gre/modules/Services.jsm"); +Components.utils.import("resource://gre/modules/FormHistory.jsm"); var dialog; // Quick access to document/form elements. var gFindInst; // nsIWebBrowserFind that we're going to use @@ -100,6 +101,7 @@ function onAccept() // Transfer dialog contents to the find service. saveFindData(); + updateFormHistory(); // set up the find instance gFindInst.searchString = dialog.findKey.value; @@ -126,3 +128,22 @@ function doEnabling() { dialog.find.disabled = !dialog.findKey.value; } + +function updateFormHistory() +{ + if (window.opener.PrivateBrowsingUtils && + window.opener.PrivateBrowsingUtils.isWindowPrivate(window.opener) || + !dialog.findKey.value) + return; + + FormHistory.update({ + op: "bump", + fieldname: "find-dialog", + value: dialog.findKey.value + }, { + handleError: function(aError) { + Components.utils.reportError("Saving find to form history failed: " + + aError.message); + } + }); +} diff --git a/toolkit/content/finddialog.xul b/toolkit/content/finddialog.xul index 37e7303e4907..c49092e6f665 100644 --- a/toolkit/content/finddialog.xul +++ b/toolkit/content/finddialog.xul @@ -25,7 +25,11 @@