Bug 566746 - Create new module FormHistory.jsm with handles asynchronous form history, p=enndeakin,felix, r=mak

This commit is contained in:
Felix Fung 2011-11-28 21:57:13 -08:00
Родитель 1f6b12f15a
Коммит 8365cf67e7
7 изменённых файлов: 1131 добавлений и 0 удалений

Просмотреть файл

@ -445,6 +445,7 @@
@BINPATH@/components/satchel.manifest
@BINPATH@/components/nsFormAutoComplete.js
@BINPATH@/components/nsFormHistory.js
@BINPATH@/components/FormHistoryStartup.js
@BINPATH@/components/nsInputListAutoComplete.js
@BINPATH@/components/contentSecurityPolicy.manifest
@BINPATH@/components/contentSecurityPolicy.js

Просмотреть файл

@ -432,6 +432,7 @@
@BINPATH@/components/satchel.manifest
@BINPATH@/components/nsFormAutoComplete.js
@BINPATH@/components/nsFormHistory.js
@BINPATH@/components/FormHistoryStartup.js
@BINPATH@/components/nsInputListAutoComplete.js
@BINPATH@/components/contentSecurityPolicy.manifest
@BINPATH@/components/contentSecurityPolicy.js

Просмотреть файл

@ -343,6 +343,7 @@
@BINPATH@/components/satchel.manifest
@BINPATH@/components/nsFormAutoComplete.js
@BINPATH@/components/nsFormHistory.js
@BINPATH@/components/FormHistoryStartup.js
@BINPATH@/components/nsInputListAutoComplete.js
@BINPATH@/components/contentSecurityPolicy.manifest
@BINPATH@/components/contentSecurityPolicy.js

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,78 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const Cc = Components.classes;
const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FormHistory",
"resource://gre/modules/FormHistory.jsm");
function FormHistoryStartup() { }
FormHistoryStartup.prototype = {
classID: Components.ID("{3A0012EB-007F-4BB8-AA81-A07385F77A25}"),
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIObserver,
Ci.nsISupportsWeakReference,
Ci.nsIFrameMessageListener
]),
observe: function(subject, topic, data) {
switch (topic) {
case "nsPref:changed":
FormHistory.updatePrefs();
break;
case "idle-daily":
case "formhistory-expire-now":
FormHistory.expireOldEntries();
break;
case "profile-before-change":
FormHistory.shutdown();
break;
case "profile-after-change":
this.init();
default:
break;
}
},
inited: false,
init: function()
{
if (this.inited)
return;
this.inited = true;
Services.prefs.addObserver("browser.formfill.", this, true);
// triggers needed service cleanup and db shutdown
Services.obs.addObserver(this, "profile-before-change", true);
Services.obs.addObserver(this, "formhistory-expire-now", true);
let messageManager = Cc["@mozilla.org/globalmessagemanager;1"].
getService(Ci.nsIMessageListenerManager);
messageManager.loadFrameScript("chrome://satchel/content/formSubmitListener.js", true);
messageManager.addMessageListener("FormHistory:FormSubmitEntries", this);
},
receiveMessage: function(message) {
let entries = message.json;
let changes = entries.map(function(entry) {
return {
op : "bump",
fieldname : entry.name,
value : entry.value,
}
});
FormHistory.update(changes);
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([FormHistoryStartup]);

Просмотреть файл

@ -25,6 +25,7 @@ CPPSRCS = \
EXTRA_COMPONENTS = \
nsFormAutoComplete.js \
FormHistoryStartup.js \
nsInputListAutoComplete.js \
satchel.manifest \
$(NULL)
@ -34,6 +35,7 @@ EXTRA_PP_COMPONENTS = \
$(NULL)
EXTRA_JS_MODULES = \
FormHistory.jsm \
nsFormAutoCompleteResult.jsm \
$(NULL)

Просмотреть файл

@ -4,3 +4,7 @@ component {c11c21b2-71c9-4f87-a0f8-5e13f50495fd} nsFormAutoComplete.js
contract @mozilla.org/satchel/form-autocomplete;1 {c11c21b2-71c9-4f87-a0f8-5e13f50495fd}
component {bf1e01d0-953e-11df-981c-0800200c9a66} nsInputListAutoComplete.js
contract @mozilla.org/satchel/inputlist-autocomplete;1 {bf1e01d0-953e-11df-981c-0800200c9a66}
component {3a0012eb-007f-4bb8-aa81-a07385f77a25} FormHistoryStartup.js
contract @mozilla.org/satchel/form-history-startup;1 {3a0012eb-007f-4bb8-aa81-a07385f77a25}
category profile-after-change formHistoryStartup @mozilla.org/satchel/form-history-startup;1
category idle-daily formHistoryStartup @mozilla.org/satchel/form-history-startup;1