3 const nav_history_service = Cc["@mozilla.org/browser/nav-history-service;1"]
4 .getService(Ci.nsINavHistoryService);
6 define_keywords("$use_webjumps", "$use_history", "$use_bookmarks");
7 function history_completer() {
9 var use_history = arguments.$use_history;
10 var use_bookmarks = arguments.$use_bookmarks;
11 return function (input, pos, conservative) {
12 if (conservative && input.length == 0)
14 var query = nav_history_service.getNewQuery();
15 query.searchTerms = input;
17 query.onlyBookmarked = true;
18 var options = nav_history_service.getNewQueryOptions();
19 options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
20 var root = nav_history_service.executeQuery(query, options).root;
21 root.containerOpen = true;
22 var history_count = root.childCount;
23 return {count: history_count,
24 get_string: function (i) root.getChild(i).uri,
25 get_description: function (i) root.getChild(i).title,
26 get_input_state: function (i) [root.getChild(i).uri],
27 destroy: function () { root.containerOpen = false; }
32 function url_completer() {
34 var use_webjumps = arguments.$use_webjumps;
35 var use_history = arguments.$use_history;
36 var use_bookmarks = arguments.$use_bookmarks;
38 completers.push(file_path_completer());
40 completers.push(webjump_completer());
42 if(use_history || use_bookmarks) {
43 completers.push(history_completer($use_history = use_history,
44 $use_bookmarks = use_bookmarks));
46 return merge_completers(completers);
49 const nav_bookmarks_service = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
51 function add_bookmark(url, title) {
52 nav_bookmarks_service.insertBookmark(nav_bookmarks_service.unfiledBookmarksFolder,
53 makeURL(url), -1, title);