forked from mirrors/gecko-dev
Bug 1885294 - P2. Rename FormAutoComplete to FormHistoryAutoComplete r=credential-management-reviewers,search-reviewers,Standard8,jneuberger
When we talk about form autocomplete, it could mean "address/credit card autocomplete", "login autocomplete", and
"form history autocomplete. In order to improve code readability, this patch changes the following naming:
1. FormAutoComplete to FormHisotryAutoComplete
2. nsIFormAutoCompleteObserver to nsIFormFillCompleteObserver
- This is because this interface is used by FormFillController, not by
FormHistory
Differential Revision: https://phabricator.services.mozilla.com/D204601
This commit is contained in:
parent
192b1e23cf
commit
7a4b04c82b
14 changed files with 67 additions and 65 deletions
|
|
@ -487,7 +487,7 @@ export class LoginAutoComplete {
|
|||
* @param {string} aSearchString The value typed in the field.
|
||||
* @param {nsIAutoCompleteResult} aPreviousResult
|
||||
* @param {HTMLInputElement} aElement
|
||||
* @param {nsIFormAutoCompleteObserver} aCallback
|
||||
* @param {nsIFormFillCompleteObserver} aCallback
|
||||
*/
|
||||
startSearch(aSearchString, aPreviousResult, aElement, aCallback) {
|
||||
let { isNullPrincipal } = aElement.nodePrincipal;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIAutoCompleteResult;
|
||||
interface nsIFormAutoCompleteObserver;
|
||||
interface nsIFormFillCompleteObserver;
|
||||
|
||||
webidl HTMLInputElement;
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ interface nsILoginAutoCompleteSearch : nsISupports {
|
|||
void startSearch(in AString aSearchString,
|
||||
in nsIAutoCompleteResult aPreviousResult,
|
||||
in HTMLInputElement aElement,
|
||||
in nsIFormAutoCompleteObserver aListener);
|
||||
in nsIFormFillCompleteObserver aListener);
|
||||
|
||||
/**
|
||||
* Stop a previously-started search.
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ function isAutocompleteDisabled(aField) {
|
|||
* figuring out the most appropriate message manager to use,
|
||||
* and what things to send.
|
||||
*
|
||||
* It is assumed that nsFormAutoComplete will only ever use
|
||||
* It is assumed that FormHistoryAutoComplete will only ever use
|
||||
* one instance at a time, and will not attempt to perform more
|
||||
* than one search request with the same instance at a time.
|
||||
* However, nsFormAutoComplete might call remove() any number of
|
||||
* However, FormHistoryAutoComplete might call remove() any number of
|
||||
* times with the same instance of the client.
|
||||
*
|
||||
* @param {object} clientInfo
|
||||
|
|
@ -193,7 +193,7 @@ export class FormHistoryClient {
|
|||
*
|
||||
* @implements {nsIAutoCompleteResult}
|
||||
*/
|
||||
export class FormAutoCompleteResult {
|
||||
export class FormHistoryAutoCompleteResult {
|
||||
constructor(client, entries, fieldName, searchString) {
|
||||
this.client = client;
|
||||
this.entries = entries;
|
||||
|
|
@ -395,7 +395,7 @@ export class FormAutoCompleteResult {
|
|||
}
|
||||
}
|
||||
|
||||
export class FormAutoComplete {
|
||||
export class FormHistoryAutoComplete {
|
||||
constructor() {
|
||||
// Preferences. Add observer so we get notified of changes.
|
||||
this._prefBranch = Services.prefs.getBranch("browser.formfill.");
|
||||
|
|
@ -407,9 +407,9 @@ export class FormAutoComplete {
|
|||
Services.obs.addObserver(this, "autocomplete-will-enter-text");
|
||||
}
|
||||
|
||||
classID = Components.ID("{c11c21b2-71c9-4f87-a0f8-5e13f50495fd}");
|
||||
classID = Components.ID("{23530265-31d1-4ee9-864c-c081975fb7bc}");
|
||||
QueryInterface = ChromeUtils.generateQI([
|
||||
"nsIFormAutoComplete",
|
||||
"nsIFormHistoryAutoComplete",
|
||||
"nsISupportsWeakReference",
|
||||
]);
|
||||
|
||||
|
|
@ -465,8 +465,7 @@ export class FormAutoComplete {
|
|||
if (!this._debug) {
|
||||
return;
|
||||
}
|
||||
dump("FormAutoComplete: " + message + "\n");
|
||||
Services.console.logStringMessage("FormAutoComplete: " + message);
|
||||
Services.console.logStringMessage("FormHistoryAutoComplete: " + message);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -478,7 +477,7 @@ export class FormAutoComplete {
|
|||
* aField -- HTMLInputElement being autocompleted (may be null if from chrome)
|
||||
* aPreviousResult -- previous search result, if any.
|
||||
* aAddDataList -- add results from list=datalist for aField.
|
||||
* aListener -- nsIFormAutoCompleteObserver that listens for the nsIAutoCompleteResult
|
||||
* aListener -- nsIFormHistoryAutoCompleteObserver that listens for the nsIAutoCompleteResult
|
||||
* that may be returned asynchronously.
|
||||
*/
|
||||
autoCompleteSearchAsync(
|
||||
|
|
@ -507,7 +506,7 @@ export class FormAutoComplete {
|
|||
}
|
||||
|
||||
// If we have datalist results, they become our "empty" result.
|
||||
const result = new FormAutoCompleteResult(
|
||||
const result = new FormHistoryAutoCompleteResult(
|
||||
client,
|
||||
[],
|
||||
aInputName,
|
||||
|
|
@ -18,10 +18,10 @@ Classes = [
|
|||
},
|
||||
|
||||
{
|
||||
'cid': '{c11c21b2-71c9-4f87-a0f8-5e13f50495fd}',
|
||||
'contract_ids': ['@mozilla.org/satchel/form-autocomplete;1'],
|
||||
'esModule': 'resource://gre/modules/FormAutoComplete.sys.mjs',
|
||||
'constructor': 'FormAutoComplete',
|
||||
'cid': '{23530265-31d1-4ee9-864c-c081975fb7bc}',
|
||||
'contract_ids': ['@mozilla.org/satchel/form-history-autocomplete;1'],
|
||||
'esModule': 'resource://gre/modules/FormHistoryAutoComplete.sys.mjs',
|
||||
'constructor': 'FormHistoryAutoComplete',
|
||||
},
|
||||
{
|
||||
'cid': '{3a0012eb-007f-4bb8-aa81-a07385f77a25}',
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.toml"]
|
|||
BROWSER_CHROME_MANIFESTS += ["test/browser/browser.toml"]
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
"nsIFormAutoComplete.idl",
|
||||
"nsIFormFillController.idl",
|
||||
"nsIFormHistoryAutoComplete.idl",
|
||||
]
|
||||
|
||||
XPIDL_MODULE = "satchel"
|
||||
|
|
@ -28,8 +28,8 @@ LOCAL_INCLUDES += [
|
|||
|
||||
EXTRA_JS_MODULES += [
|
||||
"FillHelpers.sys.mjs",
|
||||
"FormAutoComplete.sys.mjs",
|
||||
"FormHistory.sys.mjs",
|
||||
"FormHistoryAutoComplete.sys.mjs",
|
||||
"FormHistoryStartup.sys.mjs",
|
||||
"FormScenarios.sys.mjs",
|
||||
"integrations/FirefoxRelay.sys.mjs",
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StaticPrefs_ui.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFormAutoComplete.h"
|
||||
#include "nsIFormHistoryAutoComplete.h"
|
||||
#include "nsString.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIAutoCompleteResult.h"
|
||||
|
|
@ -47,12 +47,13 @@ using mozilla::LogLevel;
|
|||
|
||||
static mozilla::LazyLogModule sLogger("satchel");
|
||||
|
||||
static nsIFormAutoComplete* GetFormAutoComplete() {
|
||||
static nsCOMPtr<nsIFormAutoComplete> sInstance;
|
||||
static nsIFormHistoryAutoComplete* GetFormHistoryAutoComplete() {
|
||||
static nsCOMPtr<nsIFormHistoryAutoComplete> sInstance;
|
||||
static bool sInitialized = false;
|
||||
if (!sInitialized) {
|
||||
nsresult rv;
|
||||
sInstance = do_GetService("@mozilla.org/satchel/form-autocomplete;1", &rv);
|
||||
sInstance =
|
||||
do_GetService("@mozilla.org/satchel/form-history-autocomplete;1", &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ClearOnShutdown(&sInstance);
|
||||
|
|
@ -64,14 +65,14 @@ static nsIFormAutoComplete* GetFormAutoComplete() {
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION(nsFormFillController, mController, mLoginManagerAC,
|
||||
mFocusedPopup, mPopups, mLastListener,
|
||||
mLastFormAutoComplete)
|
||||
mLastFormHistoryAutoComplete)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFormFillController)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFormFillController)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIFormFillController)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteInput)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteSearch)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIFormAutoCompleteObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIFormFillCompleteObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
||||
|
|
@ -705,13 +706,13 @@ nsFormFillController::StartSearch(const nsAString& aSearchString,
|
|||
MaybeObserveDataListMutations();
|
||||
}
|
||||
|
||||
auto formAutoComplete = GetFormAutoComplete();
|
||||
NS_ENSURE_TRUE(formAutoComplete, NS_ERROR_FAILURE);
|
||||
auto* formHistoryAutoComplete = GetFormHistoryAutoComplete();
|
||||
NS_ENSURE_TRUE(formHistoryAutoComplete, NS_ERROR_FAILURE);
|
||||
|
||||
formAutoComplete->AutoCompleteSearchAsync(aSearchParam, aSearchString,
|
||||
mFocusedInput, aPreviousResult,
|
||||
addDataList, this);
|
||||
mLastFormAutoComplete = formAutoComplete;
|
||||
formHistoryAutoComplete->AutoCompleteSearchAsync(
|
||||
aSearchParam, aSearchString, mFocusedInput, aPreviousResult,
|
||||
addDataList, this);
|
||||
mLastFormHistoryAutoComplete = formHistoryAutoComplete;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
@ -760,10 +761,10 @@ void nsFormFillController::RevalidateDataList() {
|
|||
NS_IMETHODIMP
|
||||
nsFormFillController::StopSearch() {
|
||||
// Make sure to stop and clear this, otherwise the controller will prevent
|
||||
// mLastFormAutoComplete from being deleted.
|
||||
if (mLastFormAutoComplete) {
|
||||
mLastFormAutoComplete->StopAutoCompleteSearch();
|
||||
mLastFormAutoComplete = nullptr;
|
||||
// mLastFormHistoryAutoComplete from being deleted.
|
||||
if (mLastFormHistoryAutoComplete) {
|
||||
mLastFormHistoryAutoComplete->StopAutoCompleteSearch();
|
||||
mLastFormHistoryAutoComplete = nullptr;
|
||||
}
|
||||
|
||||
if (mLoginManagerAC) {
|
||||
|
|
@ -773,7 +774,7 @@ nsFormFillController::StopSearch() {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//// nsIFormAutoCompleteObserver
|
||||
//// nsIFormFillCompleteObserver
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormFillController::OnSearchCompletion(nsIAutoCompleteResult* aResult) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include "nsIAutoCompleteController.h"
|
||||
#include "nsIAutoCompletePopup.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIFormAutoComplete.h"
|
||||
#include "nsIFormHistoryAutoComplete.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
|
@ -37,7 +37,7 @@ class HTMLInputElement;
|
|||
class nsFormFillController final : public nsIFormFillController,
|
||||
public nsIAutoCompleteInput,
|
||||
public nsIAutoCompleteSearch,
|
||||
public nsIFormAutoCompleteObserver,
|
||||
public nsIFormFillCompleteObserver,
|
||||
public nsIDOMEventListener,
|
||||
public nsIObserver,
|
||||
public nsMultiMutationObserver {
|
||||
|
|
@ -46,7 +46,7 @@ class nsFormFillController final : public nsIFormFillController,
|
|||
NS_DECL_NSIFORMFILLCONTROLLER
|
||||
NS_DECL_NSIAUTOCOMPLETESEARCH
|
||||
NS_DECL_NSIAUTOCOMPLETEINPUT
|
||||
NS_DECL_NSIFORMAUTOCOMPLETEOBSERVER
|
||||
NS_DECL_NSIFORMFILLCOMPLETEOBSERVER
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIMUTATIONOBSERVER
|
||||
|
|
@ -122,7 +122,7 @@ class nsFormFillController final : public nsIFormFillController,
|
|||
nsCOMPtr<nsIAutoCompleteObserver> mLastListener;
|
||||
|
||||
// This is cleared by StopSearch().
|
||||
nsCOMPtr<nsIFormAutoComplete> mLastFormAutoComplete;
|
||||
nsCOMPtr<nsIFormHistoryAutoComplete> mLastFormHistoryAutoComplete;
|
||||
nsString mLastSearchString;
|
||||
|
||||
nsTHashMap<nsPtrHashKey<const nsINode>, bool> mPwmgrInputs;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIAutoCompletePopup;
|
||||
interface nsIAutoCompleteResult;
|
||||
|
||||
webidl Document;
|
||||
webidl Element;
|
||||
|
|
@ -67,3 +68,16 @@ interface nsIFormFillController : nsISupports
|
|||
*/
|
||||
[can_run_script] void showPopup();
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(604419ab-55a0-4831-9eca-1b9e67cc4751)]
|
||||
interface nsIFormFillCompleteObserver : nsISupports
|
||||
{
|
||||
/*
|
||||
* Called when a search is complete and the results are ready even if the
|
||||
* result set is empty. If the search is cancelled or a new search is
|
||||
* started, this is not called.
|
||||
*
|
||||
* @param result - The search result object
|
||||
*/
|
||||
[can_run_script] void onSearchCompletion(in nsIAutoCompleteResult result);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIAutoCompleteResult;
|
||||
interface nsIFormAutoCompleteObserver;
|
||||
interface nsIFormFillCompleteObserver;
|
||||
interface nsIPropertyBag2;
|
||||
|
||||
webidl HTMLInputElement;
|
||||
|
||||
[scriptable, uuid(bfd9b82b-0ab3-4b6b-9e54-aa961ff4b732)]
|
||||
interface nsIFormAutoComplete: nsISupports {
|
||||
interface nsIFormHistoryAutoComplete: nsISupports {
|
||||
/**
|
||||
* Generate results for a form input autocomplete menu asynchronously.
|
||||
*/
|
||||
|
|
@ -21,7 +21,7 @@ interface nsIFormAutoComplete: nsISupports {
|
|||
in HTMLInputElement aField,
|
||||
in nsIAutoCompleteResult aPreviousResult,
|
||||
in bool aAddDatalist,
|
||||
in nsIFormAutoCompleteObserver aListener);
|
||||
in nsIFormFillCompleteObserver aListener);
|
||||
|
||||
/**
|
||||
* If a search is in progress, stop it. Otherwise, do nothing. This is used
|
||||
|
|
@ -29,16 +29,3 @@ interface nsIFormAutoComplete: nsISupports {
|
|||
*/
|
||||
void stopAutoCompleteSearch();
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(604419ab-55a0-4831-9eca-1b9e67cc4751)]
|
||||
interface nsIFormAutoCompleteObserver : nsISupports
|
||||
{
|
||||
/*
|
||||
* Called when a search is complete and the results are ready even if the
|
||||
* result set is empty. If the search is cancelled or a new search is
|
||||
* started, this is not called.
|
||||
*
|
||||
* @param result - The search result object
|
||||
*/
|
||||
[can_run_script] void onSearchCompletion(in nsIAutoCompleteResult result);
|
||||
};
|
||||
|
|
@ -39,8 +39,8 @@ function run_test() {
|
|||
|
||||
testfile.copyTo(profileDir, "formhistory.sqlite");
|
||||
|
||||
fac = Cc["@mozilla.org/satchel/form-autocomplete;1"].getService(
|
||||
Ci.nsIFormAutoComplete
|
||||
fac = Cc["@mozilla.org/satchel/form-history-autocomplete;1"].getService(
|
||||
Ci.nsIFormHistoryAutoComplete
|
||||
);
|
||||
|
||||
timeGroupingSize =
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
FormAutoCompleteResult: "resource://gre/modules/FormAutoComplete.sys.mjs",
|
||||
FormHistoryClient: "resource://gre/modules/FormAutoComplete.sys.mjs",
|
||||
FormHistoryAutoCompleteResult:
|
||||
"resource://gre/modules/FormHistoryAutoComplete.sys.mjs",
|
||||
FormHistoryClient: "resource://gre/modules/FormHistoryAutoComplete.sys.mjs",
|
||||
|
||||
SearchSuggestionController:
|
||||
"resource://gre/modules/SearchSuggestionController.sys.mjs",
|
||||
|
|
@ -29,7 +30,7 @@ class SuggestAutoComplete {
|
|||
/**
|
||||
* Notifies the front end of new results.
|
||||
*
|
||||
* @param {FormAutoCompleteResult} result
|
||||
* @param {FormHistoryAutoCompleteResult} result
|
||||
* Any previous form history result.
|
||||
* @private
|
||||
*/
|
||||
|
|
@ -168,7 +169,7 @@ class SuggestAutoComplete {
|
|||
...historyEntry,
|
||||
})
|
||||
);
|
||||
let autoCompleteResult = new lazy.FormAutoCompleteResult(
|
||||
let autoCompleteResult = new lazy.FormHistoryAutoCompleteResult(
|
||||
client,
|
||||
formHistoryEntries,
|
||||
this.#suggestionController.formHistoryParam,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const SEARCH_TELEMETRY_LATENCY = "SEARCH_SUGGESTIONS_LATENCY_MS";
|
|||
|
||||
// We must make sure the FormHistoryStartup component is
|
||||
// initialized in order for it to respond to FormHistory
|
||||
// requests from nsFormAutoComplete.js.
|
||||
// requests from FormHistoryAutoComplete.sys.mjs.
|
||||
var formHistoryStartup = Cc[
|
||||
"@mozilla.org/satchel/form-history-startup;1"
|
||||
].getService(Ci.nsIObserver);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const { SearchSuggestionController } = ChromeUtils.importESModule(
|
|||
|
||||
// We must make sure the FormHistoryStartup component is
|
||||
// initialized in order for it to respond to FormHistory
|
||||
// requests from nsFormAutoComplete.js.
|
||||
// requests from FormHistoryAutoComplete.sys.mjs.
|
||||
var formHistoryStartup = Cc[
|
||||
"@mozilla.org/satchel/form-history-startup;1"
|
||||
].getService(Ci.nsIObserver);
|
||||
|
|
|
|||
|
|
@ -566,8 +566,8 @@
|
|||
"resource://gre/modules/FirefoxRelay.jsm": "toolkit/components/passwordmgr/FirefoxRelay.jsm",
|
||||
"resource://gre/modules/FirstStartup.jsm": "toolkit/modules/FirstStartup.jsm",
|
||||
"resource://gre/modules/ForgetAboutSite.jsm": "toolkit/components/forgetaboutsite/ForgetAboutSite.jsm",
|
||||
"resource://gre/modules/FormAutoComplete.jsm": "toolkit/components/satchel/FormAutoComplete.jsm",
|
||||
"resource://gre/modules/FormHistory.jsm": "toolkit/components/satchel/FormHistory.jsm",
|
||||
"resource://gre/modules/FormAutoComplete.jsm": "toolkit/components/satchel/FormHistoryAutoComplete.jsm",
|
||||
"resource://gre/modules/FormHistoryStartup.jsm": "toolkit/components/satchel/FormHistoryStartup.jsm",
|
||||
"resource://gre/modules/FormLikeFactory.jsm": "toolkit/modules/FormLikeFactory.jsm",
|
||||
"resource://gre/modules/FxAccounts.jsm": "services/fxaccounts/FxAccounts.jsm",
|
||||
|
|
|
|||
Loading…
Reference in a new issue