OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UTILS_H_ | |
6 #define CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UTILS_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/strings/string16.h" | |
13 #include "build/build_config.h" | |
14 | |
15 class GURL; | |
16 class TemplateURL; | |
17 | |
18 namespace base { | |
19 class DictionaryValue; | |
20 class FilePath; | |
21 } | |
22 | |
23 #if defined(OS_WIN) | |
24 // Detects which version of Firefox is installed from registry. Returns its | |
25 // major version, and drops the minor version. Returns 0 if failed. If there are | |
26 // indicators of both Firefox 2 and Firefox 3 it is biased to return the biggest | |
27 // version. | |
28 int GetCurrentFirefoxMajorVersionFromRegistry(); | |
29 | |
30 // Detects where Firefox lives. Returns an empty path if Firefox is not | |
31 // installed. | |
32 base::FilePath GetFirefoxInstallPathFromRegistry(); | |
33 #endif // OS_WIN | |
34 | |
35 #if defined(OS_MACOSX) | |
36 // Get the directory in which the Firefox .dylibs live, we need to load these | |
37 // in order to decoded FF profile passwords. | |
38 // The Path is usuall FF App Bundle/Contents/Mac OS/ | |
39 // Returns empty path on failure. | |
40 base::FilePath GetFirefoxDylibPath(); | |
41 #endif // OS_MACOSX | |
42 | |
43 // Returns the path to the Firefox profile. | |
44 base::FilePath GetFirefoxProfilePath(); | |
45 | |
46 // Detects version of Firefox and installation path for the given Firefox | |
47 // profile. | |
48 bool GetFirefoxVersionAndPathFromProfile(const base::FilePath& profile_path, | |
49 int* version, | |
50 base::FilePath* app_path); | |
51 | |
52 // Gets the full path of the profiles.ini file. This file records the profiles | |
53 // that can be used by Firefox. Returns an empty path if failed. | |
54 base::FilePath GetProfilesINI(); | |
55 | |
56 // Parses the profile.ini file, and stores its information in |root|. | |
57 // This file is a plain-text file. Key/value pairs are stored one per line, and | |
58 // they are separated in different sections. For example: | |
59 // [General] | |
60 // StartWithLastProfile=1 | |
61 // | |
62 // [Profile0] | |
63 // Name=default | |
64 // IsRelative=1 | |
65 // Path=Profiles/abcdefeg.default | |
66 // We set "[value]" in path "<Section>.<Key>". For example, the path | |
67 // "Genenral.StartWithLastProfile" has the value "1". | |
68 void ParseProfileINI(const base::FilePath& file, base::DictionaryValue* root); | |
69 | |
70 // Returns true if we want to add the URL to the history. We filter out the URL | |
71 // with a unsupported scheme. | |
72 bool CanImportURL(const GURL& url); | |
73 | |
74 // Returns the home page set in Firefox in a particular profile. | |
75 GURL GetHomepage(const base::FilePath& profile_path); | |
76 | |
77 // Checks to see if this home page is a default home page, as specified by | |
78 // the resource file browserconfig.properties in the Firefox application | |
79 // directory. | |
80 bool IsDefaultHomepage(const GURL& homepage, const base::FilePath& app_path); | |
81 | |
82 // Parses the prefs found in the file |pref_file| and puts the key/value pairs | |
83 // in |prefs|. Keys are strings, and values can be strings, booleans or | |
84 // integers. Returns true if it succeeded, false otherwise (in which case | |
85 // |prefs| is not filled). | |
86 // Note: for strings, only valid UTF-8 string values are supported. If a | |
87 // key/pair is not valid UTF-8, it is ignored and will not appear in |prefs|. | |
88 bool ParsePrefFile(const base::FilePath& pref_file, base::DictionaryValue* prefs
); | |
89 | |
90 // Parses the value of a particular firefox preference from a string that is the | |
91 // contents of the prefs file. | |
92 std::string GetPrefsJsValue(const std::string& prefs, | |
93 const std::string& pref_key); | |
94 | |
95 // Returns the localized Firefox branding name. | |
96 // This is useful to differentiate between Firefox and Iceweasel. | |
97 // If anything goes wrong while trying to obtain the branding name, | |
98 // the function assumes it's Firefox. | |
99 string16 GetFirefoxImporterName(const base::FilePath& app_path); | |
100 | |
101 #endif // CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UTILS_H_ | |
OLD | NEW |