summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjcivelli@google.com <jcivelli@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 23:19:47 +0000
committerjcivelli@google.com <jcivelli@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 23:19:47 +0000
commit4200a20809504434ab46abf92cd23568b9e2e72f (patch)
treeec5ab7d1e7b2a23dde9d877dfaec434e5dc33151 /chrome
parent3277c385ff33e524a587eaf7c273ed88f134a80b (diff)
downloadchromium_src-4200a20809504434ab46abf92cd23568b9e2e72f.zip
chromium_src-4200a20809504434ab46abf92cd23568b9e2e72f.tar.gz
chromium_src-4200a20809504434ab46abf92cd23568b9e2e72f.tar.bz2
Adding a way to retrieve Firefox proxy settings.
BUG=None TEST=None Review URL: http://codereview.chromium.org/1703010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/importer/firefox_importer_utils.cc111
-rw-r--r--chrome/browser/importer/firefox_importer_utils.h8
-rw-r--r--chrome/browser/importer/firefox_proxy_settings.cc158
-rw-r--r--chrome/browser/importer/firefox_proxy_settings.h98
-rw-r--r--chrome/browser/importer/firefox_proxy_settings_unittest.cc51
-rw-r--r--chrome/browser/importer/importer_list.cc72
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/test/data/firefox3_pref.js136
9 files changed, 579 insertions, 58 deletions
diff --git a/chrome/browser/importer/firefox_importer_utils.cc b/chrome/browser/importer/firefox_importer_utils.cc
index 5ee8a13..c72aa7f 100644
--- a/chrome/browser/importer/firefox_importer_utils.cc
+++ b/chrome/browser/importer/firefox_importer_utils.cc
@@ -43,6 +43,51 @@ class FirefoxURLParameterFilter : public TemplateURLParser::ParameterFilter {
};
} // namespace
+FilePath GetFirefoxProfilePath() {
+ DictionaryValue root;
+ FilePath ini_file = GetProfilesINI();
+ ParseProfileINI(ini_file, &root);
+
+ FilePath source_path;
+ for (int i = 0; ; ++i) {
+ std::string current_profile = StringPrintf("Profile%d", i);
+ if (!root.HasKeyASCII(current_profile)) {
+ // Profiles are continuously numbered. So we exit when we can't
+ // find the i-th one.
+ break;
+ }
+ std::string is_relative;
+ string16 path16;
+ if (root.GetStringASCII(current_profile + ".IsRelative", &is_relative) &&
+ root.GetString(current_profile + ".Path", &path16)) {
+#if defined(OS_WIN)
+ ReplaceSubstringsAfterOffset(
+ &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\"));
+#endif
+ FilePath path = FilePath::FromWStringHack(UTF16ToWide(path16));
+
+ // IsRelative=1 means the folder path would be relative to the
+ // path of profiles.ini. IsRelative=0 refers to a custom profile
+ // location.
+ if (is_relative == "1") {
+ path = ini_file.DirName().Append(path);
+ }
+
+ // We only import the default profile when multiple profiles exist,
+ // since the other profiles are used mostly by developers for testing.
+ // Otherwise, Profile0 will be imported.
+ std::string is_default;
+ if ((root.GetStringASCII(current_profile + ".Default", &is_default) &&
+ is_default == "1") || i == 0) {
+ // We have found the default profile.
+ return path;
+ }
+ }
+ }
+ return FilePath();
+}
+
+
bool GetFirefoxVersionAndPathFromProfile(const FilePath& profile_path,
int* version,
FilePath* app_path) {
@@ -331,3 +376,69 @@ bool IsDefaultHomepage(const GURL& homepage, const FilePath& app_path) {
return false;
}
+
+bool ParsePrefFile(const FilePath& pref_file, DictionaryValue* prefs) {
+ // The string that is before a pref key.
+ const std::string kUserPrefString = "user_pref(\"";
+ std::string contents;
+ if (!file_util::ReadFileToString(pref_file, &contents))
+ return false;
+
+ std::vector<std::string> lines;
+ Tokenize(contents, "\n", &lines);
+
+ for (std::vector<std::string>::const_iterator iter = lines.begin();
+ iter != lines.end(); ++iter) {
+ const std::string& line = *iter;
+ size_t start_key = line.find(kUserPrefString);
+ if (start_key == std::string::npos)
+ continue; // Could be a comment or a blank line.
+ start_key += kUserPrefString.length();
+ size_t stop_key = line.find('"', start_key);
+ if (stop_key == std::string::npos) {
+ LOG(ERROR) << "Invalid key found in Firefox pref file '" <<
+ pref_file.value() << "' line is '" << line << "'.";
+ continue;
+ }
+ std::string key = line.substr(start_key, stop_key - start_key);
+ size_t start_value = line.find(',', stop_key + 1);
+ if (start_value == std::string::npos) {
+ LOG(ERROR) << "Invalid value found in Firefox pref file '" <<
+ pref_file.value() << "' line is '" << line << "'.";
+ continue;
+ }
+ size_t stop_value = line.find(");", start_value + 1);
+ if (stop_value == std::string::npos) {
+ LOG(ERROR) << "Invalid value found in Firefox pref file '" <<
+ pref_file.value() << "' line is '" << line << "'.";
+ continue;
+ }
+ std::string value = line.substr(start_value + 1,
+ stop_value - start_value - 1);
+ TrimWhitespace(value, TRIM_ALL, &value);
+ // Value could be a boolean.
+ bool is_value_true = LowerCaseEqualsASCII(value, "true");
+ if (is_value_true || LowerCaseEqualsASCII(value, "false")) {
+ prefs->SetBoolean(ASCIIToWide(key), is_value_true);
+ continue;
+ }
+
+ // Value could be a string.
+ if (value.size() >= 2U &&
+ value[0] == '"' && value[value.size() - 1] == '"') {
+ prefs->SetString(ASCIIToWide(key), value.substr(1, value.size() - 2));
+ continue;
+ }
+
+ // Or value could be an integer.
+ int int_value = 0;
+ if (StringToInt(value, &int_value)) {
+ prefs->SetInteger(ASCIIToWide(key), int_value);
+ continue;
+ }
+
+ LOG(ERROR) << "Invalid value found in Firefox pref file '" <<
+ pref_file.value() << "' value is '" << value << "'.";
+ }
+ return true;
+}
diff --git a/chrome/browser/importer/firefox_importer_utils.h b/chrome/browser/importer/firefox_importer_utils.h
index 4e00b5a..c97833f 100644
--- a/chrome/browser/importer/firefox_importer_utils.h
+++ b/chrome/browser/importer/firefox_importer_utils.h
@@ -36,6 +36,9 @@ std::wstring GetFirefoxInstallPathFromRegistry();
FilePath GetFirefoxDylibPath();
#endif // OS_MACOSX
+// Returns the path to the Firefox profile.
+FilePath GetFirefoxProfilePath();
+
// Detects version of Firefox and installation path from given Firefox profile
bool GetFirefoxVersionAndPathFromProfile(const FilePath& profile_path,
int* version,
@@ -83,5 +86,10 @@ GURL GetHomepage(const FilePath& profile_path);
// directory.
bool IsDefaultHomepage(const GURL& homepage, const FilePath& app_path);
+// Parses the prefs found in the file |pref_file| and puts the key/value pairs
+// in |prefs|. Keys are strings, and values can be strings, booleans or
+// integers. Returns true if it succeeded, false otherwise (in which case
+// |prefs| is not filled).
+bool ParsePrefFile(const FilePath& pref_file, DictionaryValue* prefs);
#endif // CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UTILS_H_
diff --git a/chrome/browser/importer/firefox_proxy_settings.cc b/chrome/browser/importer/firefox_proxy_settings.cc
new file mode 100644
index 0000000..493beff
--- /dev/null
+++ b/chrome/browser/importer/firefox_proxy_settings.cc
@@ -0,0 +1,158 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/importer/firefox_proxy_settings.h"
+
+#include "base/string_tokenizer.h"
+#include "base/string_util.h"
+#include "base/values.h"
+#include "chrome/browser/importer/firefox_importer_utils.h"
+
+namespace {
+
+const wchar_t* const kNetworkProxyTypeKey = L"network.proxy.type";
+const char* const kHTTPProxyKey = "network.proxy.http";
+const wchar_t* const kHTTPProxyPortKey = L"network.proxy.http_port";
+const char* const kSSLProxyKey = "network.proxy.ssl";
+const wchar_t* const kSSLProxyPortKey = L"network.proxy.ssl_port";
+const char* const kFTPProxyKey = "network.proxy.ftp";
+const wchar_t* const kFTPProxyPortKey = L"network.proxy.ftp_port";
+const char* const kGopherProxyKey = "network.proxy.gopher";
+const wchar_t* const kGopherProxyPortKey = L"network.proxy.gopher_port";
+const char* const kSOCKSHostKey = "network.proxy.socks";
+const wchar_t* const kSOCKSHostPortKey = L"network.proxy.socks_port";
+const wchar_t* const kSOCKSVersionKey = L"network.proxy.socks_version";
+const char* const kAutoconfigURL = "network.proxy.autoconfig_url";
+const char* const kNoProxyListKey = "network.proxy.no_proxies_on";
+const char* const kPrefFileName = "prefs.js";
+
+FirefoxProxySettings::ProxyConfig IntToProxyConfig(int type) {
+ switch (type) {
+ case 1:
+ return FirefoxProxySettings::MANUAL;
+ case 2:
+ return FirefoxProxySettings::AUTO_FROM_URL;
+ case 4:
+ return FirefoxProxySettings::AUTO_DETECT;
+ case 5:
+ return FirefoxProxySettings::SYSTEM;
+ default:
+ LOG(ERROR) << "Unknown Firefox proxy config type: " << type;
+ return FirefoxProxySettings::NO_PROXY;
+ }
+}
+
+FirefoxProxySettings::SOCKSVersion IntToSOCKSVersion(int type) {
+ switch (type) {
+ case 4:
+ return FirefoxProxySettings::V4;
+ case 5:
+ return FirefoxProxySettings::V5;
+ default:
+ LOG(ERROR) << "Unknown Firefox proxy config type: " << type;
+ return FirefoxProxySettings::UNKNONW;
+ }
+}
+
+} // namespace
+
+FirefoxProxySettings::FirefoxProxySettings() {
+ Reset();
+}
+
+FirefoxProxySettings::~FirefoxProxySettings() {
+}
+
+void FirefoxProxySettings::Reset() {
+ config_type_ = NO_PROXY;
+ http_proxy_.clear();
+ http_proxy_port_ = 0;
+ ssl_proxy_.clear();
+ ssl_proxy_port_ = 0;
+ ftp_proxy_.clear();
+ ftp_proxy_port_ = 0;
+ gopher_proxy_.clear();
+ gopher_proxy_port_ = 0;
+ socks_host_.clear();
+ socks_port_ = 0;
+ socks_version_ = UNKNONW;
+ proxy_bypass_list_.clear();
+ autoconfig_url_.clear();
+}
+
+// static
+ bool FirefoxProxySettings::GetSettings(FirefoxProxySettings* settings) {
+ DCHECK(settings);
+ settings->Reset();
+
+ FilePath profile_path = GetFirefoxProfilePath();
+ if (profile_path.empty())
+ return false;
+ FilePath pref_file = profile_path.AppendASCII(kPrefFileName);
+ return GetSettingsFromFile(pref_file, settings);
+}
+
+// static
+bool FirefoxProxySettings::GetSettingsFromFile(const FilePath& pref_file,
+ FirefoxProxySettings* settings) {
+ DictionaryValue dictionary;
+ if (!ParsePrefFile(pref_file, &dictionary))
+ return false;
+
+ int proxy_type = 0;
+ if (!dictionary.GetInteger(kNetworkProxyTypeKey, &proxy_type))
+ return true; // No type means no proxy.
+
+ settings->config_type_ = IntToProxyConfig(proxy_type);
+ if (settings->config_type_ == AUTO_FROM_URL) {
+ if (!dictionary.GetStringASCII(kAutoconfigURL,
+ &(settings->autoconfig_url_))) {
+ LOG(ERROR) << "Failed to retrieve Firefox proxy autoconfig URL";
+ }
+ return false;
+ }
+
+ if (settings->config_type_ == MANUAL) {
+ if (!dictionary.GetStringASCII(kHTTPProxyKey, &(settings->http_proxy_)))
+ LOG(ERROR) << "Failed to retrieve Firefox proxy HTTP host";
+ if (!dictionary.GetInteger(kHTTPProxyPortKey,
+ &(settings->http_proxy_port_))) {
+ LOG(ERROR) << "Failed to retrieve Firefox proxy HTTP port";
+ }
+ if (!dictionary.GetStringASCII(kSSLProxyKey, &(settings->ssl_proxy_)))
+ LOG(ERROR) << "Failed to retrieve Firefox proxy SSL host";
+ if (!dictionary.GetInteger(kSSLProxyPortKey, &(settings->ssl_proxy_port_)))
+ LOG(ERROR) << "Failed to retrieve Firefox proxy SSL port";
+ if (!dictionary.GetStringASCII(kFTPProxyKey, &(settings->ftp_proxy_)))
+ LOG(ERROR) << "Failed to retrieve Firefox proxy FTP host";
+ if (!dictionary.GetInteger(kFTPProxyPortKey, &(settings->ftp_proxy_port_)))
+ LOG(ERROR) << "Failed to retrieve Firefox proxy SSL port";
+ if (!dictionary.GetStringASCII(kGopherProxyKey, &(settings->gopher_proxy_)))
+ LOG(ERROR) << "Failed to retrieve Firefox proxy gopher host";
+ if (!dictionary.GetInteger(kGopherProxyPortKey,
+ &(settings->gopher_proxy_port_))) {
+ LOG(ERROR) << "Failed to retrieve Firefox proxy gopher port";
+ }
+ if (!dictionary.GetStringASCII(kSOCKSHostKey, &(settings->socks_host_)))
+ LOG(ERROR) << "Failed to retrieve Firefox SOCKS host";
+ if (!dictionary.GetInteger(kSOCKSHostPortKey, &(settings->socks_port_)))
+ LOG(ERROR) << "Failed to retrieve Firefox SOCKS port";
+ int socks_version;
+ if (dictionary.GetInteger(kSOCKSVersionKey, &socks_version))
+ settings->socks_version_ = IntToSOCKSVersion(socks_version);
+
+ std::string proxy_bypass;
+ if (dictionary.GetStringASCII(kNoProxyListKey, &proxy_bypass) &&
+ !proxy_bypass.empty()) {
+ StringTokenizer string_tok(proxy_bypass, ",");
+ while (string_tok.GetNext()) {
+ std::string token = string_tok.token();
+ TrimWhitespaceASCII(token, TRIM_ALL, &token);
+ if (!token.empty())
+ settings->proxy_bypass_list_.push_back(token);
+ }
+ }
+ }
+ return true;
+}
diff --git a/chrome/browser/importer/firefox_proxy_settings.h b/chrome/browser/importer/firefox_proxy_settings.h
new file mode 100644
index 0000000..eb624bd
--- /dev/null
+++ b/chrome/browser/importer/firefox_proxy_settings.h
@@ -0,0 +1,98 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_IMPORTER_FIREFOX_PROXY_SETTINGS_H_
+#define CHROME_BROWSER_IMPORTER_FIREFOX_PROXY_SETTINGS_H_
+
+#include <string>
+#include <vector>
+
+#include "base/logging.h"
+
+class FilePath;
+
+class FirefoxProxySettings {
+ public:
+ enum ProxyConfig {
+ NO_PROXY = 0, // No proxy are used.
+ AUTO_DETECT, // Automatically detected.
+ SYSTEM, // Using system proxy settings.
+ AUTO_FROM_URL, // Automatically configured from a URL.
+ MANUAL // User specified settings.
+ };
+
+ enum SOCKSVersion {
+ UNKNONW = 0,
+ V4,
+ V5
+ };
+
+ FirefoxProxySettings();
+ ~FirefoxProxySettings();
+
+ // Sets |settings| to the proxy settings for the current installed version of
+ // Firefox and returns true if successful.
+ // Returns false if Firefox is not installed or if the settings could not be
+ // retrieved.
+ static bool GetSettings(FirefoxProxySettings* settings);
+
+ // Resets all the states of this FirefoxProxySettings to no proxy.
+ void Reset();
+
+ ProxyConfig config_type() const { return config_type_; }
+
+ std::string http_proxy() const { return http_proxy_; }
+ int http_proxy_port() const { return http_proxy_port_; }
+
+ std::string ssl_proxy() const { return ssl_proxy_; }
+ int ssl_proxy_port() const { return ssl_proxy_port_; }
+
+ std::string ftp_proxy() const { return ftp_proxy_; }
+ int ftp_proxy_port() const { return ftp_proxy_port_; }
+
+ std::string gopher_proxy() const { return gopher_proxy_; }
+ int gopher_proxy_port() const { return gopher_proxy_port_; }
+
+ std::string socks_host() const { return socks_host_; }
+ int socks_port() const { return socks_port_; }
+ SOCKSVersion socks_version() const { return socks_version_; }
+
+ std::vector<std::string> proxy_bypass_list() const {
+ return proxy_bypass_list_;
+ }
+
+ protected:
+ // Gets the settings from the passed prefs.js file and returns true if
+ // successful.
+ // Protected for tests.
+ static bool GetSettingsFromFile(const FilePath& pref_file,
+ FirefoxProxySettings* settings);
+
+ private:
+ ProxyConfig config_type_;
+
+ std::string http_proxy_;
+ int http_proxy_port_;
+
+ std::string ssl_proxy_;
+ int ssl_proxy_port_;
+
+ std::string ftp_proxy_;
+ int ftp_proxy_port_;
+
+ std::string gopher_proxy_;
+ int gopher_proxy_port_;
+
+ std::string socks_host_;
+ int socks_port_;
+ SOCKSVersion socks_version_;
+
+ std::vector<std::string> proxy_bypass_list_;
+
+ std::string autoconfig_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(FirefoxProxySettings);
+};
+
+#endif // CHROME_BROWSER_IMPORTER_FIREFOX_PROXY_SETTINGS_H_
diff --git a/chrome/browser/importer/firefox_proxy_settings_unittest.cc b/chrome/browser/importer/firefox_proxy_settings_unittest.cc
new file mode 100644
index 0000000..8c854f4
--- /dev/null
+++ b/chrome/browser/importer/firefox_proxy_settings_unittest.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "base/file_path.h"
+#include "base/path_service.h"
+#include "chrome/browser/importer/firefox_proxy_settings.h"
+#include "chrome/common/chrome_paths.h"
+
+class FirefoxProxySettingsTest : public testing::Test {
+};
+
+class TestFirefoxProxySettings : public FirefoxProxySettings {
+ public:
+ TestFirefoxProxySettings() {}
+
+ static bool TestGetSettingsFromFile(const FilePath& pref_file,
+ FirefoxProxySettings* settings) {
+ return GetSettingsFromFile(pref_file, settings);
+ }
+};
+
+TEST_F(FirefoxProxySettingsTest, TestParse) {
+ FirefoxProxySettings settings;
+
+ FilePath js_pref_path;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &js_pref_path));
+ js_pref_path = js_pref_path.AppendASCII("firefox3_pref.js");
+
+ EXPECT_TRUE(TestFirefoxProxySettings::TestGetSettingsFromFile(js_pref_path,
+ &settings));
+ EXPECT_EQ(FirefoxProxySettings::MANUAL, settings.config_type());
+ EXPECT_EQ("http_proxy", settings.http_proxy());
+ EXPECT_EQ(1111, settings.http_proxy_port());
+ EXPECT_EQ("ssl_proxy", settings.ssl_proxy());
+ EXPECT_EQ(2222, settings.ssl_proxy_port());
+ EXPECT_EQ("ftp_proxy", settings.ftp_proxy());
+ EXPECT_EQ(3333, settings.ftp_proxy_port());
+ EXPECT_EQ("gopher_proxy", settings.gopher_proxy());
+ EXPECT_EQ(4444, settings.gopher_proxy_port());
+ EXPECT_EQ("socks_host", settings.socks_host());
+ EXPECT_EQ(5555, settings.socks_port());
+ EXPECT_EQ(FirefoxProxySettings::V4, settings.socks_version());
+ ASSERT_EQ(3U, settings.proxy_bypass_list().size());
+ EXPECT_EQ("localhost", settings.proxy_bypass_list()[0]);
+ EXPECT_EQ("127.0.0.1", settings.proxy_bypass_list()[1]);
+ EXPECT_EQ("noproxy.com", settings.proxy_bypass_list()[2]);
+}
+
diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc
index fccc389..f9ddaea 100644
--- a/chrome/browser/importer/importer_list.cc
+++ b/chrome/browser/importer/importer_list.cc
@@ -119,51 +119,9 @@ void ImporterList::DetectIEProfiles() {
#endif
void ImporterList::DetectFirefoxProfiles() {
- DictionaryValue root;
- FilePath ini_file = GetProfilesINI();
- ParseProfileINI(ini_file, &root);
-
- FilePath source_path;
- for (int i = 0; ; ++i) {
- std::string current_profile = "Profile" + IntToString(i);
- if (!root.HasKeyASCII(current_profile)) {
- // Profiles are continuously numbered. So we exit when we can't
- // find the i-th one.
- break;
- }
- std::string is_relative;
- string16 path16;
- FilePath profile_path;
- if (root.GetStringASCII(current_profile + ".IsRelative", &is_relative) &&
- root.GetString(current_profile + ".Path", &path16)) {
-#if defined(OS_WIN)
- ReplaceSubstringsAfterOffset(
- &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\"));
-#endif
- FilePath path = FilePath::FromWStringHack(UTF16ToWide(path16));
-
- // IsRelative=1 means the folder path would be relative to the
- // path of profiles.ini. IsRelative=0 refers to a custom profile
- // location.
- if (is_relative == "1") {
- profile_path = ini_file.DirName().Append(path);
- } else {
- profile_path = path;
- }
-
- // We only import the default profile when multiple profiles exist,
- // since the other profiles are used mostly by developers for testing.
- // Otherwise, Profile0 will be imported.
- std::string is_default;
- if ((root.GetStringASCII(current_profile + ".Default", &is_default) &&
- is_default == "1") || i == 0) {
- source_path = profile_path;
- // We break out of the loop when we have found the default profile.
- if (is_default == "1")
- break;
- }
- }
- }
+ FilePath profile_path = GetFirefoxProfilePath();
+ if (profile_path.empty())
+ return;
// Detects which version of Firefox is installed.
importer::ProfileType firefox_type;
@@ -173,7 +131,7 @@ void ImporterList::DetectFirefoxProfiles() {
version = GetCurrentFirefoxMajorVersionFromRegistry();
#endif
if (version != 2 && version != 3)
- GetFirefoxVersionAndPathFromProfile(source_path, &version, &app_path);
+ GetFirefoxVersionAndPathFromProfile(profile_path, &version, &app_path);
if (version == 2) {
firefox_type = importer::FIREFOX2;
@@ -184,20 +142,18 @@ void ImporterList::DetectFirefoxProfiles() {
return;
}
- if (!source_path.empty()) {
- importer::ProfileInfo* firefox = new importer::ProfileInfo();
- firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX);
- firefox->browser_type = firefox_type;
- firefox->source_path = source_path.ToWStringHack();
+ importer::ProfileInfo* firefox = new importer::ProfileInfo();
+ firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX);
+ firefox->browser_type = firefox_type;
+ firefox->source_path = profile_path.ToWStringHack();
#if defined(OS_WIN)
- firefox->app_path = GetFirefoxInstallPathFromRegistry();
+ firefox->app_path = GetFirefoxInstallPathFromRegistry();
#endif
- if (firefox->app_path.empty())
- firefox->app_path = app_path.ToWStringHack();
- firefox->services_supported = importer::HISTORY | importer::FAVORITES |
- importer::COOKIES | importer::PASSWORDS | importer::SEARCH_ENGINES;
- source_profiles_.push_back(firefox);
- }
+ if (firefox->app_path.empty())
+ firefox->app_path = app_path.ToWStringHack();
+ firefox->services_supported = importer::HISTORY | importer::FAVORITES |
+ importer::COOKIES | importer::PASSWORDS | importer::SEARCH_ENGINES;
+ source_profiles_.push_back(firefox);
}
void ImporterList::DetectGoogleToolbarProfiles() {
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 642af1b..2178892 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1467,6 +1467,8 @@
'browser/importer/firefox_profile_lock.h',
'browser/importer/firefox_profile_lock_posix.cc',
'browser/importer/firefox_profile_lock_win.cc',
+ 'browser/importer/firefox_proxy_settings.cc',
+ 'browser/importer/firefox_proxy_settings.h',
'browser/importer/ie_importer.cc',
'browser/importer/ie_importer.h',
'browser/importer/importer.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index c733e46..681bb0d39 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -823,6 +823,7 @@
'browser/importer/firefox_importer_unittest.cc',
'browser/importer/firefox_importer_unittest_utils.h',
'browser/importer/firefox_importer_unittest_utils_mac.cc',
+ 'browser/importer/firefox_proxy_settings_unittest.cc',
'browser/importer/importer_unittest.cc',
'browser/importer/safari_importer_unittest.mm',
'browser/importer/toolbar_importer_unittest.cc',
diff --git a/chrome/test/data/firefox3_pref.js b/chrome/test/data/firefox3_pref.js
new file mode 100644
index 0000000..7db3dc7
--- /dev/null
+++ b/chrome/test/data/firefox3_pref.js
@@ -0,0 +1,136 @@
+# Mozilla User Preferences
+
+/* Do not edit this file.
+ *
+ * If you make changes to this file while the application is running,
+ * the changes will be overwritten when the application exits.
+ *
+ * To make a manual change to preferences, you can visit the URL about:config
+ * For more information, see http://www.mozilla.org/unix/customizing.html#prefs
+ */
+
+user_pref("accessibility.typeaheadfind.flashBar", 0);
+user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1272055295);
+user_pref("app.update.lastUpdateTime.background-update-timer", 1272055295);
+user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1272054695);
+user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1271786959);
+user_pref("app.update.lastUpdateTime.places-maintenance-timer", 1272054695);
+user_pref("app.update.lastUpdateTime.restart-nag-timer", 1264545692);
+user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1272042695);
+user_pref("app.update.never.3.5.5", true);
+user_pref("app.update.never.3.5.7", false);
+user_pref("app.update.never.3.6", true);
+user_pref("browser.download.dir", "C:\\Users\\Tom\\Downloads");
+user_pref("browser.download.lastDir", "c:\\tmp");
+user_pref("browser.download.save_converter_index", 0);
+user_pref("browser.feeds.showFirstRunUI", false);
+user_pref("browser.fixup.alternate.enabled", false);
+user_pref("browser.migration.version", 1);
+user_pref("browser.open.lastDir", "C:\\tmp");
+user_pref("browser.places.importBookmarksHTML", false);
+user_pref("browser.places.importDefaults", false);
+user_pref("browser.places.leftPaneFolderId", -1);
+user_pref("browser.places.migratePostDataAnnotations", false);
+user_pref("browser.places.smartBookmarksVersion", 1);
+user_pref("browser.places.updateRecentTagsUri", false);
+user_pref("browser.preferences.advanced.selectedTabIndex", 1);
+user_pref("browser.rights.3.shown", true);
+user_pref("browser.shell.checkDefaultBrowser", false);
+user_pref("browser.startup.homepage_override.mstone", "rv:1.9.1.9");
+user_pref("browser.warnOnRestart", false);
+user_pref("extensions.enabledItems", "");
+user_pref("extensions.lastAppVersion", "3.5.9");
+user_pref("extensions.livehttpheaders.exclude", false);
+user_pref("extensions.livehttpheaders.excludeRegexp", ".gif$|.jpg$|.ico$|.css$|.js$");
+user_pref("extensions.livehttpheaders.filter", false);
+user_pref("extensions.livehttpheaders.filterRegexp", "/$|.html$");
+user_pref("extensions.livehttpheaders.mode", 1);
+user_pref("extensions.livehttpheaders.style", 0);
+user_pref("extensions.livehttpheaders.tab", false);
+user_pref("extensions.update.notifyUser", false);
+user_pref("general.useragent.extra.microsoftdotnet", "(.NET CLR 3.5.30729)");
+user_pref("google.toolbar.auto_page_translate.rules.blacklist", "");
+user_pref("google.toolbar.auto_page_translate.rules.whitelist", "");
+user_pref("google.toolbar.auto_page_translate.target_lang", "fr");
+user_pref("google.toolbar.auto_page_translate.usage", "en:-1,de:1");
+user_pref("google.toolbar.autofill.profiles", 0);
+user_pref("google.toolbar.button_option.gtbAutoFill", true);
+user_pref("google.toolbar.button_option.gtbAutoLink", true);
+user_pref("google.toolbar.button_option.gtbBookmarks", true);
+user_pref("google.toolbar.button_option.gtbPageRank", false);
+user_pref("google.toolbar.button_option.gtbSearchBookmarks", true);
+user_pref("google.toolbar.button_option.gtbSearchGoogle", true);
+user_pref("google.toolbar.button_option.gtbSpellCheck", false);
+user_pref("google.toolbar.button_option.gtbTranslate", true);
+user_pref("google.toolbar.component.bundled.dictionaries_config.json", "7.1.20100408");
+user_pref("google.toolbar.component.bundled.share_providers.json", "7.1.20100408");
+user_pref("google.toolbar.component.bundled.suggest_window.html", "7.1.20100408");
+user_pref("google.toolbar.custombuttons.migrated", "true");
+user_pref("google.toolbar.custombuttons.order.migrated.to.v6", false);
+user_pref("google.toolbar.custombuttons.version", 1);
+user_pref("google.toolbar.done_page_shown", "7.1.20100408");
+user_pref("google.toolbar.enhanced_features.week", -1);
+user_pref("google.toolbar.first_search", false);
+user_pref("google.toolbar.first_search_ping_retires", 2);
+user_pref("google.toolbar.firstrun.done", true);
+user_pref("google.toolbar.google_home", "www.google.com");
+user_pref("google.toolbar.google_home.default", "www.google.com");
+user_pref("google.toolbar.id", "Oj35xTRgvLDr2FwcLkvCyavaqTwKrlIIVxFk783ELzLh");
+user_pref("google.toolbar.install_id", "Oj35xTRgvLDr2FwcLkvCyavaqTwKrlIIVxFk783ELzLh");
+user_pref("google.toolbar.install_ping_acked", true);
+user_pref("google.toolbar.install_ping_retires", 1);
+user_pref("google.toolbar.last_ping_attempt", "1272041782265");
+user_pref("google.toolbar.linkdoctor.backup.browser.fixup.alternate.enabled", false);
+user_pref("google.toolbar.never_show_done_page", false);
+user_pref("google.toolbar.newtab", false);
+user_pref("google.toolbar.newtab-hash", "suAKo4qNilL+FK6ejwhzxIgNtWQ=");
+user_pref("google.toolbar.opted_into_advanced_features_1", false);
+user_pref("google.toolbar.rlz", "1B3GGLL_enUS361US372");
+user_pref("google.toolbar.safebrowsing.keyupdatetime", 1271867966);
+user_pref("google.toolbar.search-icon", "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7PT7/3zF6/9Ptu//RbHx/0227/+Tzvb/9vv5/97h0f9JeBz/NHoA/z98Av9AfAD/PHsA/0F6AP8AAAAA/vz7/1+33/8Mp+z/FrHw/xWy8f8bs/T/Hqrx/3zE7v////7/t8qp/zF2A/87gwH/P4ID/z59AP8+egD/Q3kA/97s8v8botj/ELn3/wy58f8PtfL/D7Lw/xuz9P8vq+f/8/n///779v9KhR3/OYYA/0GFAv88hgD/QIAC/z17AP/0+/j/N6bM/wC07/8Cxf7/CsP7/wm+9v8Aqur/SrDb//7+/v///P7/VZEl/zSJAP87jQD/PYYA/0OBBf8+fQH///3//9Dp8/84sM7/CrDf/wC14/8CruL/KqnW/9ns8f/8/v//4OjX/z+GDf85kAD/PIwD/z2JAv8+hQD/PoEA/9C7pv/97uv////+/9Xw+v+w3ej/ls/e/+rz9///////+/z6/22mSf8qjQH/OJMA/zuQAP85iwL/PIgA/zyFAP+OSSL/nV44/7J+Vv/AkG7/7trP//7//f/9//7/6/Lr/2uoRv8tjQH/PJYA/zuTAP87kwD/PY8A/z2KAP89hAD/olkn/6RVHP+eSgj/mEgR//Ho3//+/v7/5Ozh/1GaJv8tlAD/OZcC/zuXAv84lAD/O5IC/z2PAf89iwL/OIkA/6hWFf+cTxD/pm9C/76ihP/8/v//+////8nav/8fdwL/NZsA/zeZAP83mgD/PJQB/zyUAf84jwD/PYsB/z6HAf+fXif/1r6s//79///58u//3r+g/+3i2v/+//3/mbiF/yyCAP87mgP/OpgD/zeWAP85lgD/OpEB/z+TAP9ChwH/7eHb/////v/28ej/tWwo/7tUAP+5XQ7/5M+5/////v+bsZn/IHAd/zeVAP89lgP/O5MA/zaJCf8tZTr/DyuK//3////9////0qmC/7lTAP/KZAT/vVgC/8iQWf/+//3///j//ygpx/8GGcL/ESax/xEgtv8FEMz/AALh/wAB1f///f7///z//758O//GXQL/yGYC/8RaAv/Ojlf/+/////////9QU93/BAD0/wAB//8DAP3/AAHz/wAA5f8DAtr///////v7+/+2bCT/yGMA/89mAP/BWQD/0q+D///+/////P7/Rkbg/wEA+f8AA/z/AQH5/wMA8P8AAev/AADf///7/P////7/uINQ/7lXAP/MYwL/vGIO//Lm3P/8/v//1dT2/woM5/8AAP3/AwH+/wAB/f8AAfb/BADs/wAC4P8AAAAA//z7/+LbzP+mXyD/oUwE/9Gshv/8//3/7/H5/zo/w/8AAdX/AgL6/wAA/f8CAP3/AAH2/wAA7v8AAAAAgAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAEAAA==");
+user_pref("google.toolbar.searchdomaincheck.done", true);
+user_pref("google.toolbar.seenInstaller", false);
+user_pref("google.toolbar.sent", "1");
+user_pref("google.toolbar.sentfs", "1");
+user_pref("google.toolbar.sharing.button-promotion-shown", 3);
+user_pref("google.toolbar.sharing.usage.Facebook", 1);
+user_pref("google.toolbar.sidewiki.enabled", false);
+user_pref("google.toolbar.sidewiki.first.run", false);
+user_pref("google.toolbar.spell_check.dictionary.words2", "");
+user_pref("google.toolbar.spell_check.lang", "en");
+user_pref("google.toolbar.spell_check.last_lang", "en");
+user_pref("google.toolbar.tbsync.backup_saved", false);
+user_pref("google.toolbar.tbsync.promotions", 0);
+user_pref("google.toolbar.thumbnail.clean-counter", 0);
+user_pref("google.toolbar.thumbnail.clearing", 680);
+user_pref("google.toolbar.translate.hover", false);
+user_pref("google.toolbar.translate.target_lang", "es");
+user_pref("google.toolbar.usage_stats.default", true);
+user_pref("idle.lastDailyNotification", 1271987453);
+user_pref("intl.charsetmenu.browser.cache", "windows-1252, us-ascii, ISO-8859-1, UTF-8");
+user_pref("metrics.event-count", 0);
+user_pref("metrics.last-session-id", 17);
+user_pref("metrics.upload.enable", true);
+user_pref("metrics.upload.next-ping", 1271969199);
+user_pref("microsoft.CLR.auto_install", false);
+user_pref("network.cookie.prefsMigrated", true);
+user_pref("network.proxy.ftp", "ftp_proxy");
+user_pref("network.proxy.ftp_port", 3333);
+user_pref("network.proxy.gopher", "gopher_proxy");
+user_pref("network.proxy.gopher_port", 4444);
+user_pref("network.proxy.http", "http_proxy");
+user_pref("network.proxy.http_port", 1111);
+user_pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1,noproxy.com");
+user_pref("network.proxy.socks", "socks_host");
+user_pref("network.proxy.socks_port", 5555);
+user_pref("network.proxy.socks_version", 4);
+user_pref("network.proxy.ssl", "ssl_proxy");
+user_pref("network.proxy.ssl_port", 2222);
+user_pref("network.proxy.type", 1);
+user_pref("privacy.sanitize.migrateFx3Prefs", true);
+user_pref("privacy.sanitize.timeSpan", 0);
+user_pref("security.warn_viewing_mixed", false);
+user_pref("spellchecker.dictionary", "en-US");
+user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1273341477);
+user_pref("xpinstall.whitelist.add", "");
+user_pref("xpinstall.whitelist.add.103", "");