зеркало из https://github.com/mozilla/gecko-dev.git
Merged
This commit is contained in:
Коммит
a5da49ac2f
|
@ -88,11 +88,23 @@ HistoryStore.prototype = {
|
||||||
getService(Ci.nsINavHistoryService);
|
getService(Ci.nsINavHistoryService);
|
||||||
hsvc.QueryInterface(Ci.nsIGlobalHistory2);
|
hsvc.QueryInterface(Ci.nsIGlobalHistory2);
|
||||||
hsvc.QueryInterface(Ci.nsIBrowserHistory);
|
hsvc.QueryInterface(Ci.nsIBrowserHistory);
|
||||||
|
hsvc.QueryInterface(Ci.nsPIPlacesDatabase);
|
||||||
this.__defineGetter__("_hsvc", function() hsvc);
|
this.__defineGetter__("_hsvc", function() hsvc);
|
||||||
return hsvc;
|
return hsvc;
|
||||||
},
|
},
|
||||||
|
|
||||||
get _histDB() {
|
get _anno() {
|
||||||
|
let anno = Cc["@mozilla.org/browser/annotation-service;1"].
|
||||||
|
getService(Ci.nsIAnnotationService);
|
||||||
|
this.__defineGetter__("_ans", function() anno);
|
||||||
|
return anno;
|
||||||
|
},
|
||||||
|
|
||||||
|
get _histDB_31() {
|
||||||
|
return this._hsvc.DBConnection;
|
||||||
|
},
|
||||||
|
|
||||||
|
get _histDB_30() {
|
||||||
let file = Cc["@mozilla.org/file/directory_service;1"].
|
let file = Cc["@mozilla.org/file/directory_service;1"].
|
||||||
getService(Ci.nsIProperties).
|
getService(Ci.nsIProperties).
|
||||||
get("ProfD", Ci.nsIFile);
|
get("ProfD", Ci.nsIFile);
|
||||||
|
@ -100,13 +112,44 @@ HistoryStore.prototype = {
|
||||||
let stor = Cc["@mozilla.org/storage/service;1"].
|
let stor = Cc["@mozilla.org/storage/service;1"].
|
||||||
getService(Ci.mozIStorageService);
|
getService(Ci.mozIStorageService);
|
||||||
let db = stor.openDatabase(file);
|
let db = stor.openDatabase(file);
|
||||||
this.__defineGetter__("_histDB", function() db);
|
this.__defineGetter__("_histDB_30", function() db);
|
||||||
return db;
|
return db;
|
||||||
},
|
},
|
||||||
|
|
||||||
_itemExists: function HistStore__itemExists(GUID) {
|
get _db() {
|
||||||
// we don't care about already-existing items; just try to re-add them
|
// FIXME
|
||||||
return false;
|
//if (fx3.0)
|
||||||
|
// return this._histDB_30;
|
||||||
|
//else
|
||||||
|
return this._histDB_31;
|
||||||
|
},
|
||||||
|
|
||||||
|
get _visitStm() {
|
||||||
|
let stmt = this._db.createStatement(
|
||||||
|
"SELECT visit_type FROM moz_historyvisits WHERE place_id = ?1");
|
||||||
|
this.__defineGetter__("_visitStm", function() stmt);
|
||||||
|
return stmt;
|
||||||
|
},
|
||||||
|
|
||||||
|
get _pidStm() {
|
||||||
|
let stmt = this._db.createStatement(
|
||||||
|
"SELECT id FROM moz_places WHERE url = ?1");
|
||||||
|
this.__defineGetter__("_pidStm", function() stmt);
|
||||||
|
return stmt;
|
||||||
|
},
|
||||||
|
|
||||||
|
get _urlStm() {
|
||||||
|
let stmt = this._db.createStatement(
|
||||||
|
"SELECT url FROM moz_places WHERE id = ?1");
|
||||||
|
this.__defineGetter__("_urlStm", function() stmt);
|
||||||
|
return stmt;
|
||||||
|
},
|
||||||
|
|
||||||
|
get _findPidByAnnoStm() {
|
||||||
|
let stmt = this._db.createStatement(
|
||||||
|
"SELECT place_id FROM moz_annos WHERE type = ?1 AND content = ?2");
|
||||||
|
this.__defineGetter__("_findPidByAnnoStm", function() stmt);
|
||||||
|
return stmt;
|
||||||
},
|
},
|
||||||
|
|
||||||
_createCommand: function HistStore__createCommand(command) {
|
_createCommand: function HistStore__createCommand(command) {
|
||||||
|
@ -138,68 +181,79 @@ HistoryStore.prototype = {
|
||||||
// FIXME: implement!
|
// FIXME: implement!
|
||||||
},
|
},
|
||||||
|
|
||||||
_historyRoot: function HistStore__historyRoot() {
|
// See bug 320831 for why we use SQL here
|
||||||
let query = this._hsvc.getNewQuery(),
|
_getVisitType: function HistStore__getVisitType(uri) {
|
||||||
options = this._hsvc.getNewQueryOptions();
|
this._pidStm.bindUTF8StringParameter(0, uri);
|
||||||
|
if (this._pidStm.executeStep()) {
|
||||||
query.minVisits = 1;
|
let placeId = this._pidStm.getInt32(0);
|
||||||
options.maxResults = 1000;
|
this._visitStm.bindInt32Parameter(0, placeId);
|
||||||
options.resultType = options.RESULTS_AS_VISIT; // FULL_VISIT does not work
|
if (this._visitStm.executeStep())
|
||||||
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
|
return this._visitStm.getInt32(0);
|
||||||
options.queryType = options.QUERY_TYPE_HISTORY;
|
}
|
||||||
|
return null;
|
||||||
let root = this._hsvc.executeQuery(query, options).root;
|
|
||||||
root.QueryInterface(Ci.nsINavHistoryQueryResultNode);
|
|
||||||
return root;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/* UGLY, UGLY way of syncing visit type !
|
_getGUID: function HistStore__getAnno(uri) {
|
||||||
We'll just have to wait for bug #320831 */
|
try {
|
||||||
_getVisitType: function HistStore__getVisitType(uri) {
|
return this._anno.getPageAnnotation(uri, "weave/guid");
|
||||||
let visitStmnt = this._histDB.createStatement("SELECT visit_type FROM moz_historyvisits WHERE place_id = ?1");
|
} catch (e) {
|
||||||
let pidStmnt = this._histDB.createStatement("SELECT id FROM moz_places WHERE url = ?1");
|
// FIXME
|
||||||
|
// if (e != NS_ERROR_NOT_AVAILABLE)
|
||||||
pidStmnt.bindUTF8StringParameter(0, uri);
|
// throw e;
|
||||||
|
|
||||||
let placeID = null;
|
|
||||||
if (pidStmnt.executeStep()) {
|
|
||||||
placeID = pidStmnt.getInt32(0);
|
|
||||||
}
|
}
|
||||||
|
let guid = Utils.makeGUID();
|
||||||
|
this._anno.setPageAnnotation(uri, "weave/guid", guid, 0, 0);
|
||||||
|
return guid;
|
||||||
|
},
|
||||||
|
|
||||||
if (placeID) {
|
// See bug 468732 for why we use SQL here
|
||||||
visitStmnt.bindInt32Parameter(0, placeID);
|
_findURLByGUID: function HistStore__findByGUID(guid) {
|
||||||
if (visitStmnt.executeStep())
|
this._findPidByAnnoStm.bindUTF8Parameter(0, "weave/guid");
|
||||||
return visitStmnt.getInt32(0);
|
this._findPidByAnnoStm.bindUTF8Parameter(1, guid);
|
||||||
|
if (this._findPidByAnnoStm.executeStep()) {
|
||||||
|
let placeId = this._findPidByAnnoStm.getInt32(0);
|
||||||
|
this._urlStm.bindInt32Parameter(0, placeId);
|
||||||
|
if (this._urlStm.executeStep()) {
|
||||||
|
return this._urlStm.getString(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
wrap: function HistStore_wrap() {
|
wrap: function HistStore_wrap() {
|
||||||
let root = this._historyRoot();
|
let query = this._hsvc.getNewQuery(),
|
||||||
|
options = this._hsvc.getNewQueryOptions();
|
||||||
|
|
||||||
|
query.minVisits = 1;
|
||||||
|
|
||||||
|
let root = this._hsvc.executeQuery(query, options).root;
|
||||||
|
root.QueryInterface(Ci.nsINavHistoryQueryResultNode);
|
||||||
root.containerOpen = true;
|
root.containerOpen = true;
|
||||||
|
|
||||||
let items = {};
|
let items = {};
|
||||||
for (let i = 0; i < root.childCount; i++) {
|
for (let i = 0; i < root.childCount; i++) {
|
||||||
let item = root.getChild(i);
|
let item = root.getChild(i);
|
||||||
let guid = item.time + ":" + item.uri;
|
let guid = this._getGUID(item.uri);
|
||||||
let vType = this._getVisitType(item.uri);
|
let vType = this._getVisitType(item.uri);
|
||||||
items[guid] = {parentid: '',
|
items[guid] = {title: item.title,
|
||||||
title: item.title,
|
|
||||||
URI: item.uri,
|
URI: item.uri,
|
||||||
time: item.time,
|
|
||||||
transition: vType};
|
transition: vType};
|
||||||
|
// FIXME: get last 10 visit times (& transitions ?)
|
||||||
}
|
}
|
||||||
|
|
||||||
this._lookup = items;
|
|
||||||
return items;
|
return items;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
wrapItem: function HistStore_wrapItem(id) {
|
||||||
|
// FIXME: use findURLByGUID! (not so important b/c of cache hints though)
|
||||||
|
if (this._itemCache)
|
||||||
|
return this._itemCache[id];
|
||||||
|
let all = this._wrap();
|
||||||
|
return all[id];
|
||||||
|
},
|
||||||
|
|
||||||
wipe: function HistStore_wipe() {
|
wipe: function HistStore_wipe() {
|
||||||
this._hsvc.removeAllPages();
|
this._hsvc.removeAllPages();
|
||||||
},
|
|
||||||
|
|
||||||
_resetGUIDs: function FormStore__resetGUIDs() {
|
|
||||||
let self = yield;
|
|
||||||
// Not needed.
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче