summaryrefslogtreecommitdiffstats
path: root/chrome/browser/importer
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-20 19:25:42 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-20 19:25:42 +0000
commit00e3f152083aea092353b3d284c368b48136f33c (patch)
tree081df57119ba9301bebd7c7091efc4acab5accc9 /chrome/browser/importer
parent4e6f2f037e6d1956bc431ac37a72d8e6871586d8 (diff)
downloadchromium_src-00e3f152083aea092353b3d284c368b48136f33c.zip
chromium_src-00e3f152083aea092353b3d284c368b48136f33c.tar.gz
chromium_src-00e3f152083aea092353b3d284c368b48136f33c.tar.bz2
Convert some structures in webkit/glue to string16.
R=yaar BUG=none TEST=none Review URL: http://codereview.chromium.org/305002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29549 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r--chrome/browser/importer/firefox_importer_unittest.cc20
-rw-r--r--chrome/browser/importer/firefox_importer_unittest_messages_internal.h2
-rw-r--r--chrome/browser/importer/firefox_importer_unittest_utils.h4
-rw-r--r--chrome/browser/importer/firefox_importer_unittest_utils_mac.cc10
-rw-r--r--chrome/browser/importer/nss_decryptor.cc16
-rw-r--r--chrome/browser/importer/nss_decryptor_linux.h2
-rw-r--r--chrome/browser/importer/nss_decryptor_mac.h2
7 files changed, 30 insertions, 26 deletions
diff --git a/chrome/browser/importer/firefox_importer_unittest.cc b/chrome/browser/importer/firefox_importer_unittest.cc
index fa5086c..c2e0210 100644
--- a/chrome/browser/importer/firefox_importer_unittest.cc
+++ b/chrome/browser/importer/firefox_importer_unittest.cc
@@ -35,11 +35,13 @@ TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) {
EXPECT_TRUE(decryptor_proxy.DecryptorInit(nss_path.ToWStringHack(),
db_path.ToWStringHack()));
- EXPECT_EQ(L"hello", decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE"
- "wFAYIKoZIhvcNAwcECBJM63MpT9rtBAjMCm7qo/EhlA=="));
+ EXPECT_EQ(ASCIIToUTF16("hello"),
+ decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECBJ"
+ "M63MpT9rtBAjMCm7qo/EhlA=="));
// Test UTF-16 encoding.
- EXPECT_EQ(L"\x4E2D", decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE"
- "wFAYIKoZIhvcNAwcECN9OQ5ZFmhb8BAiFo1Z+fUvaIQ=="));
+ EXPECT_EQ(WideToUTF16(L"\x4E2D"),
+ decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECN9"
+ "OQ5ZFmhb8BAiFo1Z+fUvaIQ=="));
}
TEST(FirefoxImporterTest, Firefox3NSS3Decryptor) {
@@ -59,11 +61,13 @@ TEST(FirefoxImporterTest, Firefox3NSS3Decryptor) {
EXPECT_TRUE(decryptor_proxy.DecryptorInit(nss_path.ToWStringHack(),
db_path.ToWStringHack()));
- EXPECT_EQ(L"hello", decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE"
- "wFAYIKoZIhvcNAwcECKajtRg4qFSHBAhv9luFkXgDJA=="));
+ EXPECT_EQ(ASCIIToUTF16("hello"),
+ decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECKa"
+ "jtRg4qFSHBAhv9luFkXgDJA=="));
// Test UTF-16 encoding.
- EXPECT_EQ(L"\x4E2D", decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE"
- "wFAYIKoZIhvcNAwcECLWqqiccfQHWBAie74hxnULxlw=="));
+ EXPECT_EQ(WideToUTF16(L"\x4E2D"),
+ decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECLW"
+ "qqiccfQHWBAie74hxnULxlw=="));
}
TEST(FirefoxImporterTest, Firefox2BookmarkParse) {
diff --git a/chrome/browser/importer/firefox_importer_unittest_messages_internal.h b/chrome/browser/importer/firefox_importer_unittest_messages_internal.h
index 72eff6f..68b2582 100644
--- a/chrome/browser/importer/firefox_importer_unittest_messages_internal.h
+++ b/chrome/browser/importer/firefox_importer_unittest_messages_internal.h
@@ -25,7 +25,7 @@ IPC_MESSAGE_CONTROL1(Msg_Decrypt,
std::string /* crypt */)
// Child->Server: Decrypted String.
IPC_MESSAGE_CONTROL1(Msg_Decryptor_Response,
- std::wstring /* unencrypted_str */)
+ string16 /* unencrypted_str */)
// Server->Child: Die.
IPC_MESSAGE_CONTROL0(Msg_Decryptor_Quit)
diff --git a/chrome/browser/importer/firefox_importer_unittest_utils.h b/chrome/browser/importer/firefox_importer_unittest_utils.h
index c989bd6..6db8ee4 100644
--- a/chrome/browser/importer/firefox_importer_unittest_utils.h
+++ b/chrome/browser/importer/firefox_importer_unittest_utils.h
@@ -38,7 +38,7 @@ class FFUnitTestDecryptorProxy {
// This match the parallel functions in NSSDecryptor.
bool DecryptorInit(const std::wstring& dll_path, const std::wstring& db_path);
- std::wstring Decrypt(const std::string& crypt);
+ string16 Decrypt(const std::string& crypt);
private:
#if defined(OS_MACOSX)
@@ -76,7 +76,7 @@ bool FFUnitTestDecryptorProxy::DecryptorInit(const std::wstring& dll_path,
return decryptor_.Init(dll_path, db_path);
}
-std::wstring FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) {
+string16 FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) {
return decryptor_.Decrypt(crypt);
}
#endif // !OS_MACOSX
diff --git a/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc b/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc
index a6757f9..7b559bb 100644
--- a/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc
+++ b/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc
@@ -84,7 +84,7 @@ class FFDecryptorServerChannelListener : public IPC::Channel::Listener {
MessageLoop::current()->Quit();
}
- void OnDecryptedTextResonse(std::wstring decrypted_text) {
+ void OnDecryptedTextResonse(const string16& decrypted_text) {
DCHECK(!got_result);
result_string = decrypted_text;
got_result = true;
@@ -110,7 +110,7 @@ class FFDecryptorServerChannelListener : public IPC::Channel::Listener {
}
// Results of IPC calls.
- std::wstring result_string;
+ string16 result_string;
bool result_bool;
// True if IPC call succeeded and data in above variables is valid.
bool got_result;
@@ -196,14 +196,14 @@ bool FFUnitTestDecryptorProxy::DecryptorInit(const std::wstring& dll_path,
return false;
}
-std::wstring FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) {
+string16 FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) {
channel_->Send(new Msg_Decrypt(crypt));
bool ok = WaitForClientResponse();
if (ok && listener_->got_result) {
listener_->got_result = false;
return listener_->result_string;
}
- return L"";
+ return string16();
}
//---------------------------- Child Process -----------------------
@@ -225,7 +225,7 @@ class FFDecryptorClientChannelListener : public IPC::Channel::Listener {
}
void OnDecrypt(std::string crypt) {
- std::wstring unencrypted_str = decryptor_.Decrypt(crypt);
+ string16 unencrypted_str = decryptor_.Decrypt(crypt);
sender_->Send(new Msg_Decryptor_Response(unencrypted_str));
}
diff --git a/chrome/browser/importer/nss_decryptor.cc b/chrome/browser/importer/nss_decryptor.cc
index 13bb14b..db2c89f 100644
--- a/chrome/browser/importer/nss_decryptor.cc
+++ b/chrome/browser/importer/nss_decryptor.cc
@@ -59,10 +59,10 @@ using webkit_glue::PasswordForm;
*
* ***** END LICENSE BLOCK ***** */
-std::wstring NSSDecryptor::Decrypt(const std::string& crypt) const {
+string16 NSSDecryptor::Decrypt(const std::string& crypt) const {
// Do nothing if NSS is not loaded.
if (!is_nss_initialized_)
- return std::wstring();
+ return string16();
// The old style password is encoded in base64. They are identified
// by a leading '~'. Otherwise, we should decrypt the text.
@@ -74,7 +74,7 @@ std::wstring NSSDecryptor::Decrypt(const std::string& crypt) const {
SECStatus result = PK11_Authenticate(slot, PR_TRUE, NULL);
if (result != SECSuccess) {
FreeSlot(slot);
- return std::wstring();
+ return string16();
}
SECItem request;
@@ -99,7 +99,7 @@ std::wstring NSSDecryptor::Decrypt(const std::string& crypt) const {
net::Base64Decode(crypt.substr(1), &plain);
}
- return UTF8ToWide(plain);
+ return UTF8ToUTF16(plain);
}
// There are three versions of password filess. They store saved user
@@ -202,11 +202,11 @@ void NSSDecryptor::ParseSignons(const std::string& content,
// line (contains a dot).
while (begin + 4 < end) {
// The user name.
- form.username_element = UTF8ToWide(lines[begin++]);
+ form.username_element = UTF8ToUTF16(lines[begin++]);
form.username_value = Decrypt(lines[begin++]);
// The element name has a leading '*'.
if (lines[begin].at(0) == '*') {
- form.password_element = UTF8ToWide(lines[begin++].substr(1));
+ form.password_element = UTF8ToUTF16(lines[begin++].substr(1));
form.password_value = Decrypt(lines[begin++]);
} else {
// Maybe the file is bad, we skip to next block.
@@ -286,9 +286,9 @@ bool NSSDecryptor::ReadAndParseSignons(const FilePath& sqlite_file,
form.signon_realm += realm;
form.ssl_valid = form.origin.SchemeIsSecure();
// The user name, password and action.
- form.username_element = UTF8ToWide(s2.column_string(3));
+ form.username_element = UTF8ToUTF16(s2.column_string(3));
form.username_value = Decrypt(s2.column_string(5));
- form.password_element = UTF8ToWide(s2.column_string(4));
+ form.password_element = UTF8ToUTF16(s2.column_string(4));
form.password_value = Decrypt(s2.column_string(6));
form.action = GURL(s2.column_string(2)).ReplaceComponents(rep);
forms->push_back(form);
diff --git a/chrome/browser/importer/nss_decryptor_linux.h b/chrome/browser/importer/nss_decryptor_linux.h
index d73c733..05684fd 100644
--- a/chrome/browser/importer/nss_decryptor_linux.h
+++ b/chrome/browser/importer/nss_decryptor_linux.h
@@ -28,7 +28,7 @@ class NSSDecryptor {
// Decrypts Firefox stored passwords. Before using this method,
// make sure Init() returns true.
- std::wstring Decrypt(const std::string& crypt) const;
+ string16 Decrypt(const std::string& crypt) const;
// Parses the Firefox password file content, decrypts the
// username/password and reads other related information.
diff --git a/chrome/browser/importer/nss_decryptor_mac.h b/chrome/browser/importer/nss_decryptor_mac.h
index 477cf53..af1b004 100644
--- a/chrome/browser/importer/nss_decryptor_mac.h
+++ b/chrome/browser/importer/nss_decryptor_mac.h
@@ -123,7 +123,7 @@ class NSSDecryptor {
// Decrypts Firefox stored passwords. Before using this method,
// make sure Init() returns true.
- std::wstring Decrypt(const std::string& crypt) const;
+ string16 Decrypt(const std::string& crypt) const;
// Parses the Firefox password file content, decrypts the
// username/password and reads other related information.