summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-19 15:57:13 +0000
committerpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-19 15:57:13 +0000
commita8b7a15ff429ecfca9e0ae4446b734cad0648a54 (patch)
treef458e9cc33a1229fafc9cb567686d7f788eef769 /chrome
parent7d12ee16699e8f611f4d1e367a0485a444957386 (diff)
downloadchromium_src-a8b7a15ff429ecfca9e0ae4446b734cad0648a54.zip
chromium_src-a8b7a15ff429ecfca9e0ae4446b734cad0648a54.tar.gz
chromium_src-a8b7a15ff429ecfca9e0ae4446b734cad0648a54.tar.bz2
Revert 212579 "Move firefox_proxy_settings* out of importer."
> Move firefox_proxy_settings* out of importer. > > Apparently FirefoxProxySettings has nothing to do with importer/, it's use only > by c/b/net. So per request we move it there. > > BUG=258876 > TEST=unit_tests > TBR=eroman@chromium.org, gab@chromium.org, thestig@chromium.org > > Review URL: https://codereview.chromium.org/18612016 TBR=tfarina@chromium.org Review URL: https://codereview.chromium.org/19786003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/importer/firefox_proxy_settings.cc (renamed from chrome/browser/net/firefox_proxy_settings.cc)82
-rw-r--r--chrome/browser/importer/firefox_proxy_settings.h (renamed from chrome/browser/net/firefox_proxy_settings.h)6
-rw-r--r--chrome/browser/importer/firefox_proxy_settings_unittest.cc (renamed from chrome/browser/net/firefox_proxy_settings_unittest.cc)4
-rw-r--r--chrome/browser/net/connection_tester.cc2
-rw-r--r--chrome/chrome_browser.gypi6
-rw-r--r--chrome/chrome_tests_unit.gypi2
-rw-r--r--chrome/common/importer/firefox_importer_utils.cc72
-rw-r--r--chrome/common/importer/firefox_importer_utils.h9
8 files changed, 92 insertions, 91 deletions
diff --git a/chrome/browser/net/firefox_proxy_settings.cc b/chrome/browser/importer/firefox_proxy_settings.cc
index 07604ab..58aa4f36 100644
--- a/chrome/browser/net/firefox_proxy_settings.cc
+++ b/chrome/browser/importer/firefox_proxy_settings.cc
@@ -2,11 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/net/firefox_proxy_settings.h"
+#include "chrome/browser/importer/firefox_proxy_settings.h"
-#include "base/file_util.h"
#include "base/files/file_path.h"
-#include "base/strings/string_number_conversions.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "base/values.h"
@@ -59,84 +57,6 @@ FirefoxProxySettings::SOCKSVersion IntToSOCKSVersion(int type) {
}
}
-// 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).
-// Note: for strings, only valid UTF-8 string values are supported. If a
-// key/pair is not valid UTF-8, it is ignored and will not appear in |prefs|.
-bool ParsePrefFile(const base::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(key, is_value_true);
- continue;
- }
-
- // Value could be a string.
- if (value.size() >= 2U &&
- value[0] == '"' && value[value.size() - 1] == '"') {
- value = value.substr(1, value.size() - 2);
- // ValueString only accept valid UTF-8. Simply ignore that entry if it is
- // not UTF-8.
- if (IsStringUTF8(value))
- prefs->SetString(key, value);
- else
- VLOG(1) << "Non UTF8 value for key " << key << ", ignored.";
- continue;
- }
-
- // Or value could be an integer.
- int int_value = 0;
- if (base::StringToInt(value, &int_value)) {
- prefs->SetInteger(key, int_value);
- continue;
- }
-
- LOG(ERROR) << "Invalid value found in Firefox pref file '"
- << pref_file.value() << "' value is '" << value << "'.";
- }
- return true;
-}
-
} // namespace
FirefoxProxySettings::FirefoxProxySettings() {
diff --git a/chrome/browser/net/firefox_proxy_settings.h b/chrome/browser/importer/firefox_proxy_settings.h
index 31dbff8..41657a2 100644
--- a/chrome/browser/net/firefox_proxy_settings.h
+++ b/chrome/browser/importer/firefox_proxy_settings.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_NET_FIREFOX_PROXY_SETTINGS_H_
-#define CHROME_BROWSER_NET_FIREFOX_PROXY_SETTINGS_H_
+#ifndef CHROME_BROWSER_IMPORTER_FIREFOX_PROXY_SETTINGS_H_
+#define CHROME_BROWSER_IMPORTER_FIREFOX_PROXY_SETTINGS_H_
#include <string>
#include <vector>
@@ -109,4 +109,4 @@ class FirefoxProxySettings {
DISALLOW_COPY_AND_ASSIGN(FirefoxProxySettings);
};
-#endif // CHROME_BROWSER_NET_FIREFOX_PROXY_SETTINGS_H_
+#endif // CHROME_BROWSER_IMPORTER_FIREFOX_PROXY_SETTINGS_H_
diff --git a/chrome/browser/net/firefox_proxy_settings_unittest.cc b/chrome/browser/importer/firefox_proxy_settings_unittest.cc
index 78d351c..7699e13 100644
--- a/chrome/browser/net/firefox_proxy_settings_unittest.cc
+++ b/chrome/browser/importer/firefox_proxy_settings_unittest.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/net/firefox_proxy_settings.h"
+#include "testing/gtest/include/gtest/gtest.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
+#include "chrome/browser/importer/firefox_proxy_settings.h"
#include "chrome/common/chrome_paths.h"
#include "net/proxy/proxy_config.h"
-#include "testing/gtest/include/gtest/gtest.h"
class FirefoxProxySettingsTest : public testing::Test {
};
diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc
index 7a06aae..5127d55 100644
--- a/chrome/browser/net/connection_tester.cc
+++ b/chrome/browser/net/connection_tester.cc
@@ -37,7 +37,7 @@
#include "net/url_request/url_request_context_storage.h"
#if !defined(OS_ANDROID) && !defined(OS_IOS)
-#include "chrome/browser/net/firefox_proxy_settings.h"
+#include "chrome/browser/importer/firefox_proxy_settings.h"
#endif
namespace {
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a26d3a7..2b79c88 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -832,6 +832,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/importer_list.cc',
'browser/importer/importer_list.h',
'browser/importer/importer_list_observer.h',
@@ -1091,15 +1093,13 @@
'browser/net/dns_probe_service.h',
'browser/net/evicted_domain_cookie_counter.cc',
'browser/net/evicted_domain_cookie_counter.h',
- 'browser/net/firefox_proxy_settings.cc',
- 'browser/net/firefox_proxy_settings.h',
'browser/net/gaia/gaia_oauth_consumer.h',
'browser/net/gaia/gaia_oauth_fetcher.cc',
'browser/net/gaia/gaia_oauth_fetcher.h',
'browser/net/http_pipelining_compatibility_client.cc',
'browser/net/http_pipelining_compatibility_client.h',
- 'browser/net/http_server_properties_manager.cc',
'browser/net/http_server_properties_manager.h',
+ 'browser/net/http_server_properties_manager.cc',
'browser/net/load_time_stats.cc',
'browser/net/load_time_stats.h',
'browser/net/net_error_tab_helper.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index d7d1268..31ac60b 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -928,6 +928,7 @@
'browser/history/visit_filter_unittest.cc',
'browser/history/visit_tracker_unittest.cc',
'browser/importer/firefox_profile_lock_unittest.cc',
+ 'browser/importer/firefox_proxy_settings_unittest.cc',
'browser/importer/profile_writer_unittest.cc',
'browser/internal_auth_unittest.cc',
'browser/invalidation/invalidation_service_android_unittest.cc',
@@ -972,7 +973,6 @@
'browser/net/dns_probe_runner_unittest.cc',
'browser/net/dns_probe_service_unittest.cc',
'browser/net/evicted_domain_cookie_counter_unittest.cc',
- 'browser/net/firefox_proxy_settings_unittest.cc',
'browser/net/gaia/gaia_oauth_fetcher_unittest.cc',
'browser/net/http_pipelining_compatibility_client_unittest.cc',
'browser/net/http_server_properties_manager_unittest.cc',
diff --git a/chrome/common/importer/firefox_importer_utils.cc b/chrome/common/importer/firefox_importer_utils.cc
index 5ec56d6..d6ec2d3 100644
--- a/chrome/common/importer/firefox_importer_utils.cc
+++ b/chrome/common/importer/firefox_importer_utils.cc
@@ -226,6 +226,78 @@ bool IsDefaultHomepage(const GURL& homepage, const base::FilePath& app_path) {
return false;
}
+bool ParsePrefFile(const base::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(key, is_value_true);
+ continue;
+ }
+
+ // Value could be a string.
+ if (value.size() >= 2U &&
+ value[0] == '"' && value[value.size() - 1] == '"') {
+ value = value.substr(1, value.size() - 2);
+ // ValueString only accept valid UTF-8. Simply ignore that entry if it is
+ // not UTF-8.
+ if (IsStringUTF8(value))
+ prefs->SetString(key, value);
+ else
+ VLOG(1) << "Non UTF8 value for key " << key << ", ignored.";
+ continue;
+ }
+
+ // Or value could be an integer.
+ int int_value = 0;
+ if (base::StringToInt(value, &int_value)) {
+ prefs->SetInteger(key, int_value);
+ continue;
+ }
+
+ LOG(ERROR) << "Invalid value found in Firefox pref file '"
+ << pref_file.value() << "' value is '" << value << "'.";
+ }
+ return true;
+}
+
std::string GetPrefsJsValue(const std::string& content,
const std::string& pref_key) {
// This file has the syntax: user_pref("key", value);
diff --git a/chrome/common/importer/firefox_importer_utils.h b/chrome/common/importer/firefox_importer_utils.h
index 54c5a74..09da571 100644
--- a/chrome/common/importer/firefox_importer_utils.h
+++ b/chrome/common/importer/firefox_importer_utils.h
@@ -84,6 +84,15 @@ GURL GetHomepage(const base::FilePath& profile_path);
// directory.
bool IsDefaultHomepage(const GURL& homepage, const base::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).
+// Note: for strings, only valid UTF-8 string values are supported. If a
+// key/pair is not valid UTF-8, it is ignored and will not appear in |prefs|.
+bool ParsePrefFile(const base::FilePath& pref_file,
+ base::DictionaryValue* prefs);
+
// Parses the value of a particular firefox preference from a string that is the
// contents of the prefs file.
std::string GetPrefsJsValue(const std::string& prefs,