- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / importer / firefox_importer_utils.h
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_COMMON_IMPORTER_FIREFOX_IMPORTER_UTILS_H_
6 #define CHROME_COMMON_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 // Returns the path to the Firefox profile, using a custom dictionary.
47 // Exposed for testing.
48 base::FilePath GetFirefoxProfilePathFromDictionary(
49     const base::DictionaryValue& root);
50
51 // Detects version of Firefox and installation path for the given Firefox
52 // profile.
53 bool GetFirefoxVersionAndPathFromProfile(const base::FilePath& profile_path,
54                                          int* version,
55                                          base::FilePath* app_path);
56
57 // Gets the full path of the profiles.ini file. This file records the profiles
58 // that can be used by Firefox. Returns an empty path if failed.
59 base::FilePath GetProfilesINI();
60
61 // Parses the profile.ini file, and stores its information in |root|.
62 // This file is a plain-text file. Key/value pairs are stored one per line, and
63 // they are separated in different sections. For example:
64 //   [General]
65 //   StartWithLastProfile=1
66 //
67 //   [Profile0]
68 //   Name=default
69 //   IsRelative=1
70 //   Path=Profiles/abcdefeg.default
71 // We set "[value]" in path "<Section>.<Key>". For example, the path
72 // "Genenral.StartWithLastProfile" has the value "1".
73 void ParseProfileINI(const base::FilePath& file, base::DictionaryValue* root);
74
75 // Returns the home page set in Firefox in a particular profile.
76 GURL GetHomepage(const base::FilePath& profile_path);
77
78 // Checks to see if this home page is a default home page, as specified by
79 // the resource file browserconfig.properties in the Firefox application
80 // directory.
81 bool IsDefaultHomepage(const GURL& homepage, const base::FilePath& app_path);
82
83 // Parses the value of a particular firefox preference from a string that is the
84 // contents of the prefs file.
85 std::string GetPrefsJsValue(const std::string& prefs,
86                             const std::string& pref_key);
87
88 // Returns the localized Firefox branding name.
89 // This is useful to differentiate between Firefox and Iceweasel.
90 // If anything goes wrong while trying to obtain the branding name,
91 // the function assumes it's Firefox.
92 string16 GetFirefoxImporterName(const base::FilePath& app_path);
93
94 #endif  // CHROME_COMMON_IMPORTER_FIREFOX_IMPORTER_UTILS_H_