nsSafariProfileMigrator.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is The Browser Profile Migrator.
16  *
17  * The Initial Developer of the Original Code is Ben Goodger.
18  * Portions created by the Initial Developer are Copyright (C) 2004
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Ben Goodger <ben@bengoodger.com>
23  * Asaf Romano <mozilla.mano@sent.com>
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38 
39 #ifndef safariprofilemigrator___h___
40 #define safariprofilemigrator___h___
41 
42 #include "nsIBrowserProfileMigrator.h"
43 #include "nsIObserverService.h"
44 #include "nsISupportsArray.h"
45 #include "nsStringAPI.h"
46 #include "nsINavHistoryService.h"
47 
48 #include <CoreFoundation/CoreFoundation.h>
49 
50 class nsIRDFDataSource;
51 
53  public nsINavHistoryBatchCallback
54 {
55 public:
56  NS_DECL_NSIBROWSERPROFILEMIGRATOR
57  NS_DECL_NSINAVHISTORYBATCHCALLBACK
59 
61  virtual ~nsSafariProfileMigrator();
62 
63  typedef enum { STRING, INT, BOOL } PrefType;
64 
65  typedef nsresult(*prefConverter)(void*, nsIPrefBranch*);
66 
67  struct PrefTransform {
68  CFStringRef keyName;
72  PRBool prefHasValue;
73  union {
74  PRInt32 intValue;
75  PRBool boolValue;
76  char* stringValue;
77  };
78  };
79 
80  static nsresult SetBool(void* aTransform, nsIPrefBranch* aBranch);
81  static nsresult SetBoolInverted(void* aTransform, nsIPrefBranch* aBranch);
82  static nsresult SetString(void* aTransform, nsIPrefBranch* aBranch);
83  static nsresult SetInt(void* aTransform, nsIPrefBranch* aBranch);
84  static nsresult SetDefaultEncoding(void* aTransform, nsIPrefBranch* aBranch);
85  static nsresult SetDownloadFolder(void* aTransform, nsIPrefBranch* aBranch);
86  static nsresult SetDownloadHandlers(void* aTransform, nsIPrefBranch* aBranch);
87  static nsresult SetDownloadRetention(void* aTransform, nsIPrefBranch* aBranch);
88  static nsresult SetDisplayImages(void* aTransform, nsIPrefBranch* aBranch);
89  static nsresult SetFontName(void* aTransform, nsIPrefBranch* aBranch);
90  static nsresult SetFontSize(void* aTransform, nsIPrefBranch* aBranch);
91  static void CleanResource(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource);
92 
93 protected:
94  nsresult CopyPreferences(PRBool aReplace);
95  nsresult CopyCookies(PRBool aReplace);
104  nsresult CopyHistory(PRBool aReplace);
105  nsresult CopyHistoryBatched(PRBool aReplace);
115  nsresult CopyBookmarks(PRBool aReplace);
116  nsresult CopyBookmarksBatched(PRBool aReplace);
117  nsresult ParseBookmarksFolder(CFArrayRef aChildren,
118  PRInt64 aParentFolder,
119  nsINavBookmarksService * aBookmarksService,
120  PRBool aIsAtRootLevel);
121  nsresult CopyFormData(PRBool aReplace);
122  nsresult CopyOtherData(PRBool aReplace);
123 
124  nsresult ProfileHasContentStyleSheet(PRBool *outExists);
125  nsresult GetSafariUserStyleSheet(nsILocalFile** aResult);
126 
127 private:
128  PRBool HasFormDataToImport();
129  nsCOMPtr<nsIObserverService> mObserverService;
130 };
131 
132 #endif
static void CleanResource(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource)
static nsresult SetDownloadFolder(void *aTransform, nsIPrefBranch *aBranch)
nsresult CopyBookmarksBatched(PRBool aReplace)
nsresult(* prefConverter)(void *, nsIPrefBranch *)
static nsresult SetInt(void *aTransform, nsIPrefBranch *aBranch)
static nsresult SetString(void *aTransform, nsIPrefBranch *aBranch)
static nsresult SetDownloadRetention(void *aTransform, nsIPrefBranch *aBranch)
static nsresult SetDisplayImages(void *aTransform, nsIPrefBranch *aBranch)
const nsIPrefBranch
nsresult CopyBookmarks(PRBool aReplace)
nsresult CopyFormData(PRBool aReplace)
nsresult CopyPreferences(PRBool aReplace)
static nsresult SetFontName(void *aTransform, nsIPrefBranch *aBranch)
static nsresult SetDefaultEncoding(void *aTransform, nsIPrefBranch *aBranch)
nsresult CopyHistoryBatched(PRBool aReplace)
static nsresult SetFontSize(void *aTransform, nsIPrefBranch *aBranch)
static nsresult SetDownloadHandlers(void *aTransform, nsIPrefBranch *aBranch)
nsresult CopyCookies(PRBool aReplace)
NS_DECL_NSIBROWSERPROFILEMIGRATOR NS_DECL_NSINAVHISTORYBATCHCALLBACK NS_DECL_ISUPPORTS nsSafariProfileMigrator()
nsresult GetSafariUserStyleSheet(nsILocalFile **aResult)
nsresult ProfileHasContentStyleSheet(PRBool *outExists)
static nsresult SetBoolInverted(void *aTransform, nsIPrefBranch *aBranch)
nsresult CopyHistory(PRBool aReplace)
static nsresult SetBool(void *aTransform, nsIPrefBranch *aBranch)
nsresult ParseBookmarksFolder(CFArrayRef aChildren, PRInt64 aParentFolder, nsINavBookmarksService *aBookmarksService, PRBool aIsAtRootLevel)
nsresult CopyOtherData(PRBool aReplace)