Thank you for notification.
I created 2 patches.
use_services_jsm.patch ::
not get XPCOM component object directly but get from Services.jsm.
Can get preferenceService without nsIPrefBracn2 interface implicitly
CAUTION: some required the argument of services.get is changed.
ex.) services.get("pref") => services.get("prefs")
remove_livemarkService.patch ::
remove livemark code from service.js
and use PlacesUtils.livemarks if need.
Best regards.
Post by Martin StubenschrottSorry for the update, I was just notified that the validation-results needs
special permissions,
(This really reminds me, to finally start the cleaning up, Vimperator with
too many obscure
features is just a maintainance-nightmare with the always faster Firefox
release cycle).
=========================
Deprecated interface in use
Error: This add-on uses nsILivemarkService, which has been deprecated in
Gecko 13. Some of its functions may not work as expected.
mozIAsyncLivemarks should be used instead.
Error: See bug https://bugzilla.mozilla.org/show_bug.cgi?id=613588<http://outgoing.mozilla.org/v1/ff146d0977bf546b20eebb880e18507183071a01/https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid=613588>for
more information.
common/content/services.js
73
74
75
iface: Ci.nsILivemarkService
},
Deprecated interface in use
Warning: This add-on uses nsIPrefBranch2, which has been merged into
nsIPrefBranch in Gecko 13. Once you drop support for old versions of Gecko,
you should stop using nsIPrefBranch2. You can use the == operator as an
alternative.
Warning: See bug
https://bugzilla.mozilla.org/show_bug.cgi?id=718255<http://outgoing.mozilla.org/v1/7ca2cb32855bd9eb2fe961ab46093526a10da93f/https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid=718255>for
more information.
common/content/services.js
81
82
83
iface: [Ci.nsIPrefService, Ci.nsIPrefBranch, Ci.nsIPrefBranch2]
},
Deprecated interface in use
Warning: This add-on uses nsIPrefBranch2, which has been merged into
nsIPrefBranch in Gecko 13. Once you drop support for old versions of Gecko,
you should stop using nsIPrefBranch2. You can use the == operator as an
alternative.
Warning: See bug
https://bugzilla.mozilla.org/show_bug.cgi?id=718255<http://outgoing.mozilla.org/v1/7ca2cb32855bd9eb2fe961ab46093526a10da93f/https%3A//bugzilla.mozilla.org/show_bug.cgi%3Fid=718255>for
more information.
common/content/options.js
487
488
489
// better way to monitor all changes?
this._branch =
services.get("pref").getBranch("").QueryInterface(Ci.nsIPrefBranch2);
this._branch.addObserver("", this, false);
_______________________________________________
Vimperator mailing list
Vimperator at mozdev.org
https://www.mozdev.org/mailman/listinfo/vimperator
-------------- next part --------------
# HG changeset patch
# User teramako <teramako at gmail.com>
# Date 1338073371 -32400
# Node ID 4d2fe38750987f26a283103d3a25ad90a3760786
# Parent bb4f9baee9138d7f9006055a5e03ac7b9609f165
use Services.jsm's properties
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/bookmarks.js
--- a/common/content/bookmarks.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/bookmarks.js Sun May 27 08:02:51 2012 +0900
@@ -309,7 +309,7 @@
// also ensures that each search engine has a Liberator-friendly alias
getSearchEngines: function getSearchEngines() {
let searchEngines = [];
- for (let [, engine] in Iterator(services.get("browserSearch").getVisibleEngines({}))) {
+ for (let [, engine] in Iterator(services.get("search").getVisibleEngines({}))) {
let alias = engine.alias;
if (!alias || !/^[a-z0-9_-]+$/.test(alias))
alias = engine.name.replace(/^\W*([a-zA-Z_-]+).*/, "$1").toLowerCase();
@@ -337,7 +337,7 @@
getSuggestions: function getSuggestions(engineName, query, callback) {
const responseType = "application/x-suggestions+json";
- let engine = services.get("browserSearch").getEngineByAlias(engineName);
+ let engine = services.get("search").getEngineByAlias(engineName);
if (engine && engine.supportsResponseType(responseType))
var queryURI = engine.getSubmission(query, responseType).uri.spec;
if (!queryURI)
@@ -389,7 +389,7 @@
param = url.substr(offset + 1);
}
- var engine = services.get("browserSearch").getEngineByAlias(keyword);
+ var engine = services.get("search").getEngineByAlias(keyword);
if (engine) {
var submission = engine.getSubmission(param, null);
return [submission.uri.spec, submission.postData];
@@ -742,7 +742,7 @@
let engineList = (engineAliases || options["suggestengines"] || "google").split(",");
engineList.forEach(function (name) {
- let engine = services.get("browserSearch").getEngineByAlias(name);
+ let engine = services.get("search").getEngineByAlias(name);
if (!engine)
return;
let [, word] = /^\s*(\S+)/.exec(context.filter) || [];
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/browser.js
--- a/common/content/browser.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/browser.js Sun May 27 08:02:51 2012 +0900
@@ -65,8 +65,8 @@
storage.newObject("private-mode", function () {
({
init: function () {
- services.get("observer").addObserver(this, "private-browsing", false);
- services.get("observer").addObserver(this, "quit-application", false);
+ services.get("obs").addObserver(this, "private-browsing", false);
+ services.get("obs").addObserver(this, "quit-application", false);
this.private = services.get("privateBrowsing").privateBrowsingEnabled;
},
observe: function (subject, topic, data) {
@@ -78,8 +78,8 @@
storage.fireEvent("private-mode", "change", storage.privateMode);
}
else if (topic == "quit-application") {
- services.get("observer").removeObserver(this, "quit-application");
- services.get("observer").removeObserver(this, "private-browsing");
+ services.get("obs").removeObserver(this, "quit-application");
+ services.get("obs").removeObserver(this, "private-browsing");
}
}
}).init();
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/commandline.js
--- a/common/content/commandline.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/commandline.js Sun May 27 08:02:51 2012 +0900
@@ -29,8 +29,8 @@
CLEAR: "browser:purge-session-history",
QUIT: "quit-application",
init: function () {
- services.get("observer").addObserver(this, this.CLEAR, false);
- services.get("observer").addObserver(this, this.QUIT, false);
+ services.get("obs").addObserver(this, this.CLEAR, false);
+ services.get("obs").addObserver(this, this.QUIT, false);
},
observe: function (subject, topic, data) {
switch (topic) {
@@ -40,8 +40,8 @@
});
break;
case this.QUIT:
- services.get("observer").removeObserver(this, this.CLEAR);
- services.get("observer").removeObserver(this, this.QUIT);
+ services.get("obs").removeObserver(this, this.CLEAR);
+ services.get("obs").removeObserver(this, this.QUIT);
break;
}
}
@@ -1556,7 +1556,7 @@
"stringlist", "google",
{
completer: function completer(value) {
- let engines = services.get("browserSearch").getEngines({})
+ let engines = services.get("search").getEngines({})
.filter(function (engine) engine.supportsResponseType("application/x-suggestions+json"));
return engines.map(function (engine) [engine.alias, engine.description]);
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/io.js
--- a/common/content/io.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/io.js Sun May 27 08:02:51 2012 +0900
@@ -323,7 +323,7 @@
requires: ["config", "services"],
init: function () {
- this._processDir = services.get("directory").get("CurWorkD", Ci.nsIFile);
+ this._processDir = services.get("dirsvc").get("CurWorkD", Ci.nsIFile);
this._cwd = this._processDir;
this._oldcwd = null;
@@ -485,7 +485,7 @@
* @returns {File}
*/
createTempFile: function () {
- let file = services.get("directory").get("TmpD", Ci.nsIFile);
+ let file = services.get("dirsvc").get("TmpD", Ci.nsIFile);
file.append(config.tempFile);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
@@ -817,7 +817,7 @@
*/
get PATH_SEP() {
delete this.PATH_SEP;
- let f = services.get("directory").get("CurProcD", Ci.nsIFile);
+ let f = services.get("dirsvc").get("CurProcD", Ci.nsIFile);
f.append("foo");
return this.PATH_SEP = f.path.substr(f.parent.path.length, 1);
}
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/liberator.js
--- a/common/content/liberator.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/liberator.js Sun May 27 08:02:51 2012 +0900
@@ -64,7 +64,7 @@
// current profile. These will differ if the current process was run
// without explicitly selecting a profile.
/** @property {string} The name of the current user profile. */
- this.profileName = services.get("directory").get("ProfD", Ci.nsIFile).leafName.replace(/^.+?\./, "");
+ this.profileName = services.get("dirsvc").get("ProfD", Ci.nsIFile).leafName.replace(/^.+?\./, "");
let platform = Liberator.getPlatformFeature()
config.features.push(platform);
@@ -333,7 +333,7 @@
loadScript: function (uri, context) {
XML.ignoreWhitespace = false;
XML.prettyPrinting = false;
- services.get("subscriptLoader").loadSubScript(uri, context, "UTF-8");
+ services.get("scriptloader").loadSubScript(uri, context, "UTF-8");
},
eval: function (str, context) {
@@ -446,7 +446,7 @@
* element.
*/
focusContent: function (clearFocusedElement) {
- if (window != services.get("windowWatcher").activeWindow)
+ if (window != services.get("ww").activeWindow)
return;
let elem = config.mainWidget || window.content;
@@ -796,7 +796,7 @@
case liberator.NEW_WINDOW:
window.open();
- let win = services.get("windowMediator").getMostRecentWindow("navigator:browser");
+ let win = services.get("wm").getMostRecentWindow("navigator:browser");
win.loadURI(url, null, postdata);
browser = win.getBrowser();
break;
@@ -835,7 +835,7 @@
options.setPref("browser.startup.page", 1); // start with default homepage session
if (force)
- services.get("appStartup").quit(Ci.nsIAppStartup.eForceQuit);
+ services.get("startup").quit(Ci.nsIAppStartup.eForceQuit);
else
window.goQuitApplication();
},
@@ -913,23 +913,23 @@
restart: function () {
// notify all windows that an application quit has been requested.
var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
- services.get("observer").notifyObservers(cancelQuit, "quit-application-requested", null);
+ services.get("obs").notifyObservers(cancelQuit, "quit-application-requested", null);
// something aborted the quit process.
if (cancelQuit.data)
return;
// notify all windows that an application quit has been granted.
- services.get("observer").notifyObservers(null, "quit-application-granted", null);
+ services.get("obs").notifyObservers(null, "quit-application-granted", null);
// enumerate all windows and call shutdown handlers
- let windows = services.get("windowMediator").getEnumerator(null);
+ let windows = services.get("wm").getEnumerator(null);
while (windows.hasMoreElements()) {
let win = windows.getNext();
if (("tryToClose" in win) && !win.tryToClose())
return;
}
- services.get("appStartup").quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
+ services.get("startup").quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
},
/**
@@ -1008,7 +1008,7 @@
*/
get windows() {
let windows = [];
- let enumerator = services.get("windowMediator").getEnumerator("navigator:browser");
+ let enumerator = services.get("wm").getEnumerator("navigator:browser");
while (enumerator.hasMoreElements())
windows.push(enumerator.getNext());
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/options.js
--- a/common/content/options.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/options.js Sun May 27 08:02:51 2012 +0900
@@ -485,7 +485,7 @@
prefObserver: {
register: function () {
// better way to monitor all changes?
- this._branch = services.get("pref").getBranch("").QueryInterface(Ci.nsIPrefBranch2);
+ this._branch = services.get("prefs").getBranch("").QueryInterface(Ci.nsIPrefBranch2);
this._branch.addObserver("", this, false);
},
@@ -550,7 +550,7 @@
* @param {string} branch The branch in which to search preferences.
* @default ""
*/
- allPrefs: function (branch) services.get("pref").getChildList(branch || "", { value: 0 }),
+ allPrefs: function (branch) services.get("prefs").getChildList(branch || "", { value: 0 }),
/**
* Returns the option with <b>name</b> in the specified <b>scope</b>.
@@ -636,7 +636,7 @@
prefArray.sort();
function prefs() {
for (let [, pref] in Iterator(prefArray)) {
- let userValue = services.get("pref").prefHasUserValue(pref);
+ let userValue = services.get("prefs").prefHasUserValue(pref);
if (onlyNonDefault && !userValue || pref.indexOf(filter) == -1)
continue;
@@ -775,7 +775,7 @@
*/
resetPref: function (name) {
try {
- services.get("pref").clearUserPref(name);
+ services.get("prefs").clearUserPref(name);
}
catch (e) {
// ignore - thrown if not a user set value
@@ -788,7 +788,7 @@
* @param {string} name The preference name.
*/
invertPref: function (name) {
- if (services.get("pref").getPrefType(name) == Ci.nsIPrefBranch.PREF_BOOL)
+ if (services.get("prefs").getPrefType(name) == Ci.nsIPrefBranch.PREF_BOOL)
this.setPref(name, !this.getPref(name));
else
liberator.echoerr("Trailing characters: " + name + "!");
@@ -841,13 +841,13 @@
this._prefContexts[this._prefContexts.length - 1][name] = val;
}
- let type = services.get("pref").getPrefType(name);
+ let type = services.get("prefs").getPrefType(name);
switch (typeof value) {
case "string":
if (type == Ci.nsIPrefBranch.PREF_INVALID || type == Ci.nsIPrefBranch.PREF_STRING) {
let supportString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
supportString.data = value;
- services.get("pref").setComplexValue(name, Ci.nsISupportsString, supportString);
+ services.get("prefs").setComplexValue(name, Ci.nsISupportsString, supportString);
}
else if (type == Ci.nsIPrefBranch.PREF_INT)
liberator.echoerr("Number required after =: " + name + "=" + value);
@@ -856,13 +856,13 @@
break;
case "number":
if (type == Ci.nsIPrefBranch.PREF_INVALID || type == Ci.nsIPrefBranch.PREF_INT)
- services.get("pref").setIntPref(name, value);
+ services.get("prefs").setIntPref(name, value);
else
liberator.echoerr("Invalid argument: " + name + "=" + value);
break;
case "boolean":
if (type == Ci.nsIPrefBranch.PREF_INVALID || type == Ci.nsIPrefBranch.PREF_BOOL)
- services.get("pref").setBoolPref(name, value);
+ services.get("prefs").setBoolPref(name, value);
else if (type == Ci.nsIPrefBranch.PREF_INT)
liberator.echoerr("Number required after =: " + name + "=" + value);
else
@@ -878,14 +878,14 @@
if (forcedDefault != null) // this argument sets defaults for non-user settable options (like extensions.history.comp_history)
defaultValue = forcedDefault;
- let branch = defaultBranch ? services.get("pref").getDefaultBranch("") : services.get("pref");
- let type = services.get("pref").getPrefType(name);
+ let branch = defaultBranch ? services.get("prefs").getDefaultBranch("") : services.get("prefs");
+ let type = services.get("prefs").getPrefType(name);
try {
switch (type) {
case Ci.nsIPrefBranch.PREF_STRING:
let value = branch.getComplexValue(name, Ci.nsISupportsString).data;
// try in case it's a localized string (will throw an exception if not)
- if (!services.get("pref").prefIsLocked(name) && !services.get("pref").prefHasUserValue(name) &&
+ if (!services.get("prefs").prefIsLocked(name) && !services.get("prefs").prefHasUserValue(name) &&
RegExp("chrome://.+/locale/.+\\.properties").test(value))
value = branch.getComplexValue(name, Ci.nsIPrefLocalizedString).data;
return value;
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/sanitizer.js
--- a/common/content/sanitizer.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/sanitizer.js Sun May 27 08:02:51 2012 +0900
@@ -26,7 +26,7 @@
// Largely ripped from from browser/base/content/sanitize.js so we can override
// the pref strategy without stepping on the global prefs namespace.
sanitize: function () {
- const prefService = services.get("pref");
+ const prefService = services.get("prefs");
let branch = prefService.getBranch(this.prefDomain);
let branch2 = prefService.getBranch(this.prefDomain2);
let errors = null;
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/services.js
--- a/common/content/services.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/services.js Sun May 27 08:02:51 2012 +0900
@@ -13,11 +13,8 @@
const Services = Module("services", {
init: function () {
this.classes = {};
+ this.jsm = window.Services;
this.services = {
- "appStartup": {
- class_: "@mozilla.org/toolkit/app-startup;1",
- iface: Ci.nsIAppStartup
- },
"autoCompleteSearch": {
class_: "@mozilla.org/autocomplete/search;1?name=history",
iface: Ci.nsIAutoCompleteSearch
@@ -26,18 +23,6 @@
class_: "@mozilla.org/browser/nav-bookmarks-service;1",
iface: Ci.nsINavBookmarksService
},
- "browserSearch": {
- class_: "@mozilla.org/browser/search-service;1",
- iface: Ci.nsIBrowserSearchService
- },
- "cache": {
- class_: "@mozilla.org/network/cache-service;1",
- iface: Ci.nsICacheService
- },
- "console": {
- class_: "@mozilla.org/consoleservice;1",
- iface: Ci.nsIConsoleService
- },
"liberator:": {
class_: "@mozilla.org/network/protocol;1?name=liberator"
},
@@ -45,10 +30,6 @@
class_: "@mozilla.org/js/jsd/debugger-service;1",
iface: Ci.jsdIDebuggerService
},
- "directory": {
- class_: "@mozilla.org/file/directory_service;1",
- iface: Ci.nsIProperties
- },
"downloadManager": {
class_: "@mozilla.org/download-manager;1",
iface: Ci.nsIDownloadManager
@@ -65,22 +46,10 @@
class_: "@mozilla.org/browser/nav-history-service;1",
iface: [Ci.nsINavHistoryService, Ci.nsIBrowserHistory]
},
- "io": {
- class_: "@mozilla.org/network/io-service;1",
- iface: Ci.nsIIOService
- },
"livemark": {
class_: "@mozilla.org/browser/livemark-service;2",
iface: Ci.nsILivemarkService
},
- "observer": {
- class_: "@mozilla.org/observer-service;1",
- iface: Ci.nsIObserverService
- },
- "pref": {
- class_: "@mozilla.org/preferences-service;1",
- iface: [Ci.nsIPrefService, Ci.nsIPrefBranch, Ci.nsIPrefBranch2]
- },
"privateBrowsing": {
class_: "@mozilla.org/privatebrowsing;1",
iface: Ci.nsIPrivateBrowsingService
@@ -97,26 +66,10 @@
class_: "@mozilla.org/browser/sessionstore;1",
iface: Ci.nsISessionStore
},
- "subscriptLoader": {
- class_: "@mozilla.org/moz/jssubscript-loader;1",
- iface: Ci.mozIJSSubScriptLoader
- },
"threadManager": {
class_: "@mozilla.org/thread-manager;1",
iface: Ci.nsIThreadManager
},
- "windowMediator": {
- class_: "@mozilla.org/appshell/window-mediator;1",
- iface: Ci.nsIWindowMediator
- },
- "windowWatcher": {
- class_: "@mozilla.org/embedcomp/window-watcher;1",
- iface: Ci.nsIWindowWatcher
- },
- "xulAppInfo": {
- class_: "@mozilla.org/xre/app-info;1",
- iface: Ci.nsIXULAppInfo
- }
};
this.addClass("file", "@mozilla.org/file/local;1", Ci.nsILocalFile);
@@ -175,6 +128,9 @@
* @param {string} name The service's cache key.
*/
get: function (name) {
+ if (this.jsm.hasOwnProperty(name))
+ return this.jsm[name];
+
if (!this.services[name]["reference"]) {
var currentService = this.services[name];
@@ -193,7 +149,9 @@
}, {
}, {
completion: function () {
- JavaScript.setCompleter(this.get, [function () services.services]);
+ JavaScript.setCompleter(this.get, [
+ function () Object.keys(services.jsm).concat(Object.keys(services.services)).map(function(key) [key, ""])
+ ]);
JavaScript.setCompleter(this.create, [function () [[c, ""] for (c in services.classes)]]);
}
diff -r bb4f9baee913 -r 4d2fe3875098 common/content/tabs.js
--- a/common/content/tabs.js Sun May 27 05:18:57 2012 +0900
+++ b/common/content/tabs.js Sun May 27 08:02:51 2012 +0900
@@ -525,7 +525,7 @@
if (!tab)
tab = config.tabbrowser.mTabContainer.selectedItem;
- services.get("windowWatcher")
+ services.get("ww")
.openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab);
},
-------------- next part --------------
# HG changeset patch
# User teramako <teramako at gmail.com>
# Date 1338074969 -32400
# Node ID 380a9329259fc5382fad53b53b1fdb8ee48e31eb
# Parent c47203d79cb6db82cae7442945e7b176069c4ec2
nsILivemarkService will be deprecated since Gecho version 13
A livemark item doesn't have id, so the id (gotten by bookmarkService.getBookmarkIdsForURI)
is not livemark item always.
TODO: remove this code when minVersion >= 13
diff -r c47203d79cb6 -r 380a9329259f common/content/bookmarks.js
--- a/common/content/bookmarks.js Sun May 27 08:02:51 2012 +0900
+++ b/common/content/bookmarks.js Sun May 27 08:29:29 2012 +0900
@@ -95,15 +95,22 @@
this.isBookmark = function (id) rootFolders.indexOf(self.findRoot(id)) >= 0;
- this.isRegularBookmark = function findRoot(id) {
- do {
- var root = id;
- if (services.get("livemark") && services.get("livemark").isLivemark(id))
- return false;
- id = bookmarksService.getFolderIdForItem(id);
- } while (id != bookmarksService.placesRoot && id != root);
- return rootFolders.indexOf(root) >= 0;
- };
+ // nsILivemarkService will be deprecated since Gecho version 13
+ // and a livemark item doesn't have id, so the id (gotten by bookmarkService.getBookmarkIdsForURI)
+ // is not livemark item always.
+ // TODO: remove this code when minVersion >= 13
+ this.isRegularBookmark = ("mozIAsyncLivemarks" in Ci) ?
+ function() true :
+ function findRoot(id) {
+ var livemarkService = PlacesUtils.livemarks;
+ do {
+ var root = id;
+ if (livemarkService.isLivemark(id))
+ return false;
+ id = bookmarksService.getFolderIdForItem(id);
+ } while (id != bookmarksService.placesRoot && id != root);
+ return rootFolders.indexOf(root) >= 0;
+ };
// since we don't use a threaded bookmark loading (by set preload)
// anymore, is this loading synchronization still needed? --mst
diff -r c47203d79cb6 -r 380a9329259f common/content/services.js
--- a/common/content/services.js Sun May 27 08:02:51 2012 +0900
+++ b/common/content/services.js Sun May 27 08:29:29 2012 +0900
@@ -46,10 +46,6 @@
class_: "@mozilla.org/browser/nav-history-service;1",
iface: [Ci.nsINavHistoryService, Ci.nsIBrowserHistory]
},
- "livemark": {
- class_: "@mozilla.org/browser/livemark-service;2",
- iface: Ci.nsILivemarkService
- },
"privateBrowsing": {
class_: "@mozilla.org/privatebrowsing;1",
iface: Ci.nsIPrivateBrowsingService