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.
5 #ifndef CHROME_COMMON_IMPORTER_FIREFOX_IMPORTER_UTILS_H_
6 #define CHROME_COMMON_IMPORTER_FIREFOX_IMPORTER_UTILS_H_
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
13 #include "build/build_config.h"
19 class DictionaryValue
;
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
28 int GetCurrentFirefoxMajorVersionFromRegistry();
30 // Detects where Firefox lives. Returns an empty path if Firefox is not
32 base::FilePath
GetFirefoxInstallPathFromRegistry();
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();
43 // Returns the path to the Firefox profile.
44 base::FilePath
GetFirefoxProfilePath();
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
);
51 // Detects version of Firefox and installation path for the given Firefox
53 bool GetFirefoxVersionAndPathFromProfile(const base::FilePath
& profile_path
,
55 base::FilePath
* app_path
);
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();
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:
65 // StartWithLastProfile=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
);
75 // Returns the home page set in Firefox in a particular profile.
76 GURL
GetHomepage(const base::FilePath
& profile_path
);
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
81 bool IsDefaultHomepage(const GURL
& homepage
, const base::FilePath
& app_path
);
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
);
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 base::string16
GetFirefoxImporterName(const base::FilePath
& app_path
);
94 #endif // CHROME_COMMON_IMPORTER_FIREFOX_IMPORTER_UTILS_H_