зеркало из https://github.com/mozilla/gecko-dev.git
Bug 519686: Build localized bookmarks data for multi-locale builds and use it, r=mfinkle/pike
This commit is contained in:
Родитель
b8a764f3cc
Коммит
02e5a2d5d2
|
@ -82,22 +82,35 @@ BrowserStartup.prototype = {
|
|||
|
||||
Cu.import("resource://gre/modules/utils.js");
|
||||
|
||||
// Get bookmarks.html file location
|
||||
let dirService = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
try {
|
||||
let observer = {
|
||||
onStreamComplete : function(aLoader, aContext, aStatus, aLength, aResult) {
|
||||
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
|
||||
createInstance(Ci.nsIScriptableUnicodeConverter);
|
||||
let jsonStr = "";
|
||||
try {
|
||||
converter.charset = "UTF-8";
|
||||
jsonStr = converter.convertFromByteArray(aResult, aResult.length);
|
||||
|
||||
let bookmarksFile = dirService.get("profDef", Ci.nsILocalFile);
|
||||
bookmarksFile.append("bookmarks.json");
|
||||
if (bookmarksFile.exists()) {
|
||||
// import the file
|
||||
try {
|
||||
PlacesUtils.restoreBookmarksFromJSONFile(bookmarksFile);
|
||||
} catch (err) {
|
||||
// Report the error, but ignore it.
|
||||
Cu.reportError("bookmarks.json file could be corrupt. " + err);
|
||||
}
|
||||
} else
|
||||
Cu.reportError("Unable to find default bookmarks.json file.");
|
||||
PlacesUtils.restoreBookmarksFromJSONString(jsonStr, true);
|
||||
} catch (ex) {
|
||||
Cu.reportError("Failed to parse default bookmarks from bookmarks.json: " + err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let ioSvc = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
let uri = ioSvc.newURI("chrome://browser/locale/bookmarks.json", null, null);
|
||||
let channel = ioSvc.newChannelFromURI(uri);
|
||||
let sl = Cc["@mozilla.org/network/stream-loader;1"].
|
||||
createInstance(Ci.nsIStreamLoader);
|
||||
sl.init(observer);
|
||||
channel.asyncOpen(sl, channel);
|
||||
} catch (err) {
|
||||
// Report the error, but ignore it.
|
||||
Cu.reportError("Failed to load default bookmarks from bookmarks.json: " + err);
|
||||
}
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
|
|
|
@ -103,17 +103,14 @@ installers-%: clobber-% langpack-% repackage-zip-%
|
|||
|
||||
NO_JA_JP_MAC_AB_CD := $(if $(filter ja-JP-mac, $(AB_CD)),ja,$(AB_CD))
|
||||
|
||||
%/defaults/profile/bookmarks.json: bookmarks.inc generic/profile/bookmarks.json.in
|
||||
$(SYSINSTALL) -D $(dir $@)
|
||||
bookmarks.json: bookmarks.inc generic/profile/bookmarks.json.in
|
||||
$(PYTHON) $(topsrcdir)/config/Preprocessor.py \
|
||||
-I $< \
|
||||
-DAB_CD=$(NO_JA_JP_MAC_AB_CD) \
|
||||
$(srcdir)/generic/profile/bookmarks.json.in \
|
||||
> $@
|
||||
|
||||
libs:: $(FINAL_TARGET)/defaults/profile/bookmarks.json ;
|
||||
|
||||
install:: $(DESTDIR)$(mozappdir)/defaults/profile/bookmarks.json ;
|
||||
libs realchrome:: bookmarks.json
|
||||
|
||||
ifdef MOZ_UPDATER
|
||||
ifdef LOCALE_MERGEDIR
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
locale/@AB_CD@/browser/checkbox.dtd (%chrome/checkbox.dtd)
|
||||
locale/@AB_CD@/browser/notification.dtd (%chrome/notification.dtd)
|
||||
locale/@AB_CD@/browser/prompt.dtd (%chrome/prompt.dtd)
|
||||
locale/@AB_CD@/browser/bookmarks.json (bookmarks.json)
|
||||
|
||||
# Fennec-specific overrides of generic strings
|
||||
* locale/@AB_CD@/browser/netError.dtd (%chrome/overrides/netError.dtd)
|
||||
|
|
Загрузка…
Ссылка в новой задаче