зеркало из https://github.com/mozilla/gecko-dev.git
Bug 376008 bookmarks html import/export needs to move to /browser (r=mano)
This commit is contained in:
Родитель
c5f3b086d6
Коммит
65504bd2fc
|
@ -540,3 +540,6 @@ pref("browser.sessionstore.max_tabs_undo", 10);
|
||||||
|
|
||||||
// allow META refresh by default
|
// allow META refresh by default
|
||||||
pref("accessibility.blockautorefresh", false);
|
pref("accessibility.blockautorefresh", false);
|
||||||
|
|
||||||
|
// import bookmarks.html into Places bookmarks
|
||||||
|
pref("browser.places.importBookmarksHTML", true);
|
||||||
|
|
|
@ -33,6 +33,8 @@ REQUIRES = \
|
||||||
migration \
|
migration \
|
||||||
shellservice \
|
shellservice \
|
||||||
xulapp \
|
xulapp \
|
||||||
|
places \
|
||||||
|
browserplaces \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
EXPORTS = nsBrowserCompsCID.h
|
EXPORTS = nsBrowserCompsCID.h
|
||||||
|
@ -47,12 +49,17 @@ OS_LIBS += $(call EXPAND_LIBNAME,ole32 shell32)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LOCAL_INCLUDES = \
|
LOCAL_INCLUDES = \
|
||||||
-I$(srcdir)/../bookmarks/src \
|
|
||||||
-I$(srcdir)/../migration/src \
|
-I$(srcdir)/../migration/src \
|
||||||
-I$(srcdir)/../shell/src \
|
-I$(srcdir)/../shell/src \
|
||||||
-I$(srcdir)/../feeds/src \
|
-I$(srcdir)/../feeds/src \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
ifndef MOZ_PLACES_BOOKMARKS
|
||||||
|
LOCAL_INCLUDES += -I$(srcdir)/../bookmarks/src
|
||||||
|
else
|
||||||
|
LOCAL_INCLUDES += -I$(srcdir)/../places/src
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(OS_ARCH),WINNT)
|
ifeq ($(OS_ARCH),WINNT)
|
||||||
OS_LIBS += $(call EXPAND_LIBNAME,version)
|
OS_LIBS += $(call EXPAND_LIBNAME,version)
|
||||||
endif
|
endif
|
||||||
|
@ -63,13 +70,18 @@ SHARED_LIBRARY_LIBS = \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ifneq (,$(filter windows mac cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
|
ifneq (,$(filter windows mac cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
|
||||||
SHARED_LIBRARY_LIBS += ../shell/src/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX)
|
SHARED_LIBRARY_LIBS += ../shell/src/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX) \
|
||||||
|
$(NULL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef MOZ_PLACES_BOOKMARKS
|
ifndef MOZ_PLACES_BOOKMARKS
|
||||||
SHARED_LIBRARY_LIBS += \
|
SHARED_LIBRARY_LIBS += \
|
||||||
../bookmarks/src/$(LIB_PREFIX)bookmarks_s.$(LIB_SUFFIX) \
|
../bookmarks/src/$(LIB_PREFIX)bookmarks_s.$(LIB_SUFFIX) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
else
|
||||||
|
SHARED_LIBRARY_LIBS += \
|
||||||
|
../places/src/$(LIB_PREFIX)browserplaces_s.$(LIB_SUFFIX) \
|
||||||
|
$(NULL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef MOZ_SAFE_BROWSING
|
ifdef MOZ_SAFE_BROWSING
|
||||||
|
|
|
@ -96,3 +96,10 @@
|
||||||
|
|
||||||
#define NS_DOCNAVSTARTPROGRESSLISTENER_CONTRACTID \
|
#define NS_DOCNAVSTARTPROGRESSLISTENER_CONTRACTID \
|
||||||
"@mozilla.org/browser/safebrowsing/navstartlistener;1"
|
"@mozilla.org/browser/safebrowsing/navstartlistener;1"
|
||||||
|
|
||||||
|
// 6fb0c970-e1b1-11db-8314-0800200c9a66
|
||||||
|
#define NS_PLACESIMPORTEXPORTSERVICE_CID \
|
||||||
|
{ 0x6fb0c970, 0xe1b1, 0x11db, { 0x83, 0x14, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
|
||||||
|
|
||||||
|
#define NS_PLACESIMPORTEXPORTSERVICE_CONTRACTID \
|
||||||
|
"@mozilla.org/browser/places/import-export-service;1"
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#ifndef MOZ_PLACES_BOOKMARKS
|
#ifndef MOZ_PLACES_BOOKMARKS
|
||||||
#include "nsBookmarksService.h"
|
#include "nsBookmarksService.h"
|
||||||
#include "nsForwardProxyDataSource.h"
|
#include "nsForwardProxyDataSource.h"
|
||||||
|
#else
|
||||||
|
#include "nsPlacesImportExportService.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
#include "nsWindowsShellService.h"
|
#include "nsWindowsShellService.h"
|
||||||
|
@ -81,6 +83,8 @@
|
||||||
#ifndef MOZ_PLACES_BOOKMARKS
|
#ifndef MOZ_PLACES_BOOKMARKS
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsBookmarksService, Init)
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsBookmarksService, Init)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsForwardProxyDataSource, Init)
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsForwardProxyDataSource, Init)
|
||||||
|
#else
|
||||||
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPlacesImportExportService)
|
||||||
#endif
|
#endif
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowsShellService)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowsShellService)
|
||||||
|
@ -152,6 +156,13 @@ static const nsModuleComponentInfo components[] =
|
||||||
NS_RDF_INFER_DATASOURCE_CONTRACTID_PREFIX "forward-proxy",
|
NS_RDF_INFER_DATASOURCE_CONTRACTID_PREFIX "forward-proxy",
|
||||||
nsForwardProxyDataSourceConstructor },
|
nsForwardProxyDataSourceConstructor },
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
{ "Places Import/Export Service",
|
||||||
|
NS_PLACESIMPORTEXPORTSERVICE_CID,
|
||||||
|
NS_PLACESIMPORTEXPORTSERVICE_CONTRACTID,
|
||||||
|
nsPlacesImportExportServiceConstructor},
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ "Feed Sniffer",
|
{ "Feed Sniffer",
|
||||||
|
|
|
@ -71,6 +71,8 @@ REQUIRES += places
|
||||||
endif
|
endif
|
||||||
ifndef MOZ_PLACES_BOOKMARKS
|
ifndef MOZ_PLACES_BOOKMARKS
|
||||||
REQUIRES += bookmarks
|
REQUIRES += bookmarks
|
||||||
|
else
|
||||||
|
REQUIRES += browserplaces
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPPSRCS = nsProfileMigrator.cpp \
|
CPPSRCS = nsProfileMigrator.cpp \
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "nsINavBookmarksService.h"
|
#include "nsINavBookmarksService.h"
|
||||||
#include "nsBrowserCompsCID.h"
|
#include "nsBrowserCompsCID.h"
|
||||||
#include "nsToolkitCompsCID.h"
|
#include "nsToolkitCompsCID.h"
|
||||||
|
#include "nsIPlacesImportExportService.h"
|
||||||
#else
|
#else
|
||||||
#include "nsIBookmarksService.h"
|
#include "nsIBookmarksService.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -283,11 +284,6 @@ ImportBookmarksHTML(nsIFile* aBookmarksFile,
|
||||||
do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv);
|
do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Get the file:// uri for the bookmarks file.
|
|
||||||
nsCOMPtr<nsIURI> fileURI;
|
|
||||||
rv = NS_NewFileURI(getter_AddRefs(fileURI), aBookmarksFile);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
// Create an imported bookmarks folder under the bookmarks menu.
|
// Create an imported bookmarks folder under the bookmarks menu.
|
||||||
PRInt64 root;
|
PRInt64 root;
|
||||||
rv = bms->GetBookmarksRoot(&root);
|
rv = bms->GetBookmarksRoot(&root);
|
||||||
|
@ -298,7 +294,11 @@ ImportBookmarksHTML(nsIFile* aBookmarksFile,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Import the bookmarks into the folder.
|
// Import the bookmarks into the folder.
|
||||||
rv = bms->ImportBookmarksHTMLToFolder(fileURI, folder);
|
nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(aBookmarksFile));
|
||||||
|
NS_ENSURE_TRUE(localFile, NS_ERROR_FAILURE);
|
||||||
|
nsCOMPtr<nsIPlacesImportExportService> importer = do_GetService(NS_PLACESIMPORTEXPORTSERVICE_CONTRACTID, &rv);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
rv = importer->ImportHTMLFromFileToFolder(localFile, folder);
|
||||||
return rv;
|
return rv;
|
||||||
#else
|
#else
|
||||||
nsCOMPtr<nsIRDFResource> folder;
|
nsCOMPtr<nsIRDFResource> folder;
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
function BrowserGlue() {
|
function BrowserGlue() {
|
||||||
this._init();
|
this._init();
|
||||||
|
this._profileStarted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserGlue.prototype = {
|
BrowserGlue.prototype = {
|
||||||
|
@ -127,11 +128,23 @@ BrowserGlue.prototype = {
|
||||||
ww.openWindow(null, "chrome://browser/content/safeMode.xul",
|
ww.openWindow(null, "chrome://browser/content/safeMode.xul",
|
||||||
"_blank", "chrome,centerscreen,modal,resizable=no", null);
|
"_blank", "chrome,centerscreen,modal,resizable=no", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize Places
|
||||||
|
this._initPlaces();
|
||||||
|
|
||||||
|
// indicate that the profile was initialized
|
||||||
|
this._profileStarted = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// profile shutdown handler (contains profile cleanup routines)
|
// profile shutdown handler (contains profile cleanup routines)
|
||||||
_onProfileShutdown: function()
|
_onProfileShutdown: function()
|
||||||
{
|
{
|
||||||
|
// this block is for code that depends on _onProfileStartup() having been called.
|
||||||
|
if (this._profileStarted) {
|
||||||
|
// final places cleanup
|
||||||
|
this._shutdownPlaces();
|
||||||
|
}
|
||||||
|
|
||||||
// here we enter last survival area, in order to avoid multiple
|
// here we enter last survival area, in order to avoid multiple
|
||||||
// "quit-application" notifications caused by late window closings
|
// "quit-application" notifications caused by late window closings
|
||||||
const appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1']
|
const appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1']
|
||||||
|
@ -158,6 +171,71 @@ BrowserGlue.prototype = {
|
||||||
return Sanitizer;
|
return Sanitizer;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Places
|
||||||
|
* - imports bookmarks.html if bookmarks datastore is empty
|
||||||
|
*/
|
||||||
|
_initPlaces: function bg__initPlaces() {
|
||||||
|
#ifdef MOZ_PLACES_BOOKMARKS
|
||||||
|
var importBookmarks = false;
|
||||||
|
try {
|
||||||
|
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIPrefBranch);
|
||||||
|
importBookmarks = prefService.getBoolPref("browser.places.importBookmarksHTML");
|
||||||
|
} catch(ex) {}
|
||||||
|
|
||||||
|
if (!importBookmarks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var dirService = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
|
.getService(Components.interfaces.nsIProperties);
|
||||||
|
var profDir = dirService.get("ProfD", Components.interfaces.nsILocalFile);
|
||||||
|
|
||||||
|
var bookmarksFile = profDir.clone(); // bookmarks.html
|
||||||
|
bookmarksFile.append("bookmarks.html");
|
||||||
|
|
||||||
|
if (bookmarksFile.exists()) {
|
||||||
|
// import bookmarks.html
|
||||||
|
try {
|
||||||
|
var importer =
|
||||||
|
Components.classes["@mozilla.org/browser/places/import-export-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIPlacesImportExportService);
|
||||||
|
importer.importHTMLFromFile(bookmarksFile);
|
||||||
|
} catch(ex) {
|
||||||
|
} finally {
|
||||||
|
prefService.setBoolPref("browser.places.importBookmarksHTML", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// backup pre-places bookmarks.html
|
||||||
|
// XXXtodo remove this before betas, after import/export is solid
|
||||||
|
var bookmarksBackup = profDir.clone();
|
||||||
|
bookmarksBackup.append("bookmarks.preplaces.html");
|
||||||
|
if (!bookmarksBackup.exists()) {
|
||||||
|
// save old bookmarks.html file as bookmarks.preplaces.html
|
||||||
|
try {
|
||||||
|
bookmarksFile.copyTo(profDir, "bookmarks.preplaces.html");
|
||||||
|
} catch(ex) {
|
||||||
|
dump("nsBrowserGlue::_initPlaces(): copy of bookmarks.html to bookmarks.preplaces.html failed: " + ex + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Places shut-down tasks
|
||||||
|
* - back up and archive bookmarks
|
||||||
|
*/
|
||||||
|
_shutdownPlaces: function bg__shutdownPlaces() {
|
||||||
|
#ifdef MOZ_PLACES_BOOKMARKS
|
||||||
|
// backup bookmarks to bookmarks.html
|
||||||
|
var importer =
|
||||||
|
Components.classes["@mozilla.org/browser/places/import-export-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIPlacesImportExportService);
|
||||||
|
importer.backupBookmarksFile();
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
// public nsIBrowserGlue members
|
// public nsIBrowserGlue members
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
|
@ -166,7 +244,6 @@ BrowserGlue.prototype = {
|
||||||
{
|
{
|
||||||
this.Sanitizer.sanitize(aParentWindow);
|
this.Sanitizer.sanitize(aParentWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,4 +43,10 @@ VPATH = @srcdir@
|
||||||
|
|
||||||
include $(DEPTH)/config/autoconf.mk
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
|
DIRS = public src
|
||||||
|
|
||||||
|
ifdef ENABLE_TESTS
|
||||||
|
DIRS += tests
|
||||||
|
endif
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
|
|
@ -287,10 +287,12 @@ var PlacesOrganizer = {
|
||||||
Ci.nsIFilePicker.modeOpen);
|
Ci.nsIFilePicker.modeOpen);
|
||||||
fp.appendFilters(Ci.nsIFilePicker.filterHTML | Ci.nsIFilePicker.filterAll);
|
fp.appendFilters(Ci.nsIFilePicker.filterHTML | Ci.nsIFilePicker.filterAll);
|
||||||
if (fp.show() != Ci.nsIFilePicker.returnCancel) {
|
if (fp.show() != Ci.nsIFilePicker.returnCancel) {
|
||||||
var ioService = Cc["@mozilla.org/network/io-service;1"].
|
if (fp.file) {
|
||||||
getService(Ci.nsIIOService);
|
var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].
|
||||||
if (fp.file)
|
getService(Ci.nsIPlacesImportExportService);
|
||||||
PlacesUtils.bookmarks.importBookmarksHTML(ioService.newFileURI(fp.file));
|
var file = fp.file.QueryInterface(nsILocalFile);
|
||||||
|
importer.importHTMLFromFile(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -304,8 +306,11 @@ var PlacesOrganizer = {
|
||||||
Ci.nsIFilePicker.modeSave);
|
Ci.nsIFilePicker.modeSave);
|
||||||
fp.appendFilters(Ci.nsIFilePicker.filterHTML);
|
fp.appendFilters(Ci.nsIFilePicker.filterHTML);
|
||||||
fp.defaultString = "bookmarks.html";
|
fp.defaultString = "bookmarks.html";
|
||||||
if (fp.show() != Ci.nsIFilePicker.returnCancel)
|
if (fp.show() != Ci.nsIFilePicker.returnCancel) {
|
||||||
PlacesUtils.bookmarks.exportBookmarksHTML(fp.file);
|
var exporter = Cc["@mozilla.org/browser/places/import-export-service;1"].
|
||||||
|
getService(Ci.nsIPlacesImportExportService);
|
||||||
|
exporter.exportHTMLToFile(fp.file);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateStatusBarForView: function PO_updateStatusBarForView(aView) {
|
updateStatusBarForView: function PO_updateStatusBarForView(aView) {
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
#
|
||||||
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
# http://www.mozilla.org/MPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
# for the specific language governing rights and limitations under the
|
||||||
|
# License.
|
||||||
|
#
|
||||||
|
# The Original Code is Places code.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is
|
||||||
|
# Google Inc.
|
||||||
|
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
# the Initial Developer. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
# Brett Wilson <brettw@gmail.com>
|
||||||
|
#
|
||||||
|
# Alternatively, the contents of this file may be used under the terms of
|
||||||
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
# of those above. If you wish to allow use of your version of this file only
|
||||||
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
# use your version of this file under the terms of the MPL, indicate your
|
||||||
|
# decision by deleting the provisions above and replace them with the notice
|
||||||
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
# the provisions above, a recipient may use your version of this file under
|
||||||
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
#
|
||||||
|
# ***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
|
DEPTH = ../../../..
|
||||||
|
topsrcdir = @top_srcdir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
|
||||||
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
|
MODULE = browserplaces
|
||||||
|
XPIDL_MODULE = browserplaces
|
||||||
|
|
||||||
|
XPIDLSRCS = nsIPlacesImportExportService.idl
|
||||||
|
|
||||||
|
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,73 @@
|
||||||
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Places.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla Corp.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Dietrich Ayala <dietrich@mozilla.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "nsISupports.idl"
|
||||||
|
|
||||||
|
interface nsILocalFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PlacesImportExport interface provides methods for importing
|
||||||
|
* and exporting Places data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
[scriptable, uuid(212fd626-e07e-11db-8314-0800200c9a66)]
|
||||||
|
interface nsIPlacesImportExportService: nsISupports
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Loads the given bookmarks.html file and merges it with the current
|
||||||
|
* bookmarks hierarchy.
|
||||||
|
*/
|
||||||
|
void importHTMLFromFile(in nsILocalFile aFile);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the given bookmarks.html file and puts it in the given folder
|
||||||
|
*/
|
||||||
|
void importHTMLFromFileToFolder(in nsILocalFile aFile, in PRInt64 aFolder);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the current bookmarks hierarchy to a bookmarks.html file.
|
||||||
|
*/
|
||||||
|
void exportHTMLToFile(in nsILocalFile aFile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backup and archive the bookmarks.html file.
|
||||||
|
*/
|
||||||
|
void backupBookmarksFile();
|
||||||
|
};
|
|
@ -0,0 +1,68 @@
|
||||||
|
#
|
||||||
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
# http://www.mozilla.org/MPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
# for the specific language governing rights and limitations under the
|
||||||
|
# License.
|
||||||
|
#
|
||||||
|
# The Original Code is Places code
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is
|
||||||
|
# Google Inc.
|
||||||
|
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
# the Initial Developer. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
# Brett Wilson <brettw@gmail.com>
|
||||||
|
# Dietrich Ayala <dietrich@mozilla.com>
|
||||||
|
#
|
||||||
|
# Alternatively, the contents of this file may be used under the terms of
|
||||||
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
# of those above. If you wish to allow use of your version of this file only
|
||||||
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
# use your version of this file under the terms of the MPL, indicate your
|
||||||
|
# decision by deleting the provisions above and replace them with the notice
|
||||||
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
# the provisions above, a recipient may use your version of this file under
|
||||||
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
#
|
||||||
|
# ***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
|
DEPTH = ../../../..
|
||||||
|
topsrcdir = @top_srcdir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
|
||||||
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
|
MODULE = browserplaces
|
||||||
|
LIBRARY_NAME = browserplaces_s
|
||||||
|
FORCE_STATIC_LIB = 1
|
||||||
|
FORCE_USE_PIC = 1
|
||||||
|
USE_STATIC_LIBS = 1
|
||||||
|
|
||||||
|
REQUIRES = \
|
||||||
|
xpcom \
|
||||||
|
string \
|
||||||
|
docshell \
|
||||||
|
necko \
|
||||||
|
browsercomps \
|
||||||
|
toolkitcomps \
|
||||||
|
unicharutil \
|
||||||
|
htmlparser \
|
||||||
|
content \
|
||||||
|
places \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
CPPSRCS = nsPlacesImportExportService.cpp
|
||||||
|
|
||||||
|
include $(topsrcdir)/config/rules.mk
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef nsPlacesImportExportService_h__
|
||||||
|
#define nsPlacesImportExportService_h__
|
||||||
|
|
||||||
|
#include "nsIPlacesImportExportService.h"
|
||||||
|
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsILocalFile.h"
|
||||||
|
#include "nsIOutputStream.h"
|
||||||
|
#include "nsIFaviconService.h"
|
||||||
|
#include "nsIAnnotationService.h"
|
||||||
|
#include "nsILivemarkService.h"
|
||||||
|
#include "nsINavHistoryService.h"
|
||||||
|
#include "nsINavBookmarksService.h"
|
||||||
|
|
||||||
|
class nsPlacesImportExportService : public nsIPlacesImportExportService
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSIPLACESIMPORTEXPORTSERVICE
|
||||||
|
nsPlacesImportExportService();
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual ~nsPlacesImportExportService();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsCOMPtr<nsIFaviconService> mFaviconService;
|
||||||
|
nsCOMPtr<nsIAnnotationService> mAnnotationService;
|
||||||
|
nsCOMPtr<nsINavBookmarksService> mBookmarksService;
|
||||||
|
nsCOMPtr<nsINavHistoryService> mHistoryService;
|
||||||
|
nsCOMPtr<nsILivemarkService> mLivemarkService;
|
||||||
|
|
||||||
|
PRInt64 mPlacesRoot;
|
||||||
|
PRInt64 mBookmarksRoot;
|
||||||
|
PRInt64 mToolbarFolder;
|
||||||
|
|
||||||
|
nsresult ImportHTMLFromFileInternal(nsILocalFile* aFile, PRBool aAllowRootChanges,
|
||||||
|
PRInt64 aFolder, PRBool aIsImportDefaults);
|
||||||
|
nsresult WriteContainer(PRInt64 aFolder, const nsACString& aIndent, nsIOutputStream* aOutput);
|
||||||
|
nsresult WriteContainerHeader(PRInt64 aFolder, const nsACString& aIndent, nsIOutputStream* aOutput);
|
||||||
|
nsresult WriteContainerTitle(PRInt64 aFolder, nsIOutputStream* aOutput);
|
||||||
|
nsresult WriteItem(nsINavHistoryResultNode* aItem, const nsACString& aIndent, nsIOutputStream* aOutput);
|
||||||
|
nsresult WriteLivemark(PRInt64 aFolderId, const nsACString& aIndent, nsIOutputStream* aOutput);
|
||||||
|
nsresult WriteContainerContents(PRInt64 aFolder, const nsACString& aIndent, nsIOutputStream* aOutput);
|
||||||
|
|
||||||
|
nsresult ArchiveBookmarksFile(PRInt32 aNumberOfBackups, PRBool aForceArchive);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // nsPlacesImportExportService_h__
|
|
@ -0,0 +1,50 @@
|
||||||
|
#
|
||||||
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
# http://www.mozilla.org/MPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
# for the specific language governing rights and limitations under the
|
||||||
|
# License.
|
||||||
|
#
|
||||||
|
# The Original Code is mozilla.org code.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is
|
||||||
|
# Mozilla.org.
|
||||||
|
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||||
|
# the Initial Developer. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
# Dietrich Ayala <dietrich@mozilla.com>
|
||||||
|
#
|
||||||
|
# Alternatively, the contents of this file may be used under the terms of
|
||||||
|
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||||
|
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
# of those above. If you wish to allow use of your version of this file only
|
||||||
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
# use your version of this file under the terms of the MPL, indicate your
|
||||||
|
# decision by deleting the provisions above and replace them with the notice
|
||||||
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
# the provisions above, a recipient may use your version of this file under
|
||||||
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
#
|
||||||
|
# ***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
|
DEPTH = ../../../..
|
||||||
|
topsrcdir = @top_srcdir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
|
||||||
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
|
MODULE = test_browser_places
|
||||||
|
|
||||||
|
XPCSHELL_TESTS = unit
|
||||||
|
|
||||||
|
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
||||||
|
<!-- This is an automatically generated file.
|
||||||
|
It will be read and overwritten.
|
||||||
|
DO NOT EDIT! -->
|
||||||
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
||||||
|
<TITLE>Bookmarks</TITLE>
|
||||||
|
<H1 LAST_MODIFIED="1177541029">Bookmarks</H1>
|
||||||
|
|
||||||
|
<DL><p>
|
||||||
|
<DT><A HREF="http://en-US.add-ons.mozilla.com/en-US/firefox/bookmarks/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAFo9M%2F3AAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAPkSURBVHjaYmAAgrjyOnOGiKxqxT9%2F%2FvwHCCCGuNJKLpAo49KTL%2F5%2F%2F8PMABBADJFZFWwXnn%2F%2FDxJYeOLNf0aQ9AIg48%2Ff%2Fwwfvv1hAAggZpBAYlWdnrqJLcPVE4e%2Bsuy7%2FfH%2F%2B88%2FGdjY2Bj%2BcCqHMey6%2Ben%2F379%2F%2F%2F8B6unZ9ew%2Fy54jV249f6%2Bm9uXnX4Y9qyaoAAQAhAB7%2FwEAAAAAY3h%2BG1RdbeMMCgkB9%2Fr%2BAPL2%2FAC3vsyi5NG6YQFcbnwdZ3F44uru9gAAAQAAUjEVALPT7wDu9v4A5erz%2FgL19vr16PD6AAUHBgDu9PwA%2F%2F8AAO%2F2%2FgD0%2BP0A7e7x8QPYzsX38vj9g%2BPk6hkLFiAxy%2BP4AeHj5%2FXFtp9GonxaagII7AawXyprpf%2F%2FZ5L5%2Fe%2Fv9%2B%2Fff91ZN7nrG0icJSqrkknJxHm1h5Nl0J8%2F%2Fxg%2B%2FwDa%2Febzv39%2FWKQ2TG97ycIvq%2Bvn52oVxMHGxHDj8RcGQT4uEGZyCct98e3LL3YmJ2enNYxAi%2B48%2B8QQaizGIMLFBLaSlYWZgYWDWZaJhY2V%2BcvPfwz%2BeiIMf%2F%2F%2BY9CV4GAQ42Zh%2BPPvP8O%2Fv%2F%2BZmG7cff7u49c%2FDNtufGZgYmJiOHLvG8Pt1z8Yfv3%2Bz%2FDn19%2B3TCd2LNV7%2F%2FU3w7vPvxkWnHzDcOPFd4ZvQBPv3L79aM%2BS3nfMN88d%2BfyXkW0Lq6BiGAs7J8fHT9%2F%2FXTy%2BY82Lp0cdb5889hcgQJNU85JYFMXP%2B5aHqRmmZJ9kKMGAEBgtDCYYY6BFa%2BlrPc6yRf0LYYtZzG4YaNGibUNJVLuIcBNUTLMQM8ZoppdiaXnf9Xlf5z4ounDu4p57f%2Ff8Pt50SH9ZEfUuLehy93yMRBNroVAg6PV2yBbO9c94tK5v7suF3%2FlMs1o8oU27ltvIMic7fJv7uuqLJGa2UpPxlCILICBtGz1pYWooakeoDaTFgBtNWm04zl%2Fkbs53FnZ%2FZO%2BldGbFP5aaP50cj41pigi8XFjF2zp8ivpgsFMFHp0GgrQZL4DuYGCE6f3pzoBnUwRB8sYi4QGKHf7b5d8HiHWpMBsPvLKDeFiHmVEPBN0yMJyMIUhfb6gXbMkr4xtq1J6Z36eLpmiDH508LNShbDzB4kTIATguNsBqA1CHElJDhGdCGWsDkYY%2FTJh3lUelu384yTlzrtgDWVaggvG8qhDnYcEwwWi0wET%2FTNTh9Gh%2FvVn7v%2B2I%2BHlpWXS59ORgfOr7UGRkVNMUAWPtCMnHdbjjATFNKJeKpdLZYQY0crDzLUvfbHxdqfllj6a7p2VVjUqyGhYwPpZFqxYlf6hZ%2F7X3c736%2Fv4LV1blv94gEvsAAAAASUVORK5CYII%3D" ID="rdf:#$CnoJ1">Get Bookmark Add-ons</A>
|
||||||
|
<HR>
|
||||||
|
<DT><H3 LAST_MODIFIED="1177541040" PERSONAL_TOOLBAR_FOLDER="true" ID="rdf:#$FvPhC3">Bookmarks Toolbar Folder</H3>
|
||||||
|
<DD>Add bookmarks to this folder to see them displayed on the Bookmarks Toolbar
|
||||||
|
<DL><p>
|
||||||
|
<DT><A HREF="http://en-US.www.mozilla.com/en-US/firefox/central/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" ID="rdf:#$GvPhC3">Getting Started</A>
|
||||||
|
<DT><A HREF="http://en-US.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/" LAST_MODIFIED="1177541035" FEEDURL="http://en-US.fxfeeds.mozilla.com/en-US/firefox/headlines.xml" ID="rdf:#$HvPhC3">Latest Headlines</A>
|
||||||
|
</DL><p>
|
||||||
|
<HR>
|
||||||
|
<DT><H3 ID="rdf:#$ZvPhC3">Mozilla Firefox</H3>
|
||||||
|
<DL><p>
|
||||||
|
<DT><A HREF="http://en-US.www.mozilla.com/en-US/firefox/help/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" ID="rdf:#$22iCK1">Help and Tutorials</A>
|
||||||
|
<DT><A HREF="http://en-US.www.mozilla.com/en-US/firefox/customize/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" ID="rdf:#$32iCK1">Customize Firefox</A>
|
||||||
|
<DT><A HREF="http://en-US.www.mozilla.com/en-US/firefox/community/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" ID="rdf:#$42iCK1">Get Involved</A>
|
||||||
|
<DT><A HREF="http://en-US.www.mozilla.com/en-US/firefox/about/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" ID="rdf:#$52iCK1">About Us</A>
|
||||||
|
</DL><p>
|
||||||
|
<DT><H3 ADD_DATE="1177541020" LAST_MODIFIED="1177541047" ID="rdf:#$74Gpx2">test</H3>
|
||||||
|
<DL><p>
|
||||||
|
<DT><A HREF="http://test/post" ADD_DATE="1177375336" LAST_MODIFIED="1177375423" SHORTCUTURL="test" WEB_PANEL="true" POST_DATA="hidden1%3Dbar&text1%3D%25s" LAST_CHARSET="ISO-8859-1" ID="rdf:#$pYFe7">test post keyword</A>
|
||||||
|
<DD>description
|
||||||
|
<DT><A HREF="http://test/micsum" ADD_DATE="1177375377" LAST_MODIFIED="1177541023" LAST_CHARSET="ISO-8859-1" MICSUM_GEN_URI="urn:source:http://dietrich.ganx4.com/mozilla/test-microsummary.xml" MICSUM_EXPIRATION="1177542823620" GENERATED_TITLE="id:462fd9a2e5b66" ID="rdf:#$qYFe7">test microsummary</A>
|
||||||
|
<DD>test microsummary
|
||||||
|
</DL><p>
|
||||||
|
</DL><p>
|
|
@ -0,0 +1,95 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Places.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Google Inc.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Brian Ryner <bryner@brianryner.com>
|
||||||
|
* Dietrich Ayala <dietrich@mozilla.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
const NS_APP_USER_PROFILE_50_DIR = "ProfD";
|
||||||
|
const Ci = Components.interfaces;
|
||||||
|
const Cc = Components.classes;
|
||||||
|
const Cr = Components.results;
|
||||||
|
|
||||||
|
function LOG(aMsg) {
|
||||||
|
aMsg = ("*** PLACES TESTS: " + aMsg);
|
||||||
|
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).
|
||||||
|
logStringMessage(aMsg);
|
||||||
|
print(aMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there's no location registered for the profile direcotry, register one now.
|
||||||
|
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
||||||
|
var profileDir = null;
|
||||||
|
try {
|
||||||
|
profileDir = dirSvc.get(NS_APP_USER_PROFILE_50_DIR, Ci.nsIFile);
|
||||||
|
} catch (e) {}
|
||||||
|
if (!profileDir) {
|
||||||
|
// Register our own provider for the profile directory.
|
||||||
|
// It will simply return the current directory.
|
||||||
|
var provider = {
|
||||||
|
getFile: function(prop, persistent) {
|
||||||
|
persistent.value = true;
|
||||||
|
if (prop == NS_APP_USER_PROFILE_50_DIR) {
|
||||||
|
return dirSvc.get("CurProcD", Ci.nsIFile);
|
||||||
|
}
|
||||||
|
throw Cr.NS_ERROR_FAILURE;
|
||||||
|
},
|
||||||
|
QueryInterface: function(iid) {
|
||||||
|
if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
|
||||||
|
iid.equals(Ci.nsISupports)) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
var iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||||
|
|
||||||
|
function uri(spec) {
|
||||||
|
return iosvc.newURI(spec, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a previously created sqlite file
|
||||||
|
function clearDB() {
|
||||||
|
try {
|
||||||
|
var file = dirSvc.get('ProfD', Ci.nsIFile);
|
||||||
|
file.append("places.sqlite");
|
||||||
|
if (file.exists())
|
||||||
|
file.remove(false);
|
||||||
|
} catch(ex) { dump("Exception: " + ex); }
|
||||||
|
}
|
||||||
|
clearDB();
|
|
@ -0,0 +1,41 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Places.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla.org
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Dietrich Ayala <dietrich@mozilla.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
// put cleanup of the bookmarks test here.
|
||||||
|
|
||||||
|
// remove bookmarks file
|
||||||
|
clearDB();
|
|
@ -0,0 +1,170 @@
|
||||||
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.com code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Mozilla Corp.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Dietrich Ayala <dietrich@mozilla.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
// get history service
|
||||||
|
try {
|
||||||
|
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
|
||||||
|
} catch(ex) {
|
||||||
|
do_throw("Could not get nav-history-service\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get bookmark service
|
||||||
|
try {
|
||||||
|
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
|
||||||
|
} catch(ex) {
|
||||||
|
do_throw("Could not get nav-bookmarks-service\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// main
|
||||||
|
function run_test() {
|
||||||
|
// get places import/export service
|
||||||
|
var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].getService(Ci.nsIPlacesImportExportService);
|
||||||
|
|
||||||
|
// get file pointers
|
||||||
|
var bookmarksFileOld = do_get_file("browser/components/places/tests/unit/bookmarks.preplaces.html");
|
||||||
|
var bookmarksFileNew = dirSvc.get("ProfD", Ci.nsILocalFile);
|
||||||
|
bookmarksFileNew.append("bookmarks.exported.html");
|
||||||
|
|
||||||
|
// create bookmarks.exported.html if necessary
|
||||||
|
if (!bookmarksFileOld.exists())
|
||||||
|
bookmarksFileOld.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 0600);
|
||||||
|
if (!bookmarksFileOld.exists())
|
||||||
|
do_throw("couldn't create file: bookmarks.exported.html");
|
||||||
|
|
||||||
|
// Test importing a non-Places canonical bookmarks file.
|
||||||
|
// 1. import bookmarks.preplaces.html
|
||||||
|
// 2. run the test-suite
|
||||||
|
bmsvc.removeFolderChildren(bmsvc.bookmarksRoot);
|
||||||
|
importer.importHTMLFromFile(bookmarksFileOld);
|
||||||
|
testCanonicalBookmarks(bmsvc.bookmarksRoot);
|
||||||
|
|
||||||
|
// Test exporting a Places canonical bookmarks file.
|
||||||
|
// 1. export to bookmarks.exported.html
|
||||||
|
// 2. import bookmarks.exported.html
|
||||||
|
// 3. run the test-suite
|
||||||
|
/*
|
||||||
|
importer.exportHTMLToFile(bookmarksFileNew);
|
||||||
|
bmsvc.removeFolderChildren(bmsvc.bookmarksRoot);
|
||||||
|
importer.importHTMLFromFile(bookmarksFileNew);
|
||||||
|
testCanonicalBookmarks(bmsvc.bookmarksRoot);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Test importing a Places canonical bookmarks file to a specific folder.
|
||||||
|
// 1. create a new folder
|
||||||
|
// 2. import bookmarks.exported.html to that folder
|
||||||
|
// 3. run the test-suite
|
||||||
|
/*
|
||||||
|
var testFolder = bmsvc.createFolder(bmsvc.bookmarksRoot, "test", bmsvc.DEFAULT_INDEX);
|
||||||
|
importer.importHTMLFromFileToFolder(bookmarksFileNew, testFolder);
|
||||||
|
testCanonicalBookmarks(testFolder);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
XXX if there are new fields we add to the bookmarks HTML format
|
||||||
|
then test them here
|
||||||
|
Test importing a Places canonical bookmarks file
|
||||||
|
1. empty the bookmarks datastore
|
||||||
|
2. import bookmarks.places.html
|
||||||
|
3. run the test-suite
|
||||||
|
4. run the additional-test-suite
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
XXX could write another more generic testsuite:
|
||||||
|
- a function that fetches all descendant nodes of a folder with all non-static
|
||||||
|
node properties removed, and serializes w/ toSource()
|
||||||
|
- import a file, get serialization
|
||||||
|
- export it, re-import, get serialization
|
||||||
|
- do_check_eq(str1, str2)
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests a bookmarks datastore that has a set of bookmarks, etc
|
||||||
|
// that flex each supported field and feature.
|
||||||
|
function testCanonicalBookmarks(aFolder) {
|
||||||
|
// query to see if the deleted folder and items have been imported
|
||||||
|
try {
|
||||||
|
var query = histsvc.getNewQuery();
|
||||||
|
query.setFolders([bmsvc.bookmarksRoot], 1);
|
||||||
|
var result = histsvc.executeQuery(query, histsvc.getNewQueryOptions());
|
||||||
|
var rootNode = result.root;
|
||||||
|
rootNode.containerOpen = true;
|
||||||
|
// get test folder
|
||||||
|
var idx = 3; // XXX why does passing the value directly fail?
|
||||||
|
var testFolder = rootNode.getChild(idx);
|
||||||
|
do_check_eq(testFolder.type, testFolder.RESULT_TYPE_FOLDER);
|
||||||
|
do_check_eq(testFolder.title, "test");
|
||||||
|
testFolder = testFolder.QueryInterface(Ci.nsINavHistoryFolderResultNode);
|
||||||
|
do_check_eq(testFolder.hasChildren, true);
|
||||||
|
// open test folder, and test the children
|
||||||
|
testFolder.containerOpen = true;
|
||||||
|
var cc = testFolder.childCount;
|
||||||
|
do_check_eq(cc, 2);
|
||||||
|
// test bookmark 1
|
||||||
|
var testBookmark1 = testFolder.getChild(0);
|
||||||
|
// url
|
||||||
|
do_check_eq("http://test/post", testBookmark1.uri);
|
||||||
|
// title
|
||||||
|
do_check_eq("test post keyword", testBookmark1.title);
|
||||||
|
// keyword
|
||||||
|
do_check_eq("test", bmsvc.getKeywordForBookmark(testBookmark1.bookmarkId));
|
||||||
|
// sidebar
|
||||||
|
// add date
|
||||||
|
// last modified
|
||||||
|
// post data
|
||||||
|
// last charset
|
||||||
|
// description
|
||||||
|
|
||||||
|
// test bookmark 2
|
||||||
|
var testBookmark2 = testFolder.getChild(1);
|
||||||
|
// url
|
||||||
|
do_check_eq("http://test/micsum", testBookmark2.uri);
|
||||||
|
// title
|
||||||
|
do_check_eq("test microsummary", testBookmark2.title);
|
||||||
|
// micsum uri
|
||||||
|
// micsum expiration
|
||||||
|
// micsum generated title
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
testFolder.containerOpen = false;
|
||||||
|
rootNode.containerOpen = false;
|
||||||
|
}
|
||||||
|
catch(ex) {
|
||||||
|
do_throw("bookmarks query tests failed: " + ex);
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,7 @@ bin/components/autocomplete.xpt
|
||||||
bin/components/autoconfig.xpt
|
bin/components/autoconfig.xpt
|
||||||
bin/components/bookmarks.xpt
|
bin/components/bookmarks.xpt
|
||||||
bin/components/browsercompsbase.xpt
|
bin/components/browsercompsbase.xpt
|
||||||
|
bin/components/browserplaces.xpt
|
||||||
bin/components/browsersearch.xpt
|
bin/components/browsersearch.xpt
|
||||||
bin/components/browser-feeds.xpt
|
bin/components/browser-feeds.xpt
|
||||||
bin/components/caps.xpt
|
bin/components/caps.xpt
|
||||||
|
|
|
@ -66,6 +66,7 @@ bin\components\autocomplete.xpt
|
||||||
bin\components\autoconfig.xpt
|
bin\components\autoconfig.xpt
|
||||||
bin\components\bookmarks.xpt
|
bin\components\bookmarks.xpt
|
||||||
bin\components\browsercompsbase.xpt
|
bin\components\browsercompsbase.xpt
|
||||||
|
bin\components\browserplaces.xpt
|
||||||
bin\components\browsersearch.xpt
|
bin\components\browsersearch.xpt
|
||||||
bin\components\browser-feeds.xpt
|
bin\components\browser-feeds.xpt
|
||||||
bin\components\caps.xpt
|
bin\components\caps.xpt
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
|
||||||
<!-- This is an automatically generated file.
|
|
||||||
It will be read and overwritten.
|
|
||||||
DO NOT EDIT! -->
|
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
|
||||||
<TITLE>Bookmarks and History</TITLE>
|
|
||||||
<H1 PLACES_ROOT="true">Bookmarks and History</H1>
|
|
||||||
<DL><p>
|
|
||||||
<DT><A HREF="place:&beginTime=-2592000000000&beginTimeRef=1&endTime=7200000000&endTimeRef=2&sort=4&type=1">History</A>
|
|
||||||
<DD>Shows all browsing history
|
|
||||||
<DT><H3 BOOKMARKS_MENU="true">Bookmarks</H3>
|
|
||||||
<DD>Add bookmarks to this folder to see them displayed on the Bookmarks Menu
|
|
||||||
<DL><p>
|
|
||||||
<DT><H3 PERSONAL_TOOLBAR_FOLDER="true">Bookmarks Toolbar Folder</H3>
|
|
||||||
<DD>Add bookmarks to this folder to see them displayed on the Bookmarks Toolbar
|
|
||||||
<DL><p>
|
|
||||||
</DL><p>
|
|
||||||
</DL><p>
|
|
||||||
<DT><A HREF="place:&annotation=livemark%2FfeedURI" ICON_URI="chrome://browser/skin/places/livemarkItem.png">Subscriptions</A>
|
|
||||||
<DD>Shows all Subscribed Feeds
|
|
||||||
</DL><p>
|
|
|
@ -41,13 +41,11 @@
|
||||||
%{C++
|
%{C++
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsCOMArray.h"
|
#include "nsCOMArray.h"
|
||||||
#include "nsString.h"
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
interface nsIURI;
|
interface nsIURI;
|
||||||
interface nsIVariant;
|
interface nsIVariant;
|
||||||
|
|
||||||
[ptr] native CStringArray(nsTArray<nsCString>);
|
|
||||||
[ptr] native URIArray(nsCOMArray<nsIURI>);
|
[ptr] native URIArray(nsCOMArray<nsIURI>);
|
||||||
|
|
||||||
[scriptable, uuid(d41c9510-2377-4728-b275-bdad6a0521f8)]
|
[scriptable, uuid(d41c9510-2377-4728-b275-bdad6a0521f8)]
|
||||||
|
@ -67,7 +65,7 @@ interface nsIAnnotationObserver : nsISupports
|
||||||
void onAnnotationRemoved(in nsIURI aURI, in AUTF8String aName);
|
void onAnnotationRemoved(in nsIURI aURI, in AUTF8String aName);
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(e19a463a-0bd5-4e36-b552-e52aa4220b27)]
|
[scriptable, uuid(15999472-f158-11db-8314-0800200c9a66)]
|
||||||
interface nsIAnnotationService : nsISupports
|
interface nsIAnnotationService : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -268,11 +266,6 @@ interface nsIAnnotationService : nsISupports
|
||||||
void getPageAnnotationNames(in nsIURI aURI, out PRUint32 count,
|
void getPageAnnotationNames(in nsIURI aURI, out PRUint32 count,
|
||||||
[retval, array, size_is(count)] out nsIVariant result);
|
[retval, array, size_is(count)] out nsIVariant result);
|
||||||
|
|
||||||
/**
|
|
||||||
* TArray version of getPageAnnotationNames for ease of use in C++ code.
|
|
||||||
*/
|
|
||||||
[noscript] void GetPageAnnotationNamesTArray(in nsIURI aURI, in CStringArray aResult);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for annotation existance.
|
* Test for annotation existance.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -181,7 +181,7 @@ interface nsINavBookmarkObserver : nsISupports
|
||||||
* folders. A URI in history can be contained in one or more such folders.
|
* folders. A URI in history can be contained in one or more such folders.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[scriptable, uuid(7a17cbcb-b4c8-4485-a254-9e8d58663fe7)]
|
[scriptable, uuid(48f31924-f158-11db-8314-0800200c9a66)]
|
||||||
interface nsINavBookmarksService : nsISupports
|
interface nsINavBookmarksService : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -496,23 +496,4 @@ interface nsINavBookmarksService : nsISupports
|
||||||
* done changing. Should match beginUpdateBatch or bad things will happen.
|
* done changing. Should match beginUpdateBatch or bad things will happen.
|
||||||
*/
|
*/
|
||||||
void endUpdateBatch();
|
void endUpdateBatch();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given bookmarks.html file and merges it with the current
|
|
||||||
* bookmarks hierarchy.
|
|
||||||
*/
|
|
||||||
void importBookmarksHTML(in nsIURI url);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given bookmarks.html file and puts it in the given folder
|
|
||||||
*/
|
|
||||||
void importBookmarksHTMLToFolder(in nsIURI url, in PRInt64 folder);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the current bookmarks hierarchy to a bookmarks.html file.
|
|
||||||
*/
|
|
||||||
void exportBookmarksHTML(in nsIFile file);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,7 +81,6 @@ REQUIRES = xpcom \
|
||||||
CPPSRCS = \
|
CPPSRCS = \
|
||||||
nsAnnoProtocolHandler.cpp \
|
nsAnnoProtocolHandler.cpp \
|
||||||
nsAnnotationService.cpp \
|
nsAnnotationService.cpp \
|
||||||
nsBookmarksHTML.cpp \
|
|
||||||
nsFaviconService.cpp \
|
nsFaviconService.cpp \
|
||||||
nsNavHistory.cpp \
|
nsNavHistory.cpp \
|
||||||
nsNavHistoryAutoComplete.cpp \
|
nsNavHistoryAutoComplete.cpp \
|
||||||
|
|
|
@ -637,7 +637,7 @@ nsAnnotationService::GetPageAnnotationNames(nsIURI* aURI, PRUint32* aCount,
|
||||||
|
|
||||||
// nsAnnotationService::GetPageAnnotationNamesTArray
|
// nsAnnotationService::GetPageAnnotationNamesTArray
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsresult
|
||||||
nsAnnotationService::GetPageAnnotationNamesTArray(nsIURI* aURI,
|
nsAnnotationService::GetPageAnnotationNamesTArray(nsIURI* aURI,
|
||||||
nsTArray<nsCString>* aResult)
|
nsTArray<nsCString>* aResult)
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,6 +120,7 @@ protected:
|
||||||
void CallSetObservers(nsIURI* aURI, const nsACString& aName);
|
void CallSetObservers(nsIURI* aURI, const nsACString& aName);
|
||||||
|
|
||||||
static nsresult MigrateFromAlpha1(mozIStorageConnection* aDBConn);
|
static nsresult MigrateFromAlpha1(mozIStorageConnection* aDBConn);
|
||||||
|
nsresult GetPageAnnotationNamesTArray(nsIURI* aURI, nsTArray<nsCString>* aResult);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsAnnotationService_h___ */
|
#endif /* nsAnnotationService_h___ */
|
||||||
|
|
|
@ -426,28 +426,6 @@ nsNavBookmarks::InitRoots()
|
||||||
// importing the default one.
|
// importing the default one.
|
||||||
rv = InitDefaults();
|
rv = InitDefaults();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// migrate the user's old bookmarks
|
|
||||||
// FIXME: move somewhere else to some profile migrator thingy
|
|
||||||
nsCOMPtr<nsIFile> bookmarksFile;
|
|
||||||
rv = NS_GetSpecialDirectory(NS_APP_BOOKMARKS_50_FILE,
|
|
||||||
getter_AddRefs(bookmarksFile));
|
|
||||||
if (bookmarksFile) {
|
|
||||||
PRBool bookmarksFileExists;
|
|
||||||
rv = bookmarksFile->Exists(&bookmarksFileExists);
|
|
||||||
if (NS_SUCCEEDED(rv) && bookmarksFileExists) {
|
|
||||||
nsCOMPtr<nsIIOService> ioservice = do_GetService(
|
|
||||||
"@mozilla.org/network/io-service;1", &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
nsCOMPtr<nsIURI> bookmarksFileURI;
|
|
||||||
rv = ioservice->NewFileURI(bookmarksFile,
|
|
||||||
getter_AddRefs(bookmarksFileURI));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
rv = ImportBookmarksHTMLInternal(bookmarksFileURI, PR_FALSE,
|
|
||||||
0, PR_TRUE);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -653,9 +631,9 @@ nsNavBookmarks::AddBookmarkToHash(PRInt64 aBookmarkId, PRTime aMinTime)
|
||||||
// nsNavBookmkars::RecursiveAddBookmarkHash
|
// nsNavBookmkars::RecursiveAddBookmarkHash
|
||||||
//
|
//
|
||||||
// Used to add a new level of redirect information to the bookmark hash.
|
// Used to add a new level of redirect information to the bookmark hash.
|
||||||
// Given a source bookmark 'aBookmark' and 'aCurrentSouce' that has already
|
// Given a source bookmark 'aBookmark' and 'aCurrentSource' that has already
|
||||||
// been added to the hashtable, this will add all redirect destinations of
|
// been added to the hashtable, this will add all redirect destinations of
|
||||||
// 'aCurrentSort'. Will call itself recursively to walk down the chain.
|
// 'aCurrentSource'. Will call itself recursively to walk down the chain.
|
||||||
//
|
//
|
||||||
// 'aMinTime' is the minimum time to consider visits from. Visits previous
|
// 'aMinTime' is the minimum time to consider visits from. Visits previous
|
||||||
// to this will not be considered. This allows the search to be much more
|
// to this will not be considered. This allows the search to be much more
|
||||||
|
@ -2356,164 +2334,9 @@ nsNavBookmarks::RemoveObserver(nsINavBookmarkObserver *aObserver)
|
||||||
nsresult
|
nsresult
|
||||||
nsNavBookmarks::OnQuit()
|
nsNavBookmarks::OnQuit()
|
||||||
{
|
{
|
||||||
#ifdef MOZ_PLACES_BOOKMARKS
|
|
||||||
// get bookmarks file
|
|
||||||
nsCOMPtr<nsIFile> bookmarksFile;
|
|
||||||
nsresult rv = NS_GetSpecialDirectory(NS_APP_BOOKMARKS_50_FILE,
|
|
||||||
getter_AddRefs(bookmarksFile));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
// create if it doesn't exist
|
|
||||||
PRBool exists;
|
|
||||||
rv = bookmarksFile->Exists(&exists);
|
|
||||||
if (NS_FAILED(rv) || !exists) {
|
|
||||||
rv = bookmarksFile->Create(nsIFile::NORMAL_FILE_TYPE, 0600);
|
|
||||||
NS_ASSERTION(rv, "Unable to create bookmarks.html!");
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// export bookmarks.html
|
|
||||||
rv = ExportBookmarksHTML(bookmarksFile);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
// archive if needed
|
|
||||||
nsCOMPtr<nsIPrefService> prefServ(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
nsCOMPtr<nsIPrefBranch> bookmarksPrefs;
|
|
||||||
rv = prefServ->GetBranch("browser.bookmarks.", getter_AddRefs(bookmarksPrefs));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
PRInt32 numberOfBackups;
|
|
||||||
rv = bookmarksPrefs->GetIntPref("max_backups", &numberOfBackups);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
numberOfBackups = 5;
|
|
||||||
|
|
||||||
if (numberOfBackups > 0) {
|
|
||||||
rv = ArchiveBookmarksFile(numberOfBackups, PR_FALSE);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ArchiveBookmarksFile()
|
|
||||||
*
|
|
||||||
* Creates a dated backup once a day in <profile>/bookmarkbackups
|
|
||||||
*
|
|
||||||
* PRInt32 numberOfBackups - the maximum number of backups to keep
|
|
||||||
*
|
|
||||||
* PRBool forceArchive - forces creating an archive even if one was
|
|
||||||
* already created that day (overwrites)
|
|
||||||
*/
|
|
||||||
nsresult
|
|
||||||
nsNavBookmarks::ArchiveBookmarksFile(PRInt32 numberOfBackups,
|
|
||||||
PRBool forceArchive)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIFile> bookmarksBackupDir;
|
|
||||||
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
|
|
||||||
getter_AddRefs(bookmarksBackupDir));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsDependentCString dirName("bookmarkbackups");
|
|
||||||
rv = bookmarksBackupDir->AppendNative(dirName);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
PRBool exists;
|
|
||||||
rv = bookmarksBackupDir->Exists(&exists);
|
|
||||||
if (NS_FAILED(rv) || !exists) {
|
|
||||||
rv = bookmarksBackupDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
|
||||||
|
|
||||||
// if there's no backup folder, there's no backup, fail
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
// construct the new leafname
|
|
||||||
PRTime now64 = PR_Now();
|
|
||||||
PRExplodedTime nowInfo;
|
|
||||||
PR_ExplodeTime(now64, PR_LocalTimeParameters, &nowInfo);
|
|
||||||
PR_NormalizeTime(&nowInfo, PR_LocalTimeParameters);
|
|
||||||
|
|
||||||
char timeString[128];
|
|
||||||
|
|
||||||
PR_FormatTime(timeString, 128, "bookmarks-%Y-%m-%d.html", &nowInfo);
|
|
||||||
|
|
||||||
nsCAutoString backupFilenameCString(timeString);
|
|
||||||
nsAutoString backupFilenameString = NS_ConvertUTF8toUTF16(backupFilenameCString);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> backupFile;
|
|
||||||
if (forceArchive) {
|
|
||||||
// if we have a backup from today, nuke it
|
|
||||||
nsCOMPtr<nsIFile> currentBackup;
|
|
||||||
rv = bookmarksBackupDir->Clone(getter_AddRefs(currentBackup));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
rv = currentBackup->Append(backupFilenameString);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
rv = currentBackup->Exists(&exists);
|
|
||||||
if (!NS_FAILED(rv) && exists) {
|
|
||||||
rv = currentBackup->Remove(PR_FALSE);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
nsCOMPtr<nsISimpleEnumerator> existingBackups;
|
|
||||||
rv = bookmarksBackupDir->GetDirectoryEntries(getter_AddRefs(existingBackups));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsStringArray backupFileNames;
|
|
||||||
|
|
||||||
PRBool hasMoreElements = PR_FALSE;
|
|
||||||
PRBool hasCurrentBackup = PR_FALSE;
|
|
||||||
|
|
||||||
while (NS_SUCCEEDED(existingBackups->HasMoreElements(&hasMoreElements)) &&
|
|
||||||
hasMoreElements)
|
|
||||||
{
|
|
||||||
rv = existingBackups->GetNext(getter_AddRefs(backupFile));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
nsAutoString backupName;
|
|
||||||
rv = backupFile->GetLeafName(backupName);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
// the backup for today exists, do not create later
|
|
||||||
if (backupName == backupFilenameString) {
|
|
||||||
hasCurrentBackup = PR_TRUE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// mark the rest for possible removal
|
|
||||||
if (Substring(backupName, 0, 10) == NS_LITERAL_STRING("bookmarks-"))
|
|
||||||
backupFileNames.AppendString(backupName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numberOfBackups > 0 && backupFileNames.Count() >= numberOfBackups) {
|
|
||||||
PRInt32 numberOfBackupsToDelete = backupFileNames.Count() - numberOfBackups + 1;
|
|
||||||
backupFileNames.Sort();
|
|
||||||
|
|
||||||
while (numberOfBackupsToDelete--) {
|
|
||||||
(void)bookmarksBackupDir->Clone(getter_AddRefs(backupFile));
|
|
||||||
(void)backupFile->Append(*backupFileNames[0]);
|
|
||||||
(void)backupFile->Remove(PR_FALSE);
|
|
||||||
backupFileNames.RemoveStringAt(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasCurrentBackup)
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> bookmarksFile;
|
|
||||||
rv = NS_GetSpecialDirectory(NS_APP_BOOKMARKS_50_FILE,
|
|
||||||
getter_AddRefs(bookmarksFile));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = bookmarksFile->CopyTo(bookmarksBackupDir, backupFilenameString);
|
|
||||||
// at least dump something out in case this fails in a debug build
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// nsNavBookmarks::nsINavHistoryObserver
|
// nsNavBookmarks::nsINavHistoryObserver
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -110,7 +110,6 @@ public:
|
||||||
|
|
||||||
// Called by History service when quitting.
|
// Called by History service when quitting.
|
||||||
nsresult OnQuit();
|
nsresult OnQuit();
|
||||||
nsresult ArchiveBookmarksFile(PRInt32 aNumberOfBackups, PRBool aForceArchive);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static nsNavBookmarks *sInstance;
|
static nsNavBookmarks *sInstance;
|
||||||
|
@ -256,23 +255,6 @@ private:
|
||||||
nsCString mType;
|
nsCString mType;
|
||||||
PRInt32 mIndex;
|
PRInt32 mIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
// in nsBookmarksHTML
|
|
||||||
nsresult ImportBookmarksHTMLInternal(nsIURI* aURL,
|
|
||||||
PRBool aAllowRootChanges,
|
|
||||||
PRInt64 aFolder,
|
|
||||||
PRBool aIsImportDefaults);
|
|
||||||
nsresult WriteItem(nsNavHistoryResultNode* aItem, const nsCString& aIndent,
|
|
||||||
nsIOutputStream* aOutput);
|
|
||||||
nsresult WriteContainer(PRInt64 aFolder, const nsCString& aIndent,
|
|
||||||
nsIOutputStream* aOutput);
|
|
||||||
nsresult WriteContainerHeader(PRInt64 aFolder, const nsCString& aIndent,
|
|
||||||
nsIOutputStream* aOutput);
|
|
||||||
nsresult WriteContainerTitle(PRInt64 aFolder, nsIOutputStream* aOutput);
|
|
||||||
nsresult WriteLivemark(PRInt64 aFolderId, const nsCString& aIndent,
|
|
||||||
nsIOutputStream* aOutput);
|
|
||||||
nsresult WriteContainerContents(PRInt64 aFolder, const nsCString& aIndent,
|
|
||||||
nsIOutputStream* aOutput);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nsBookmarksUpdateBatcher
|
struct nsBookmarksUpdateBatcher
|
||||||
|
|
|
@ -125,7 +125,7 @@ bmsvc.addObserver(observer, false);
|
||||||
var root = bmsvc.bookmarksRoot;
|
var root = bmsvc.bookmarksRoot;
|
||||||
|
|
||||||
// index at which items should begin
|
// index at which items should begin
|
||||||
var bmStartIndex = 4;
|
var bmStartIndex = 1;
|
||||||
|
|
||||||
// main
|
// main
|
||||||
function run_test() {
|
function run_test() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче